Changeset 41021 in vbox
- Timestamp:
- Apr 23, 2012 11:02:30 AM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 77 edited
- 14 copied
-
Makefile.kmk (modified) (8 diffs)
-
src/globals/VBoxDefs.cpp (modified) (1 diff)
-
src/globals/VBoxDefs.h (modified) (1 diff)
-
src/selector/UISelectorWindow.cpp (modified) (1 diff)
-
src/widgets/VBoxFilePathSelectorWidget.cpp (modified) (1 diff)
-
src/widgets/VBoxFilePathSelectorWidget.h (modified) (1 diff)
-
src/wizards/UIWizard.cpp (modified) (7 diffs)
-
src/wizards/UIWizard.h (modified) (3 diffs)
-
src/wizards/UIWizardPage.cpp (modified) (1 diff)
-
src/wizards/UIWizardPage.h (modified) (4 diffs)
-
src/wizards/clonevd/UIWizardCloneVD.cpp (modified) (4 diffs)
-
src/wizards/clonevd/UIWizardCloneVD.h (modified) (3 diffs)
-
src/wizards/clonevd/UIWizardCloneVDPageBasic1.cpp (modified) (4 diffs)
-
src/wizards/clonevd/UIWizardCloneVDPageBasic1.h (modified) (3 diffs)
-
src/wizards/clonevd/UIWizardCloneVDPageBasic2.cpp (modified) (3 diffs)
-
src/wizards/clonevd/UIWizardCloneVDPageBasic2.h (modified) (2 diffs)
-
src/wizards/clonevd/UIWizardCloneVDPageBasic3.cpp (modified) (4 diffs)
-
src/wizards/clonevd/UIWizardCloneVDPageBasic3.h (modified) (3 diffs)
-
src/wizards/clonevd/UIWizardCloneVDPageBasic4.cpp (modified) (8 diffs)
-
src/wizards/clonevd/UIWizardCloneVDPageBasic4.h (modified) (4 diffs)
-
src/wizards/clonevd/UIWizardCloneVDPageBasic5.cpp (modified) (2 diffs)
-
src/wizards/clonevd/UIWizardCloneVDPageBasic5.h (modified) (1 diff)
-
src/wizards/clonevd/UIWizardCloneVDPageExpert.cpp (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic1.cpp ) (3 diffs)
-
src/wizards/clonevd/UIWizardCloneVDPageExpert.h (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic1.h ) (3 diffs)
-
src/wizards/clonevm/UIWizardCloneVM.cpp (modified) (7 diffs)
-
src/wizards/clonevm/UIWizardCloneVM.h (modified) (3 diffs)
-
src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp (modified) (4 diffs)
-
src/wizards/clonevm/UIWizardCloneVMPageBasic1.h (modified) (2 diffs)
-
src/wizards/clonevm/UIWizardCloneVMPageBasic2.cpp (modified) (7 diffs)
-
src/wizards/clonevm/UIWizardCloneVMPageBasic2.h (modified) (3 diffs)
-
src/wizards/clonevm/UIWizardCloneVMPageBasic3.cpp (modified) (5 diffs)
-
src/wizards/clonevm/UIWizardCloneVMPageBasic3.h (modified) (3 diffs)
-
src/wizards/clonevm/UIWizardCloneVMPageExpert.cpp (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp ) (3 diffs)
-
src/wizards/clonevm/UIWizardCloneVMPageExpert.h (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.h ) (3 diffs)
-
src/wizards/exportappliance/UIWizardExportApp.cpp (modified) (3 diffs)
-
src/wizards/exportappliance/UIWizardExportApp.h (modified) (4 diffs)
-
src/wizards/exportappliance/UIWizardExportAppDefs.h (modified) (2 diffs)
-
src/wizards/exportappliance/UIWizardExportAppPageBasic1.cpp (modified) (5 diffs)
-
src/wizards/exportappliance/UIWizardExportAppPageBasic1.h (modified) (2 diffs)
-
src/wizards/exportappliance/UIWizardExportAppPageBasic2.cpp (modified) (5 diffs)
-
src/wizards/exportappliance/UIWizardExportAppPageBasic2.h (modified) (2 diffs)
-
src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp (modified) (7 diffs)
-
src/wizards/exportappliance/UIWizardExportAppPageBasic3.h (modified) (3 diffs)
-
src/wizards/exportappliance/UIWizardExportAppPageBasic4.cpp (modified) (4 diffs)
-
src/wizards/exportappliance/UIWizardExportAppPageBasic4.h (modified) (4 diffs)
-
src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic1.cpp ) (2 diffs)
-
src/wizards/exportappliance/UIWizardExportAppPageExpert.h (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic1.h ) (3 diffs)
-
src/wizards/firstrun/UIWizardFirstRun.cpp (modified) (3 diffs)
-
src/wizards/firstrun/UIWizardFirstRun.h (modified) (4 diffs)
-
src/wizards/firstrun/UIWizardFirstRunPageBasic1.cpp (modified) (2 diffs)
-
src/wizards/firstrun/UIWizardFirstRunPageBasic1.h (modified) (2 diffs)
-
src/wizards/firstrun/UIWizardFirstRunPageBasic2.cpp (modified) (5 diffs)
-
src/wizards/firstrun/UIWizardFirstRunPageBasic2.h (modified) (3 diffs)
-
src/wizards/firstrun/UIWizardFirstRunPageBasic3.cpp (modified) (2 diffs)
-
src/wizards/firstrun/UIWizardFirstRunPageBasic3.h (modified) (2 diffs)
-
src/wizards/firstrun/UIWizardFirstRunPageExpert.cpp (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic1.cpp ) (3 diffs)
-
src/wizards/firstrun/UIWizardFirstRunPageExpert.h (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic1.h ) (3 diffs)
-
src/wizards/importappliance/UIWizardImportApp.cpp (modified) (5 diffs)
-
src/wizards/importappliance/UIWizardImportApp.h (modified) (4 diffs)
-
src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp (modified) (5 diffs)
-
src/wizards/importappliance/UIWizardImportAppPageBasic1.h (modified) (2 diffs)
-
src/wizards/importappliance/UIWizardImportAppPageBasic2.cpp (modified) (2 diffs)
-
src/wizards/importappliance/UIWizardImportAppPageBasic2.h (modified) (3 diffs)
-
src/wizards/importappliance/UIWizardImportAppPageExpert.cpp (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp ) (3 diffs)
-
src/wizards/importappliance/UIWizardImportAppPageExpert.h (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.h ) (3 diffs)
-
src/wizards/newvd/UIWizardNewVD.cpp (modified) (8 diffs)
-
src/wizards/newvd/UIWizardNewVD.h (modified) (3 diffs)
-
src/wizards/newvd/UIWizardNewVDPageBasic1.cpp (modified) (7 diffs)
-
src/wizards/newvd/UIWizardNewVDPageBasic1.h (modified) (2 diffs)
-
src/wizards/newvd/UIWizardNewVDPageBasic2.cpp (modified) (4 diffs)
-
src/wizards/newvd/UIWizardNewVDPageBasic2.h (modified) (3 diffs)
-
src/wizards/newvd/UIWizardNewVDPageBasic3.cpp (modified) (14 diffs)
-
src/wizards/newvd/UIWizardNewVDPageBasic3.h (modified) (4 diffs)
-
src/wizards/newvd/UIWizardNewVDPageBasic4.cpp (modified) (2 diffs)
-
src/wizards/newvd/UIWizardNewVDPageBasic4.h (modified) (2 diffs)
-
src/wizards/newvd/UIWizardNewVDPageExpert.cpp (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.cpp ) (3 diffs)
-
src/wizards/newvd/UIWizardNewVDPageExpert.h (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.h ) (3 diffs)
-
src/wizards/newvm/UIWizardNewVM.cpp (modified) (5 diffs)
-
src/wizards/newvm/UIWizardNewVM.h (modified) (3 diffs)
-
src/wizards/newvm/UIWizardNewVMPageBasic1.cpp (modified) (3 diffs)
-
src/wizards/newvm/UIWizardNewVMPageBasic1.h (modified) (1 diff)
-
src/wizards/newvm/UIWizardNewVMPageBasic2.cpp (modified) (7 diffs)
-
src/wizards/newvm/UIWizardNewVMPageBasic2.h (modified) (3 diffs)
-
src/wizards/newvm/UIWizardNewVMPageBasic3.cpp (modified) (4 diffs)
-
src/wizards/newvm/UIWizardNewVMPageBasic3.h (modified) (3 diffs)
-
src/wizards/newvm/UIWizardNewVMPageBasic4.cpp (modified) (8 diffs)
-
src/wizards/newvm/UIWizardNewVMPageBasic4.h (modified) (4 diffs)
-
src/wizards/newvm/UIWizardNewVMPageBasic5.cpp (modified) (4 diffs)
-
src/wizards/newvm/UIWizardNewVMPageBasic5.h (modified) (3 diffs)
-
src/wizards/newvm/UIWizardNewVMPageExpert.cpp (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp ) (2 diffs)
-
src/wizards/newvm/UIWizardNewVMPageExpert.h (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h ) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r40872 r41021 365 365 src/wizards/newvm/UIWizardNewVMPageBasic4.h \ 366 366 src/wizards/newvm/UIWizardNewVMPageBasic5.h \ 367 src/wizards/newvm/UIWizardNewVMPageExpert.h \ 367 368 src/wizards/newvd/UIWizardNewVD.h \ 368 369 src/wizards/newvd/UIWizardNewVDPageBasic1.h \ … … 370 371 src/wizards/newvd/UIWizardNewVDPageBasic3.h \ 371 372 src/wizards/newvd/UIWizardNewVDPageBasic4.h \ 373 src/wizards/newvd/UIWizardNewVDPageExpert.h \ 372 374 src/wizards/clonevm/UIWizardCloneVM.h \ 373 375 src/wizards/clonevm/UIWizardCloneVMPageBasic1.h \ 374 376 src/wizards/clonevm/UIWizardCloneVMPageBasic2.h \ 375 377 src/wizards/clonevm/UIWizardCloneVMPageBasic3.h \ 378 src/wizards/clonevm/UIWizardCloneVMPageExpert.h \ 376 379 src/wizards/clonevd/UIWizardCloneVD.h \ 377 380 src/wizards/clonevd/UIWizardCloneVDPageBasic1.h \ … … 380 383 src/wizards/clonevd/UIWizardCloneVDPageBasic4.h \ 381 384 src/wizards/clonevd/UIWizardCloneVDPageBasic5.h \ 385 src/wizards/clonevd/UIWizardCloneVDPageExpert.h \ 382 386 src/wizards/exportappliance/UIWizardExportApp.h \ 383 387 src/wizards/exportappliance/UIWizardExportAppPageBasic1.h \ … … 385 389 src/wizards/exportappliance/UIWizardExportAppPageBasic3.h \ 386 390 src/wizards/exportappliance/UIWizardExportAppPageBasic4.h \ 391 src/wizards/exportappliance/UIWizardExportAppPageExpert.h \ 387 392 src/wizards/importappliance/UIWizardImportApp.h \ 388 393 src/wizards/importappliance/UIWizardImportAppPageBasic1.h \ 389 394 src/wizards/importappliance/UIWizardImportAppPageBasic2.h \ 395 src/wizards/importappliance/UIWizardImportAppPageExpert.h \ 390 396 src/wizards/firstrun/UIWizardFirstRun.h \ 391 397 src/wizards/firstrun/UIWizardFirstRunPageBasic1.h \ 392 398 src/wizards/firstrun/UIWizardFirstRunPageBasic2.h \ 393 src/wizards/firstrun/UIWizardFirstRunPageBasic3.h 399 src/wizards/firstrun/UIWizardFirstRunPageBasic3.h \ 400 src/wizards/firstrun/UIWizardFirstRunPageExpert.h 394 401 395 402 VirtualBox_QT_MOCHDRS.darwin += \ … … 574 581 src/wizards/newvm/UIWizardNewVMPageBasic4.cpp \ 575 582 src/wizards/newvm/UIWizardNewVMPageBasic5.cpp \ 583 src/wizards/newvm/UIWizardNewVMPageExpert.cpp \ 576 584 src/wizards/newvd/UIWizardNewVD.cpp \ 577 585 src/wizards/newvd/UIWizardNewVDPageBasic1.cpp \ … … 579 587 src/wizards/newvd/UIWizardNewVDPageBasic3.cpp \ 580 588 src/wizards/newvd/UIWizardNewVDPageBasic4.cpp \ 589 src/wizards/newvd/UIWizardNewVDPageExpert.cpp \ 581 590 src/wizards/clonevm/UIWizardCloneVM.cpp \ 582 591 src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp \ 583 592 src/wizards/clonevm/UIWizardCloneVMPageBasic2.cpp \ 584 593 src/wizards/clonevm/UIWizardCloneVMPageBasic3.cpp \ 594 src/wizards/clonevm/UIWizardCloneVMPageExpert.cpp \ 585 595 src/wizards/clonevd/UIWizardCloneVD.cpp \ 586 596 src/wizards/clonevd/UIWizardCloneVDPageBasic1.cpp \ … … 589 599 src/wizards/clonevd/UIWizardCloneVDPageBasic4.cpp \ 590 600 src/wizards/clonevd/UIWizardCloneVDPageBasic5.cpp \ 601 src/wizards/clonevd/UIWizardCloneVDPageExpert.cpp \ 591 602 src/wizards/exportappliance/UIWizardExportApp.cpp \ 592 603 src/wizards/exportappliance/UIWizardExportAppPageBasic1.cpp \ … … 594 605 src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp \ 595 606 src/wizards/exportappliance/UIWizardExportAppPageBasic4.cpp \ 607 src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp \ 596 608 src/wizards/importappliance/UIWizardImportApp.cpp \ 597 609 src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp \ 598 610 src/wizards/importappliance/UIWizardImportAppPageBasic2.cpp \ 611 src/wizards/importappliance/UIWizardImportAppPageExpert.cpp \ 599 612 src/wizards/firstrun/UIWizardFirstRun.cpp \ 600 613 src/wizards/firstrun/UIWizardFirstRunPageBasic1.cpp \ 601 614 src/wizards/firstrun/UIWizardFirstRunPageBasic2.cpp \ 602 src/wizards/firstrun/UIWizardFirstRunPageBasic3.cpp 615 src/wizards/firstrun/UIWizardFirstRunPageBasic3.cpp \ 616 src/wizards/firstrun/UIWizardFirstRunPageExpert.cpp 603 617 604 618 VirtualBox_SOURCES.win += \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.cpp
r40002 r41021 43 43 const char* VBoxDefs::GUI_AutoresizeGuest = "GUI/AutoresizeGuest"; 44 44 const char* VBoxDefs::GUI_FirstRun = "GUI/FirstRun"; 45 const char* VBoxDefs::GUI_HideDescriptionForWizards = "GUI/HideDescriptionForWizards"; 45 46 const char* VBoxDefs::GUI_SaveMountedAtRuntime = "GUI/SaveMountedAtRuntime"; 46 47 const char* VBoxDefs::GUI_ShowMiniToolBar = "GUI/ShowMiniToolBar"; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h
r40002 r41021 123 123 static const char* GUI_AutoresizeGuest; 124 124 static const char* GUI_FirstRun; 125 static const char* GUI_HideDescriptionForWizards; 125 126 static const char* GUI_SaveMountedAtRuntime; 126 127 static const char* GUI_ShowMiniToolBar; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r40870 r41021 216 216 QString strTmpFile = strFileName; 217 217 #endif /* !Q_WS_MAC */ 218 UIWizardImportApp wizard( strTmpFile, this);218 UIWizardImportApp wizard(this, strTmpFile); 219 219 if (strFileName.isEmpty() || wizard.isValid()) 220 220 wizard.exec(); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxFilePathSelectorWidget.cpp
r33778 r41021 678 678 } 679 679 680 void VBoxEmptyFileSelector::setChooseButtonText(const QString &strText) 681 { 682 mSelectButton->setText(strText); 683 } 684 685 QString VBoxEmptyFileSelector::chooseButtonText() const 686 { 687 return mSelectButton->text(); 688 } 689 680 690 void VBoxEmptyFileSelector::setFileDialogTitle (const QString& aTitle) 681 691 { -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxFilePathSelectorWidget.h
r33778 r41021 161 161 bool isModified () const { return mIsModified; } 162 162 void resetModified () { mIsModified = false; } 163 164 void setChooseButtonText(const QString &aText); 165 QString chooseButtonText() const; 163 166 164 167 void setFileDialogTitle (const QString& aTitle); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizard.cpp
r40870 r41021 29 29 #include "QIRichTextLabel.h" 30 30 31 UIWizard::UIWizard(QWidget *pParent) 31 int UIWizard::exec() 32 { 33 /* Prepare wizard: */ 34 prepare(); 35 /* Call to base-class: */ 36 return QWizard::exec(); 37 } 38 39 void UIWizard::sltCurrentIdChanged(int iId) 40 { 41 /* Enable 1st button (Hide/Show Description) for 1st page only: */ 42 setOption(QWizard::HaveCustomButton1, iId == 0); 43 } 44 45 void UIWizard::sltCustomButtonClicked(int iId) 46 { 47 /* Handle 1st button: */ 48 if (iId == CustomButton1) 49 { 50 /* Cleanup: */ 51 cleanup(); 52 53 /* Compose wizard's name: */ 54 QString strWizardName = nameForType(m_type); 55 /* Load mode settings: */ 56 QStringList wizards = vboxGlobal().virtualBox().GetExtraDataStringList(VBoxDefs::GUI_HideDescriptionForWizards); 57 58 /* Switch mode: */ 59 switch (m_mode) 60 { 61 case UIWizardMode_Basic: 62 { 63 m_mode = UIWizardMode_Expert; 64 if (!wizards.contains(strWizardName)) 65 wizards << strWizardName; 66 break; 67 } 68 case UIWizardMode_Expert: 69 { 70 m_mode = UIWizardMode_Basic; 71 if (wizards.contains(strWizardName)) 72 wizards.removeAll(strWizardName); 73 break; 74 } 75 } 76 77 /* Save mode settings: */ 78 vboxGlobal().virtualBox().SetExtraDataStringList(VBoxDefs::GUI_HideDescriptionForWizards, wizards); 79 80 /* Prepare: */ 81 prepare(); 82 } 83 } 84 85 UIWizard::UIWizard(QWidget *pParent, UIWizardType type) 32 86 : QIWithRetranslateUI<QWizard>(pParent) 33 { 34 #if 0 // This is VERY important change, have to discuss first! 35 /* Qt have a bug-o-feature which silently fallbacks complex-wizard-style 36 * to more simple in case it failed to initialize that complex-wizard-style. 37 * Further wizard's look-n-feel may partially corresponds to both: 38 * complex-wizard-style and falled-back-one, we have to be sure which we are using. */ 39 setWizardStyle(wizardStyle()); 40 #endif 87 , m_type(type) 88 , m_mode(loadModeForType(m_type)) 89 { 90 #ifdef Q_WS_WIN 91 /* Hide window icon: */ 92 setWindowIcon(QIcon()); 93 #endif /* Q_WS_WIN */ 41 94 42 95 #ifdef Q_WS_MAC 43 /* I'm really not sure why there shouldn't be any default button on Mac OS 44 * X.This prevents the using of Enter to jump to the next page. */96 /* I'm really not sure why there shouldn't be any default button on Mac OS X. 97 * This prevents the using of Enter to jump to the next page. */ 45 98 setOptions(options() ^ QWizard::NoDefaultButton); 46 99 #endif /* Q_WS_MAC */ 47 } 48 49 int UIWizard::addPage(UIWizardPage *pPage) 100 101 /* Setup connections: */ 102 connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(sltCurrentIdChanged(int))); 103 connect(this, SIGNAL(customButtonClicked(int)), this, SLOT(sltCustomButtonClicked(int))); 104 } 105 106 void UIWizard::retranslateUi() 107 { 108 /* Translate basic/expert button: */ 109 switch (m_mode) 110 { 111 case UIWizardMode_Basic: setButtonText(QWizard::CustomButton1, tr("Hide Description")); break; 112 case UIWizardMode_Expert: setButtonText(QWizard::CustomButton1, tr("Show Description")); break; 113 } 114 } 115 116 void UIWizard::retranslatePages() 117 { 118 /* Translate all the pages: */ 119 QList<int> ids = pageIds(); 120 for (int i = 0; i < ids.size(); ++i) 121 qobject_cast<UIWizardPage*>(page(ids[i]))->retranslate(); 122 } 123 124 void UIWizard::setPage(int iId, UIWizardPage *pPage) 50 125 { 51 126 /* Configure page first: */ 52 127 configurePage(pPage); 53 54 /* Add page finally: */55 return QWizard::addPage(pPage);56 }57 58 void UIWizard::setPage(int iId, UIWizardPage *pPage)59 {60 /* Configure page first: */61 configurePage(pPage);62 63 128 /* Add page finally: */ 64 129 QWizard::setPage(iId, pPage); 65 130 } 66 131 67 void UIWizard::retranslateAllPages() 68 { 69 QList<UIWizardPage*> pages = findChildren<UIWizardPage*>(); 70 for(int i = 0; i < pages.size(); ++i) 71 qobject_cast<UIWizardPage*>(pages.at((i)))->retranslate(); 72 } 73 74 void UIWizard::resizeToGoldenRatio(UIWizardType wizardType) 75 { 76 /* Get corresponding ratio: */ 77 double dRatio = ratioForWizardType(wizardType); 78 79 /* Use some small (!) initial QIRichTextLabel width: */ 80 int iInitialLabelWidth = 200; 81 82 /* Resize wizard according that initial width, 83 * actually there could be other content 84 * which wants to be wider than that initial width. */ 85 resizeAccordingLabelWidth(iInitialLabelWidth); 86 87 /* Get all the pages: */ 88 QList<UIWizardPage*> pages = findChildren<UIWizardPage*>(); 89 /* Get some (first) of those pages: */ 90 UIWizardPage *pSomePage = pages[0]; 91 92 /* Calculate actual label width: */ 93 int iPageWidth = pSomePage->width(); 94 int iLeft, iTop, iRight, iBottom; 95 pSomePage->layout()->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom); 96 int iCurrentLabelWidth = iPageWidth - iLeft - iRight; 97 98 /* Calculate summary margin length, including margins of the page and wizard: */ 99 int iMarginsLength = width() - iCurrentLabelWidth; 100 101 /* Calculating nearest to 'golden ratio' label width: */ 102 int iCurrentWizardWidth = width(); 103 int iCurrentWizardHeight = height(); 132 void UIWizard::prepare() 133 { 134 /* Translate wizard: */ 135 retranslateUi(); 136 /* Translate wizard pages: */ 137 retranslatePages(); 138 139 /* Resize wizard to 'golden ratio': */ 140 resizeToGoldenRatio(); 141 142 /* Notify pages they are ready: */ 143 QList<int> ids = pageIds(); 144 for (int i = 0; i < ids.size(); ++i) 145 qobject_cast<UIWizardPage*>(page(ids[i]))->markReady(); 146 147 /* Make sure custom buttons shown even if final page is first to show: */ 148 sltCurrentIdChanged(startId()); 149 } 150 151 void UIWizard::cleanup() 152 { 153 /* Remove all the pages: */ 154 QList<int> ids = pageIds(); 155 for (int i = ids.size() - 1; i >= 0 ; --i) 156 { 157 /* Get enumerated page ID: */ 158 int iId = ids[i]; 159 /* Get corresponding page: */ 160 QWizardPage *pWizardPage = page(iId); 161 162 /* Remove page from the wizard: */ 163 removePage(iId); 164 /* Delete page finally: */ 165 delete pWizardPage; 166 } 167 104 168 #ifndef Q_WS_MAC 105 /* We should take into account watermar thought its not assigned yet: */ 106 QPixmap watermarkPixmap(m_strWatermarkName); 107 int iWatermarkWidth = watermarkPixmap.width(); 108 iCurrentWizardWidth += iWatermarkWidth; 169 /* Cleanup watermark: */ 170 if (!m_strWatermarkName.isEmpty()) 171 setPixmap(QWizard::WatermarkPixmap, QPixmap()); 109 172 #endif /* !Q_WS_MAC */ 110 int iGoldenRatioWidth = (int)qSqrt(dRatio * iCurrentWizardWidth * iCurrentWizardHeight); 111 int iProposedLabelWidth = iGoldenRatioWidth - iMarginsLength; 173 } 174 175 void UIWizard::resizeToGoldenRatio() 176 { 177 /* Check if wizard is in basic or expert mode: */ 178 if (m_mode == UIWizardMode_Expert) 179 { 180 /* Unfortunately QWizard hides some of useful API in private part, 181 * and also have few layouting bugs which could be easy fixed 182 * by that API, so we will use QWizard::restart() method 183 * to call the same functionality indirectly... 184 * Early call restart() which is usually goes on show()! */ 185 restart(); 186 187 /* Now we have correct label size-hint(s) for all the pages. 188 * We have to make sure all the pages uses maximum available size-hint. */ 189 QSize maxOfSizeHints; 190 QList<UIWizardPage*> pages = findChildren<UIWizardPage*>(); 191 /* Search for the maximum available size-hint: */ 192 foreach (UIWizardPage *pPage, pages) 193 { 194 maxOfSizeHints.rwidth() = pPage->sizeHint().width() > maxOfSizeHints.width() ? 195 pPage->sizeHint().width() : maxOfSizeHints.width(); 196 maxOfSizeHints.rheight() = pPage->sizeHint().height() > maxOfSizeHints.height() ? 197 pPage->sizeHint().height() : maxOfSizeHints.height(); 198 } 199 /* Minimum height to 350pix: */ 200 if (maxOfSizeHints.height() < 350) 201 maxOfSizeHints.setHeight(350); 202 /* Feat corresponding height: */ 203 maxOfSizeHints.setWidth(qMax((int)(1.5 * maxOfSizeHints.height()), maxOfSizeHints.width())); 204 /* Use that size-hint for all the pages: */ 205 foreach (UIWizardPage *pPage, pages) 206 pPage->setMinimumSize(maxOfSizeHints); 207 208 /* Relayout widgets: */ 209 QList<QLayout*> layouts = findChildren<QLayout*>(); 210 foreach(QLayout *pLayout, layouts) 211 pLayout->activate(); 212 213 /* Unfortunately QWizard hides some of useful API in private part, 214 * BUT it also have few layouting bugs which could be easy fixed 215 * by that API, so we will use QWizard::restart() method 216 * to call the same functionality indirectly... 217 * And now we call restart() after layout activation procedure! */ 218 restart(); 219 220 /* Resize it to minimum size: */ 221 resize(QSize(0, 0)); 222 } 223 else 224 { 225 /* Use some small (!) initial QIRichTextLabel width: */ 226 int iInitialLabelWidth = 200; 227 228 /* Resize wizard according that initial width, 229 * actually there could be other content 230 * which wants to be wider than that initial width. */ 231 resizeAccordingLabelWidth(iInitialLabelWidth); 232 233 /* Get some (first) of those pages: */ 234 UIWizardPage *pPage = qobject_cast<UIWizardPage*>(page(0)); 235 /* Calculate actual label width: */ 236 int iPageWidth = pPage->minimumWidth(); 237 int iLeft, iTop, iRight, iBottom; 238 pPage->layout()->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom); 239 int iCurrentLabelWidth = iPageWidth - iLeft - iRight; 240 /* Calculate summary margin length, 241 * including margins of the page and the wizard: */ 242 int iMarginsLength = width() - iCurrentLabelWidth; 243 244 /* Get current wizard width and height: */ 245 int iCurrentWizardWidth = width(); 246 int iCurrentWizardHeight = height(); 112 247 #ifndef Q_WS_MAC 113 /* We should take into account watermar thought its not assigned yet: */ 114 iProposedLabelWidth -= iWatermarkWidth; 248 /* We should take into account watermark like its assigned already: */ 249 QPixmap watermarkPixmap(m_strWatermarkName); 250 int iWatermarkWidth = watermarkPixmap.width(); 251 iCurrentWizardWidth += iWatermarkWidth; 115 252 #endif /* !Q_WS_MAC */ 116 117 /* Choose maximum between current and proposed label width: */ 118 int iNewLabelWidth = qMax(iCurrentLabelWidth, iProposedLabelWidth); 119 120 /* Finally resize wizard according new label width, 121 * taking into account all the content and 'golden ratio' rule: */ 122 resizeAccordingLabelWidth(iNewLabelWidth); 253 /* Calculating nearest to 'golden ratio' label width: */ 254 int iGoldenRatioWidth = (int)qSqrt(ratio() * iCurrentWizardWidth * iCurrentWizardHeight); 255 int iProposedLabelWidth = iGoldenRatioWidth - iMarginsLength; 256 #ifndef Q_WS_MAC 257 /* We should take into account watermark like its assigned already: */ 258 iProposedLabelWidth -= iWatermarkWidth; 259 #endif /* !Q_WS_MAC */ 260 261 /* Choose maximum between current and proposed label width: */ 262 int iNewLabelWidth = qMax(iCurrentLabelWidth, iProposedLabelWidth); 263 264 /* Finally resize wizard according new label width, 265 * taking into account all the content and 'golden ratio' rule: */ 266 resizeAccordingLabelWidth(iNewLabelWidth); 267 } 123 268 124 269 #ifndef Q_WS_MAC … … 221 366 } 222 367 223 double UIWizard::ratio ForWizardType(UIWizardType wizardType)368 double UIWizard::ratio() 224 369 { 225 370 /* Default value: */ … … 247 392 #endif /* Q_WS_WIN */ 248 393 249 switch ( wizardType)394 switch (m_type) 250 395 { 251 396 /* New VM wizard much wider than others, fixing: */ … … 273 418 * 1. wizard-layout top-margin (for modern style), 274 419 * 2. wizard-header height, 275 * 3. marginbetween wizard-header and wizard-page,420 * 3. spacing between wizard-header and wizard-page, 276 421 * 4. wizard-page height, 277 422 * 5. wizard-layout bottom-margin (for modern style). */ … … 282 427 /* Acquire wizard-layout top-margin: */ 283 428 int iTopMargin = 0; 284 if (wizardStyle() == QWizard::ModernStyle) 285 iTopMargin = pStyle->pixelMetric(QStyle::PM_LayoutTopMargin); 286 287 /* We have no direct access to QWizardHeader inside QWizard private data... 288 * From Qt sources it seems title font is hardcoded as current font point-size + 4: */ 289 QFont titleFont(QApplication::font()); 290 titleFont.setPointSize(titleFont.pointSize() + 4); 291 QFontMetrics titleFontMetrics(titleFont); 292 int iTitleHeight = titleFontMetrics.height(); 293 294 /* We have no direct access to margin between QWizardHeader and wizard-pages... 295 * From Qt sources it seems its hardcoded as just 7 pixels: */ 296 int iMarginBetweenTitleAndPage = 7; 297 298 /* Also we should get any page height: */ 299 QList<UIWizardPage*> pages = findChildren<UIWizardPage*>(); 300 int iPageHeight = pages[0]->height(); 429 if (m_mode == UIWizardMode_Basic) 430 { 431 if (wizardStyle() == QWizard::ModernStyle) 432 iTopMargin = pStyle->pixelMetric(QStyle::PM_LayoutTopMargin); 433 } 434 435 /* Acquire wizard-header height: */ 436 int iTitleHeight = 0; 437 if (m_mode == UIWizardMode_Basic) 438 { 439 /* We have no direct access to QWizardHeader inside QWizard private data... 440 * From Qt sources it seems title font is hardcoded as current font point-size + 4: */ 441 QFont titleFont(QApplication::font()); 442 titleFont.setPointSize(titleFont.pointSize() + 4); 443 QFontMetrics titleFontMetrics(titleFont); 444 iTitleHeight = titleFontMetrics.height(); 445 } 446 447 /* Acquire spacing between wizard-header and wizard-page: */ 448 int iMarginBetweenTitleAndPage = 0; 449 if (m_mode == UIWizardMode_Basic) 450 { 451 /* We have no direct access to margin between QWizardHeader and wizard-pages... 452 * From Qt sources it seems its hardcoded as just 7 pixels: */ 453 iMarginBetweenTitleAndPage = 7; 454 } 455 456 /* Acquire wizard-page height: */ 457 int iPageHeight = 0; 458 if (page(0)) 459 { 460 iPageHeight = page(0)->minimumSize().height(); 461 } 301 462 302 463 /* Acquire wizard-layout bottom-margin: */ … … 320 481 /* Create final image on the basis of incoming, applying the rules: */ 321 482 QImage imgWatermarkNew(imgWatermark.width(), qMax(imgWatermark.height(), proposedWatermarkHeight()), imgWatermark.format()); 322 for (int y = 0; y < imgWatermarkNew.height(); ++ y)323 { 324 for (int x = 0; x < imgWatermarkNew.width(); ++ x)483 for (int y = 0; y < imgWatermarkNew.height(); ++y) 484 { 485 for (int x = 0; x < imgWatermarkNew.width(); ++x) 325 486 { 326 487 /* Border rule 1 - draw border for ClassicStyle */ … … 351 512 #endif /* !Q_WS_MAC */ 352 513 514 /* static */ 515 QString UIWizard::nameForType(UIWizardType type) 516 { 517 QString strName; 518 switch (type) 519 { 520 case UIWizardType_NewVM: strName = "NewVM"; break; 521 case UIWizardType_CloneVM: strName = "CloneVM"; break; 522 case UIWizardType_ExportAppliance: strName = "ExportAppliance"; break; 523 case UIWizardType_ImportAppliance: strName = "ImportAppliance"; break; 524 case UIWizardType_FirstRun: strName = "FirstRun"; break; 525 case UIWizardType_NewVD: strName = "NewVD"; break; 526 case UIWizardType_CloneVD: strName = "CloneVD"; break; 527 } 528 return strName; 529 } 530 531 /* static */ 532 UIWizardMode UIWizard::loadModeForType(UIWizardType type) 533 { 534 /* Default mode is Basic: */ 535 UIWizardMode mode = UIWizardMode_Basic; 536 /* Get mode from extra-data: */ 537 QStringList wizards = vboxGlobal().virtualBox().GetExtraDataStringList(VBoxDefs::GUI_HideDescriptionForWizards); 538 if (wizards.contains(nameForType(type))) 539 mode = UIWizardMode_Expert; 540 /* Return mode: */ 541 return mode; 542 } 543 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizard.h
r40870 r41021 29 29 class UIWizardPage; 30 30 31 /* Wizard type: */ 32 enum UIWizardType 33 { 34 UIWizardType_NewVM, 35 UIWizardType_CloneVM, 36 UIWizardType_ExportAppliance, 37 UIWizardType_ImportAppliance, 38 UIWizardType_FirstRun, 39 UIWizardType_NewVD, 40 UIWizardType_CloneVD 41 }; 42 43 /* Wizard mode: */ 44 enum UIWizardMode 45 { 46 UIWizardMode_Basic, 47 UIWizardMode_Expert 48 }; 49 31 50 /* QWizard class reimplementation with extended funtionality. */ 32 51 class UIWizard : public QIWithRetranslateUI<QWizard> … … 34 53 Q_OBJECT; 35 54 36 public :55 public slots: 37 56 38 /* Constructor: */ 39 UIWizard(QWidget *pParent); 57 /* Exec slot: */ 58 int exec(); 59 60 protected slots: 61 62 /* Page change handler: */ 63 virtual void sltCurrentIdChanged(int iId); 64 /* Custom button 1 click handler: */ 65 virtual void sltCustomButtonClicked(int iId); 40 66 41 67 protected: 42 68 43 /* Wizard type: */ 44 enum UIWizardType 45 { 46 UIWizardType_NewVM, 47 UIWizardType_CloneVM, 48 UIWizardType_ExportAppliance, 49 UIWizardType_ImportAppliance, 50 UIWizardType_FirstRun, 51 UIWizardType_NewVD, 52 UIWizardType_CloneVD 53 }; 69 /* Constructor: */ 70 UIWizard(QWidget *pParent, UIWizardType type); 71 72 /* Translation stuff: */ 73 void retranslateUi(); 74 void retranslatePages(); 75 76 /* Mode related stuff: */ 77 UIWizardMode mode() { return m_mode; } 54 78 55 79 /* Page related methods: */ 56 int addPage(UIWizardPage *pPage);57 80 void setPage(int iId, UIWizardPage *pPage); 58 59 /* Translation stuff: */ 60 void retranslateAllPages(); 81 virtual void prepare(); 82 void cleanup(); 61 83 62 84 /* Adjusting stuff: */ 63 void resizeToGoldenRatio( UIWizardType wizardType);85 void resizeToGoldenRatio(); 64 86 65 87 /* Design stuff: */ … … 78 100 void configurePage(UIWizardPage *pPage); 79 101 void resizeAccordingLabelWidth(int iLabelWidth); 80 double ratio ForWizardType(UIWizardType wizardType);102 double ratio(); 81 103 #ifndef Q_WS_MAC 82 104 int proposedWatermarkHeight(); 83 105 void assignWatermarkHelper(); 106 #endif /* !Q_WS_MAC */ 107 static QString nameForType(UIWizardType type); 108 static UIWizardMode loadModeForType(UIWizardType type); 109 110 /* Variables: */ 111 UIWizardType m_type; 112 UIWizardMode m_mode; 113 #ifndef Q_WS_MAC 84 114 QString m_strWatermarkName; 85 115 #endif /* !Q_WS_MAC */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizardPage.cpp
r40870 r41021 26 26 #include "VBoxGlobal.h" 27 27 28 UIWizard* UIWizardPageBase::wizardImp() 29 { 30 /* Should be reimplemented in sub-class to enable access to wizard! */ 31 AssertMsgFailed(("UIWizardPageBase::wizardImp() should be reimplemented!")); 32 return 0; 33 } 34 35 UIWizardPage* UIWizardPageBase::thisImp() 36 { 37 /* Should be reimplemented in sub-class to enable access to wizard page! */ 38 AssertMsgFailed(("UIWizardPageBase::thisImp() should be reimplemented!")); 39 return 0; 40 } 41 42 QVariant UIWizardPageBase::fieldImp(const QString &) const 43 { 44 /* Should be reimplemented in sub-class to enable access to wizard field! */ 45 AssertMsgFailed(("UIWizardPageBase::fieldImp(const QString &) should be reimplemented!")); 46 return QVariant(); 47 } 48 28 49 UIWizardPage::UIWizardPage() 50 : m_fReady(false) 29 51 { 52 } 53 54 void UIWizardPage::markReady() 55 { 56 m_fReady = true; 57 QWizardPage::setTitle(m_strTitle); 58 } 59 60 void UIWizardPage::setTitle(const QString &strTitle) 61 { 62 m_strTitle = strTitle; 63 if (m_fReady) 64 QWizardPage::setTitle(m_strTitle); 30 65 } 31 66 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizardPage.h
r40870 r41021 21 21 22 22 /* Global includes: */ 23 #include <QVariant> 23 24 #include <QWizardPage> 24 25 … … 28 29 /* Forward declarations: */ 29 30 class UIWizard; 31 class UIWizardPage; 30 32 31 /* QWizardPage class reimplementation with extended funtionality. */ 33 /* One of interfaces for wizard page, 34 * providing API for basic/expert pages. */ 35 class UIWizardPageBase 36 { 37 protected: 38 39 /* Helpers: */ 40 virtual UIWizard* wizardImp(); 41 virtual UIWizardPage* thisImp(); 42 virtual QVariant fieldImp(const QString &strFieldName) const; 43 }; 44 45 /* One of interfaces for wizard page, 46 * QWizardPage class reimplementation with extended funtionality. */ 32 47 class UIWizardPage : public QIWithRetranslateUI<QWizardPage> 33 48 { … … 42 57 void retranslate() { retranslateUi(); } 43 58 59 /* Prepare stuff: */ 60 void markReady(); 61 62 /* Title stuff: */ 63 void setTitle(const QString &strTitle); 64 44 65 protected: 45 66 … … 49 70 void startProcessing(); 50 71 void endProcessing(); 72 73 /* Variables: */ 74 bool m_fReady; 75 QString m_strTitle; 51 76 }; 52 77 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVD.cpp
r40870 r41021 28 28 #include "UIWizardCloneVDPageBasic4.h" 29 29 #include "UIWizardCloneVDPageBasic5.h" 30 #include "UIWizardCloneVDPageExpert.h" 30 31 #include "VBoxGlobal.h" 31 32 #include "UIMessageCenter.h" 32 33 33 34 UIWizardCloneVD::UIWizardCloneVD(QWidget *pParent, const CMedium &sourceVirtualDisk) 34 : UIWizard(pParent) 35 : UIWizard(pParent, UIWizardType_CloneVD) 36 , m_sourceVirtualDisk(sourceVirtualDisk) 35 37 { 36 #ifdef Q_WS_WIN37 /* Hide window icon: */38 setWindowIcon(QIcon());39 #endif /* Q_WS_WIN */40 41 /* Create & add pages: */42 setPage(Page1, new UIWizardCloneVDPageBasic1(sourceVirtualDisk));43 setPage(Page2, new UIWizardCloneVDPageBasic2);44 setPage(Page3, new UIWizardCloneVDPageBasic3);45 setPage(Page4, new UIWizardCloneVDPageBasic4);46 setPage(Page5, new UIWizardCloneVDPageBasic5);47 48 /* Translate wizard: */49 retranslateUi();50 51 /* Translate wizard pages: */52 retranslateAllPages();53 54 38 #ifndef Q_WS_MAC 55 39 /* Assign watermark: */ … … 59 43 assignBackground(":/vmw_new_harddisk_bg.png"); 60 44 #endif /* Q_WS_MAC */ 61 62 /* Resize wizard to 'golden ratio': */63 resizeToGoldenRatio(UIWizardType_CloneVD);64 45 } 65 46 … … 135 116 void UIWizardCloneVD::retranslateUi() 136 117 { 118 /* Call to base-class: */ 119 UIWizard::retranslateUi(); 120 137 121 /* Translate wizard: */ 138 122 setWindowTitle(tr("Copy Virtual Disk")); … … 140 124 } 141 125 126 void UIWizardCloneVD::prepare() 127 { 128 /* Create corresponding pages: */ 129 switch (mode()) 130 { 131 case UIWizardMode_Basic: 132 { 133 setPage(Page1, new UIWizardCloneVDPageBasic1(m_sourceVirtualDisk)); 134 setPage(Page2, new UIWizardCloneVDPageBasic2); 135 setPage(Page3, new UIWizardCloneVDPageBasic3); 136 setPage(Page4, new UIWizardCloneVDPageBasic4); 137 setPage(Page5, new UIWizardCloneVDPageBasic5); 138 break; 139 } 140 case UIWizardMode_Expert: 141 { 142 setPage(PageExpert, new UIWizardCloneVDPageExpert(m_sourceVirtualDisk)); 143 break; 144 } 145 } 146 /* Call to base-class: */ 147 UIWizard::prepare(); 148 } 149 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVD.h
r40870 r41021 41 41 }; 42 42 43 /* Page IDs: */ 44 enum 45 { 46 PageExpert 47 }; 48 43 49 /* Constructor: */ 44 50 UIWizardCloneVD(QWidget *pParent, const CMedium &sourceVirtualDisk); … … 57 63 /* Who will be able to copy virtual-disk: */ 58 64 friend class UIWizardCloneVDPageBasic5; 65 friend class UIWizardCloneVDPageExpert; 59 66 60 67 private: … … 63 70 void retranslateUi(); 64 71 72 /* Pages related stuff: */ 73 void prepare(); 74 65 75 /* Variables: */ 76 CMedium m_sourceVirtualDisk; 66 77 CMedium m_virtualDisk; 67 78 }; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic1.cpp
r40870 r41021 31 31 #include "QIToolButton.h" 32 32 33 UIWizardCloneVDPage Basic1::UIWizardCloneVDPageBasic1(const CMedium &sourceVirtualDisk)33 UIWizardCloneVDPage1::UIWizardCloneVDPage1() 34 34 { 35 /* Create widgets: */36 QVBoxLayout *pMainLayout = new QVBoxLayout(this);37 m_pLabel = new QIRichTextLabel(this);38 m_pSourceDiskContainer = new QGroupBox(this);39 m_pSourceDiskContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);40 QHBoxLayout *pSourceDiskLayout = new QHBoxLayout(m_pSourceDiskContainer);41 m_pSourceDiskSelector = new VBoxMediaComboBox(m_pSourceDiskContainer);42 m_pSourceDiskSelector->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);43 m_pSourceDiskSelector->setType(VBoxDefs::MediumType_HardDisk);44 m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());45 m_pSourceDiskSelector->repopulate();46 m_pOpenSourceDiskButton = new QIToolButton(m_pSourceDiskContainer);47 m_pOpenSourceDiskButton->setAutoRaise(true);48 m_pOpenSourceDiskButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png"));49 pSourceDiskLayout->addWidget(m_pSourceDiskSelector);50 pSourceDiskLayout->addWidget(m_pOpenSourceDiskButton);51 pMainLayout->addWidget(m_pLabel);52 pMainLayout->addWidget(m_pSourceDiskContainer);53 pMainLayout->addStretch();54 55 /* Setup connections: */56 connect(m_pSourceDiskSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged()));57 connect(m_pOpenSourceDiskButton, SIGNAL(clicked()), this, SLOT(sltHandleOpenSourceDiskClick()));58 59 /* Register CMedium class: */60 qRegisterMetaType<CMedium>();61 /* Register 'sourceVirtualDisk' field: */62 registerField("sourceVirtualDisk", this, "sourceVirtualDisk");63 35 } 64 36 65 void UIWizardCloneVDPage Basic1::sltHandleOpenSourceDiskClick()37 void UIWizardCloneVDPage1::onHandleOpenSourceDiskClick() 66 38 { 67 39 /* Get source virtual-disk using file-open dialog: */ 68 QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(VBoxDefs::MediumType_HardDisk, this );40 QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(VBoxDefs::MediumType_HardDisk, thisImp()); 69 41 if (!strMediumId.isNull()) 70 42 { … … 76 48 } 77 49 50 CMedium UIWizardCloneVDPage1::sourceVirtualDisk() const 51 { 52 return vboxGlobal().findMedium(m_pSourceDiskSelector->id()).medium(); 53 } 54 55 void UIWizardCloneVDPage1::setSourceVirtualDisk(const CMedium &sourceVirtualDisk) 56 { 57 m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId()); 58 } 59 60 UIWizardCloneVDPageBasic1::UIWizardCloneVDPageBasic1(const CMedium &sourceVirtualDisk) 61 { 62 /* Create widgets: */ 63 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 64 { 65 m_pLabel = new QIRichTextLabel(this); 66 m_pSourceDiskCnt = new QGroupBox(this); 67 { 68 m_pSourceDiskCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 69 QHBoxLayout *pSourceDiskCntLayout = new QHBoxLayout(m_pSourceDiskCnt); 70 { 71 m_pSourceDiskSelector = new VBoxMediaComboBox(m_pSourceDiskCnt); 72 { 73 m_pSourceDiskSelector->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); 74 m_pSourceDiskSelector->setType(VBoxDefs::MediumType_HardDisk); 75 m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId()); 76 m_pSourceDiskSelector->repopulate(); 77 } 78 m_pSourceDiskOpenButton = new QIToolButton(m_pSourceDiskCnt); 79 { 80 m_pSourceDiskOpenButton->setAutoRaise(true); 81 m_pSourceDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png")); 82 } 83 pSourceDiskCntLayout->addWidget(m_pSourceDiskSelector); 84 pSourceDiskCntLayout->addWidget(m_pSourceDiskOpenButton); 85 } 86 } 87 pMainLayout->addWidget(m_pLabel); 88 pMainLayout->addWidget(m_pSourceDiskCnt); 89 pMainLayout->addStretch(); 90 } 91 92 /* Setup connections: */ 93 connect(m_pSourceDiskSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged())); 94 connect(m_pSourceDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltHandleOpenSourceDiskClick())); 95 96 /* Register classes: */ 97 qRegisterMetaType<CMedium>(); 98 /* Register fields: */ 99 registerField("sourceVirtualDisk", this, "sourceVirtualDisk"); 100 } 101 102 void UIWizardCloneVDPageBasic1::sltHandleOpenSourceDiskClick() 103 { 104 /* Call to base-class: */ 105 onHandleOpenSourceDiskClick(); 106 } 107 78 108 void UIWizardCloneVDPageBasic1::retranslateUi() 79 109 { 80 110 /* Translate page: */ 81 setTitle(UIWizardCloneVD::tr("Welcome to the virtual disk copying wizard"));111 setTitle(UIWizardCloneVD::tr("Welcome to the Copy Virtual Disk wizard!")); 82 112 83 113 /* Translate widgets: */ 84 m_pSourceDiskContainer->setTitle(UIWizardCloneVD::tr("Virtual disk to copy"));85 m_pOpenSourceDiskButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file..."));86 114 m_pLabel->setText(UIWizardCloneVD::tr("<p>This wizard will help you to copy a virtual disk.</p>")); 87 115 m_pLabel->setText(m_pLabel->text() + QString("<p>%1</p>").arg(standardHelpText())); … … 90 118 "choose one from the list or use the folder icon " 91 119 "beside the list to select a virtual disk file.")); 120 m_pSourceDiskCnt->setTitle(UIWizardCloneVD::tr("Virtual disk to copy")); 121 m_pSourceDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file...")); 92 122 } 93 123 … … 100 130 bool UIWizardCloneVDPageBasic1::isComplete() const 101 131 { 102 /* Check whatsource virtual-disk feats the rules: */132 /* Make sure source virtual-disk feats the rules: */ 103 133 return !sourceVirtualDisk().isNull(); 104 134 } 105 135 106 CMedium UIWizardCloneVDPageBasic1::sourceVirtualDisk() const107 {108 return vboxGlobal().findMedium(m_pSourceDiskSelector->id()).medium();109 }110 111 void UIWizardCloneVDPageBasic1::setSourceVirtualDisk(const CMedium &sourceVirtualDisk)112 {113 m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());114 }115 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic1.h
r40870 r41021 25 25 26 26 /* Forward declarations: */ 27 class QIRichTextLabel;28 27 class QGroupBox; 29 28 class VBoxMediaComboBox; 30 29 class QIToolButton; 30 class QIRichTextLabel; 31 31 32 /* 1st page of the Clone Virtual Disk wizard: */ 33 class UIWizardCloneVDPageBasic1 : public UIWizardPage 32 /* 1st page of the Clone Virtual Disk wizard (base part): */ 33 class UIWizardCloneVDPage1 : public UIWizardPageBase 34 { 35 protected: 36 37 /* Constructor: */ 38 UIWizardCloneVDPage1(); 39 40 /* Handlers: */ 41 void onHandleOpenSourceDiskClick(); 42 43 /* Stuff for 'sourceVirtualDisk' field: */ 44 CMedium sourceVirtualDisk() const; 45 void setSourceVirtualDisk(const CMedium &sourceVirtualDisk); 46 47 /* Widgets: */ 48 QGroupBox *m_pSourceDiskCnt; 49 VBoxMediaComboBox *m_pSourceDiskSelector; 50 QIToolButton *m_pSourceDiskOpenButton; 51 }; 52 53 /* 1st page of the Clone Virtual Disk wizard (basic extension): */ 54 class UIWizardCloneVDPageBasic1 : public UIWizardPage, public UIWizardCloneVDPage1 34 55 { 35 56 Q_OBJECT; … … 40 61 /* Constructor: */ 41 62 UIWizardCloneVDPageBasic1(const CMedium &sourceVirtualDisk); 63 64 protected: 65 66 /* Wrapper to access 'this' from base part: */ 67 UIWizardPage* thisImp() { return this; } 42 68 43 69 private slots: … … 57 83 bool isComplete() const; 58 84 59 /* Stuff for 'sourceVirtualDisk' field: */60 CMedium sourceVirtualDisk() const;61 void setSourceVirtualDisk(const CMedium &sourceVirtualDisk);62 63 85 /* Widgets: */ 64 86 QIRichTextLabel *m_pLabel; 65 QGroupBox *m_pSourceDiskContainer;66 VBoxMediaComboBox *m_pSourceDiskSelector;67 QIToolButton *m_pOpenSourceDiskButton;68 87 }; 69 88 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic2.cpp
r40870 r41021 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QButtonGroup> 23 #include <QGroupBox> 22 24 #include <QRadioButton> 23 #include <QGroupBox>24 #include <QButtonGroup>25 25 26 26 /* Local includes: */ … … 30 30 #include "QIRichTextLabel.h" 31 31 32 UIWizardCloneVDPageBasic2::UIWizardCloneVDPageBasic2() 33 : m_pDefaultButton(0) 32 UIWizardCloneVDPage2::UIWizardCloneVDPage2() 34 33 { 35 /* Create widgets: */36 QVBoxLayout *pMainLayout = new QVBoxLayout(this);37 m_pLabel = new QIRichTextLabel(this);38 m_pFormatContainer = new QGroupBox(this);39 m_pFormatContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);40 QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatContainer);41 pMainLayout->addWidget(m_pLabel);42 pMainLayout->addWidget(m_pFormatContainer);43 pMainLayout->addStretch();44 45 /* Greate button group: */46 m_pButtonGroup = new QButtonGroup(this);47 48 /* Enumerate supportable formats: */49 CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();50 const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();51 /* Search for default (VDI) format first: */52 for (int i = 0; i < medFormats.size(); ++i)53 {54 /* Get iterated medium format: */55 const CMediumFormat &medFormat = medFormats[i];56 QString strFormatName(medFormat.GetName());57 if (strFormatName == "VDI")58 {59 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);60 if (pButton)61 {62 m_formats << medFormat;63 m_formatNames << strFormatName;64 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1);65 m_pDefaultButton = pButton;66 }67 }68 }69 /* Look for other formats: */70 for (int i = 0; i < medFormats.size(); ++i)71 {72 /* Get iterated medium format: */73 const CMediumFormat &medFormat = medFormats[i];74 QString strFormatName(medFormat.GetName());75 if (strFormatName != "VDI")76 {77 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);78 if (pButton)79 {80 m_formats << medFormat;81 m_formatNames << strFormatName;82 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1);83 }84 }85 }86 /* Check/focus default button: */87 m_pDefaultButton->setChecked(true);88 m_pDefaultButton->setFocus();89 90 /* Setup connections: */91 connect(m_pButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(completeChanged()));92 93 /* Register CMediumFormat class: */94 qRegisterMetaType<CMediumFormat>();95 /* Register 'mediumFormat' field: */96 registerField("mediumFormat", this, "mediumFormat");97 34 } 98 35 99 void UIWizardCloneVDPageBasic2::retranslateUi() 100 { 101 /* Translate page: */ 102 setTitle(UIWizardCloneVD::tr("Virtual disk file type")); 103 104 /* Translate widgets: */ 105 m_pLabel->setText(UIWizardCloneVD::tr("Please choose the type of file that you would like " 106 "to use for the new virtual disk. If you do not need " 107 "to use it with other virtualization software you can " 108 "leave this setting unchanged.")); 109 m_pFormatContainer->setTitle(UIWizardCloneVD::tr("File type")); 110 111 /* Translate 'format' buttons: */ 112 QList<QAbstractButton*> buttons = m_pButtonGroup->buttons(); 113 for (int i = 0; i < buttons.size(); ++i) 114 { 115 QAbstractButton *pButton = buttons[i]; 116 pButton->setText(UIWizardCloneVD::fullFormatName(m_formatNames[m_pButtonGroup->id(pButton)])); 117 } 118 } 119 120 void UIWizardCloneVDPageBasic2::initializePage() 121 { 122 /* Translate page: */ 123 retranslateUi(); 124 } 125 126 bool UIWizardCloneVDPageBasic2::isComplete() const 127 { 128 return !mediumFormat().isNull(); 129 } 130 131 int UIWizardCloneVDPageBasic2::nextId() const 132 { 133 CMediumFormat medFormat = mediumFormat(); 134 ULONG uCapabilities = medFormat.GetCapabilities(); 135 int cTest = 0; 136 if (uCapabilities & KMediumFormatCapabilities_CreateDynamic) 137 ++cTest; 138 if (uCapabilities & KMediumFormatCapabilities_CreateFixed) 139 ++cTest; 140 if (uCapabilities & KMediumFormatCapabilities_CreateSplit2G) 141 ++cTest; 142 if (cTest > 1) 143 return UIWizardCloneVD::Page3; 144 return UIWizardCloneVD::Page4; 145 } 146 147 QRadioButton* UIWizardCloneVDPageBasic2::addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat medFormat) 36 QRadioButton* UIWizardCloneVDPage2::addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat medFormat) 148 37 { 149 38 /* Check that medium format supports creation: */ … … 161 50 162 51 /* Create/add corresponding radio-button: */ 163 QRadioButton *pFormatButton = new QRadioButton(m_pFormatC ontainer);52 QRadioButton *pFormatButton = new QRadioButton(m_pFormatCnt); 164 53 pFormatsLayout->addWidget(pFormatButton); 165 54 return pFormatButton; 166 55 } 167 56 168 CMediumFormat UIWizardCloneVDPage Basic2::mediumFormat() const57 CMediumFormat UIWizardCloneVDPage2::mediumFormat() const 169 58 { 170 return m_p ButtonGroup->checkedButton() ? m_formats[m_pButtonGroup->checkedId()] : CMediumFormat();59 return m_pFormatButtonGroup->checkedButton() ? m_formats[m_pFormatButtonGroup->checkedId()] : CMediumFormat(); 171 60 } 172 61 173 void UIWizardCloneVDPage Basic2::setMediumFormat(const CMediumFormat &mediumFormat)62 void UIWizardCloneVDPage2::setMediumFormat(const CMediumFormat &mediumFormat) 174 63 { 175 64 int iPosition = m_formats.indexOf(mediumFormat); 176 65 if (iPosition >= 0) 177 66 { 178 m_p ButtonGroup->button(iPosition)->click();179 m_p ButtonGroup->button(iPosition)->setFocus();67 m_pFormatButtonGroup->button(iPosition)->click(); 68 m_pFormatButtonGroup->button(iPosition)->setFocus(); 180 69 } 181 70 } 182 71 72 UIWizardCloneVDPageBasic2::UIWizardCloneVDPageBasic2() 73 { 74 /* Create widgets: */ 75 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 76 { 77 m_pLabel = new QIRichTextLabel(this); 78 m_pFormatCnt = new QGroupBox(this); 79 { 80 m_pFormatCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 81 QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatCnt); 82 { 83 m_pFormatButtonGroup = new QButtonGroup(this); 84 { 85 CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties(); 86 const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats(); 87 for (int i = 0; i < medFormats.size(); ++i) 88 { 89 const CMediumFormat &medFormat = medFormats[i]; 90 QString strFormatName(medFormat.GetName()); 91 if (strFormatName == "VDI") 92 { 93 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat); 94 if (pButton) 95 { 96 m_formats << medFormat; 97 m_formatNames << strFormatName; 98 m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1); 99 } 100 } 101 } 102 for (int i = 0; i < medFormats.size(); ++i) 103 { 104 const CMediumFormat &medFormat = medFormats[i]; 105 QString strFormatName(medFormat.GetName()); 106 if (strFormatName != "VDI") 107 { 108 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat); 109 if (pButton) 110 { 111 m_formats << medFormat; 112 m_formatNames << strFormatName; 113 m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1); 114 } 115 } 116 } 117 m_pFormatButtonGroup->button(0)->click(); 118 m_pFormatButtonGroup->button(0)->setFocus(); 119 } 120 } 121 } 122 pMainLayout->addWidget(m_pLabel); 123 pMainLayout->addWidget(m_pFormatCnt); 124 pMainLayout->addStretch(); 125 } 126 127 /* Setup connections: */ 128 connect(m_pFormatButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged())); 129 130 /* Register classes: */ 131 qRegisterMetaType<CMediumFormat>(); 132 /* Register fields: */ 133 registerField("mediumFormat", this, "mediumFormat"); 134 } 135 136 void UIWizardCloneVDPageBasic2::retranslateUi() 137 { 138 /* Translate page: */ 139 setTitle(UIWizardCloneVD::tr("Virtual disk file type")); 140 141 /* Translate widgets: */ 142 m_pLabel->setText(UIWizardCloneVD::tr("Please choose the type of file that you would like " 143 "to use for the new virtual disk. If you do not need " 144 "to use it with other virtualization software you can " 145 "leave this setting unchanged.")); 146 m_pFormatCnt->setTitle(UIWizardCloneVD::tr("File type")); 147 QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons(); 148 for (int i = 0; i < buttons.size(); ++i) 149 { 150 QAbstractButton *pButton = buttons[i]; 151 pButton->setText(UIWizardCloneVD::fullFormatName(m_formatNames[m_pFormatButtonGroup->id(pButton)])); 152 } 153 } 154 155 void UIWizardCloneVDPageBasic2::initializePage() 156 { 157 /* Translate page: */ 158 retranslateUi(); 159 } 160 161 bool UIWizardCloneVDPageBasic2::isComplete() const 162 { 163 /* Make sure medium format is correct: */ 164 return !mediumFormat().isNull(); 165 } 166 167 int UIWizardCloneVDPageBasic2::nextId() const 168 { 169 /* Show variant page only if there is something to show: */ 170 CMediumFormat medFormat = mediumFormat(); 171 ULONG uCapabilities = medFormat.GetCapabilities(); 172 int cTest = 0; 173 if (uCapabilities & KMediumFormatCapabilities_CreateDynamic) 174 ++cTest; 175 if (uCapabilities & KMediumFormatCapabilities_CreateFixed) 176 ++cTest; 177 if (uCapabilities & KMediumFormatCapabilities_CreateSplit2G) 178 ++cTest; 179 if (cTest > 1) 180 return UIWizardCloneVD::Page3; 181 /* Skip otherwise: */ 182 return UIWizardCloneVD::Page4; 183 } 184 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic2.h
r40870 r41021 26 26 /* Forward declarations: */ 27 27 class QVBoxLayout; 28 class QGroupBox; 29 class QButtonGroup; 28 30 class QRadioButton; 29 31 class QIRichTextLabel; 30 class QGroupBox;31 class QButtonGroup;32 32 33 /* 2nd page of the Clone Virtual Disk wizard: */ 34 class UIWizardCloneVDPageBasic2 : public UIWizardPage 33 /* 2nd page of the Clone Virtual Disk wizard (base part): */ 34 class UIWizardCloneVDPage2 : public UIWizardPageBase 35 { 36 protected: 37 38 /* Constructor: */ 39 UIWizardCloneVDPage2(); 40 41 /* Helping stuff: */ 42 QRadioButton* addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mediumFormat); 43 44 /* Stuff for 'mediumFormat' field: */ 45 CMediumFormat mediumFormat() const; 46 void setMediumFormat(const CMediumFormat &mediumFormat); 47 48 /* Variables: */ 49 QButtonGroup *m_pFormatButtonGroup; 50 QList<CMediumFormat> m_formats; 51 QStringList m_formatNames; 52 53 /* Widgets: */ 54 QGroupBox *m_pFormatCnt; 55 }; 56 57 /* 2nd page of the Clone Virtual Disk wizard (basic extension): */ 58 class UIWizardCloneVDPageBasic2 : public UIWizardPage, public UIWizardCloneVDPage2 35 59 { 36 60 Q_OBJECT; … … 56 80 int nextId() const; 57 81 58 /* Helping stuff: */59 QRadioButton* addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mediumFormat);60 61 /* Stuff for 'mediumFormat' field: */62 CMediumFormat mediumFormat() const;63 void setMediumFormat(const CMediumFormat &mediumFormat);64 65 /* Variables: */66 QRadioButton *m_pDefaultButton;67 QButtonGroup *m_pButtonGroup;68 QList<CMediumFormat> m_formats;69 QStringList m_formatNames;70 71 82 /* Widgets: */ 72 83 QIRichTextLabel *m_pLabel; 73 QGroupBox *m_pFormatContainer;74 84 }; 75 85 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic3.cpp
r40870 r41021 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QGroupBox> 23 #include <QButtonGroup> 22 24 #include <QRadioButton> 23 25 #include <QCheckBox> 24 #include <QGroupBox>25 26 26 27 /* Local includes: */ … … 30 31 #include "QIRichTextLabel.h" 31 32 33 UIWizardCloneVDPage3::UIWizardCloneVDPage3() 34 { 35 } 36 37 qulonglong UIWizardCloneVDPage3::mediumVariant() const 38 { 39 /* Initial value: */ 40 qulonglong uMediumVariant = (qulonglong)KMediumVariant_Max; 41 42 /* Exclusive options: */ 43 if (m_pDynamicalButton->isChecked()) 44 uMediumVariant = (qulonglong)KMediumVariant_Standard; 45 else if (m_pFixedButton->isChecked()) 46 uMediumVariant = (qulonglong)KMediumVariant_Fixed; 47 48 /* Additional options: */ 49 if (m_pSplitBox->isChecked()) 50 uMediumVariant |= (qulonglong)KMediumVariant_VmdkSplit2G; 51 52 /* Return options: */ 53 return uMediumVariant; 54 } 55 56 void UIWizardCloneVDPage3::setMediumVariant(qulonglong uMediumVariant) 57 { 58 /* Exclusive options: */ 59 if (uMediumVariant & (qulonglong)KMediumVariant_Fixed) 60 { 61 m_pFixedButton->click(); 62 m_pFixedButton->setFocus(); 63 } 64 else 65 { 66 m_pDynamicalButton->click(); 67 m_pDynamicalButton->setFocus(); 68 } 69 70 /* Additional options: */ 71 m_pSplitBox->setChecked(uMediumVariant & (qulonglong)KMediumVariant_VmdkSplit2G); 72 } 73 32 74 UIWizardCloneVDPageBasic3::UIWizardCloneVDPageBasic3() 33 : m_pDynamicalButton(0), m_pFixedButton(0), m_pSplitBox(0)34 75 { 35 76 /* Create widgets: */ 36 77 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 78 { 37 79 m_pDescriptionLabel = new QIRichTextLabel(this); 38 80 m_pDynamicLabel = new QIRichTextLabel(this); 39 81 m_pFixedLabel = new QIRichTextLabel(this); 40 82 m_pSplitLabel = new QIRichTextLabel(this); 41 m_pVariantContainer = new QGroupBox(this); 42 m_pVariantContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 43 QVBoxLayout *pVariantsLayout = new QVBoxLayout(m_pVariantContainer); 44 m_pDynamicalButton = new QRadioButton(m_pVariantContainer); 45 m_pDynamicalButton->click(); 46 m_pDynamicalButton->setFocus(); 47 m_pFixedButton = new QRadioButton(m_pVariantContainer); 48 m_pSplitBox = new QCheckBox(m_pVariantContainer); 49 pVariantsLayout->addWidget(m_pDynamicalButton); 50 pVariantsLayout->addWidget(m_pFixedButton); 51 pVariantsLayout->addWidget(m_pSplitBox); 52 pMainLayout->addWidget(m_pDescriptionLabel); 53 pMainLayout->addWidget(m_pDynamicLabel); 54 pMainLayout->addWidget(m_pFixedLabel); 55 pMainLayout->addWidget(m_pSplitLabel); 56 pMainLayout->addWidget(m_pVariantContainer); 57 pMainLayout->addStretch(); 83 m_pVariantCnt = new QGroupBox(this); 84 { 85 m_pVariantCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 86 QVBoxLayout *pVariantCntLayout = new QVBoxLayout(m_pVariantCnt); 87 { 88 m_pVariantButtonGroup = new QButtonGroup(m_pVariantCnt); 89 { 90 m_pDynamicalButton = new QRadioButton(m_pVariantCnt); 91 { 92 m_pDynamicalButton->click(); 93 m_pDynamicalButton->setFocus(); 94 } 95 m_pFixedButton = new QRadioButton(m_pVariantCnt); 96 m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0); 97 m_pVariantButtonGroup->addButton(m_pFixedButton, 1); 98 } 99 m_pSplitBox = new QCheckBox(m_pVariantCnt); 100 pVariantCntLayout->addWidget(m_pDynamicalButton); 101 pVariantCntLayout->addWidget(m_pFixedButton); 102 pVariantCntLayout->addWidget(m_pSplitBox); 103 } 104 } 105 pMainLayout->addWidget(m_pDescriptionLabel); 106 pMainLayout->addWidget(m_pDynamicLabel); 107 pMainLayout->addWidget(m_pFixedLabel); 108 pMainLayout->addWidget(m_pSplitLabel); 109 pMainLayout->addWidget(m_pVariantCnt); 110 pMainLayout->addStretch(); 111 } 58 112 59 113 /* Setup connections: */ 60 connect(m_pDynamicalButton, SIGNAL(clicked(bool)), this, SIGNAL(completeChanged())); 61 connect(m_pFixedButton, SIGNAL(clicked(bool)), this, SIGNAL(completeChanged())); 114 connect(m_pVariantButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged())); 62 115 connect(m_pSplitBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged())); 63 116 64 /* Register 'mediumVariant' field: */117 /* Register fields: */ 65 118 registerField("mediumVariant", this, "mediumVariant"); 66 119 } … … 83 136 "virtual machine on removable USB devices or old systems, some of which cannot " 84 137 "handle very large files.")); 85 m_pVariantContainer->setTitle(UIWizardCloneVD::tr("Storage details"));86 138 87 /* Translate buttons: */139 m_pVariantCnt->setTitle(UIWizardCloneVD::tr("Storage details")); 88 140 m_pDynamicalButton->setText(UIWizardCloneVD::tr("&Dynamically allocated")); 89 141 m_pFixedButton->setText(UIWizardCloneVD::tr("&Fixed size")); … … 112 164 bool UIWizardCloneVDPageBasic3::isComplete() const 113 165 { 166 /* Make sure medium variant is correct: */ 114 167 return mediumVariant() != (qulonglong)KMediumVariant_Max; 115 168 } 116 169 117 qulonglong UIWizardCloneVDPageBasic3::mediumVariant() const118 {119 /* Initial value: */120 qulonglong uMediumVariant = (qulonglong)KMediumVariant_Max;121 122 /* Exclusive options: */123 if (m_pDynamicalButton->isChecked())124 uMediumVariant = (qulonglong)KMediumVariant_Standard;125 else if (m_pFixedButton->isChecked())126 uMediumVariant = (qulonglong)KMediumVariant_Fixed;127 128 /* Additional options: */129 if (m_pSplitBox->isChecked())130 uMediumVariant |= (qulonglong)KMediumVariant_VmdkSplit2G;131 132 /* Return options: */133 return uMediumVariant;134 }135 136 void UIWizardCloneVDPageBasic3::setMediumVariant(qulonglong uMediumVariant)137 {138 /* Exclusive options: */139 if (uMediumVariant & (qulonglong)KMediumVariant_Fixed)140 {141 m_pFixedButton->click();142 m_pFixedButton->setFocus();143 }144 else145 {146 m_pDynamicalButton->click();147 m_pDynamicalButton->setFocus();148 }149 150 /* Additional options: */151 m_pSplitBox->setChecked(uMediumVariant & (qulonglong)KMediumVariant_VmdkSplit2G);152 }153 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic3.h
r40870 r41021 24 24 25 25 /* Forward declarations: */ 26 class QGroupBox; 27 class QButtonGroup; 26 28 class QRadioButton; 27 29 class QCheckBox; 28 30 class QIRichTextLabel; 29 class QGroupBox;30 31 31 /* 3rd page of the Clone Virtual Disk wizard: */ 32 class UIWizardCloneVDPageBasic3 : public UIWizardPage 32 /* 3rd page of the Clone Virtual Disk wizard (base part): */ 33 class UIWizardCloneVDPage3 : public UIWizardPageBase 34 { 35 protected: 36 37 /* Constructor: */ 38 UIWizardCloneVDPage3(); 39 40 /* Stuff for 'variant' field: */ 41 qulonglong mediumVariant() const; 42 void setMediumVariant(qulonglong uMediumVariant); 43 44 /* Widgets: */ 45 QGroupBox *m_pVariantCnt; 46 QButtonGroup *m_pVariantButtonGroup; 47 QRadioButton *m_pDynamicalButton; 48 QRadioButton *m_pFixedButton; 49 QCheckBox *m_pSplitBox; 50 }; 51 52 /* 3rd page of the Clone Virtual Disk wizard (basic extension): */ 53 class UIWizardCloneVDPageBasic3 : public UIWizardPage, public UIWizardCloneVDPage3 33 54 { 34 55 Q_OBJECT; … … 51 72 bool isComplete() const; 52 73 53 /* Stuff for 'variant' field: */54 qulonglong mediumVariant() const;55 void setMediumVariant(qulonglong uMediumVariant);56 57 /* Variables: */58 QRadioButton *m_pDynamicalButton;59 QRadioButton *m_pFixedButton;60 QCheckBox *m_pSplitBox;61 62 74 /* Widgets: */ 63 75 QIRichTextLabel *m_pDescriptionLabel; … … 65 77 QIRichTextLabel *m_pFixedLabel; 66 78 QIRichTextLabel *m_pSplitLabel; 67 QGroupBox *m_pVariantContainer;68 79 }; 69 80 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic4.cpp
r40870 r41021 29 29 #include "UIWizardCloneVD.h" 30 30 #include "COMDefs.h" 31 #include "VBoxGlobal.h" 31 32 #include "UIMessageCenter.h" 32 33 #include "UIIconPool.h" … … 34 35 #include "QIRichTextLabel.h" 35 36 #include "QIToolButton.h" 36 #include "iprt/path.h" 37 38 UIWizardCloneVDPageBasic4::UIWizardCloneVDPageBasic4() 39 : m_uMediumSize(0) 40 { 41 /* Create widgets: */ 42 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 43 m_pLabel = new QIRichTextLabel(this); 44 m_pLocationCnt = new QGroupBox(this); 45 m_pLocationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 46 QHBoxLayout *pOptionsLayout = new QHBoxLayout(m_pLocationCnt); 47 m_pLocationEditor = new QLineEdit(m_pLocationCnt); 48 m_pLocationSelector = new QIToolButton(m_pLocationCnt); 49 m_pLocationSelector->setAutoRaise(true); 50 m_pLocationSelector->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png")); 51 pOptionsLayout->addWidget(m_pLocationEditor); 52 pOptionsLayout->addWidget(m_pLocationSelector); 53 pMainLayout->addWidget(m_pLabel); 54 pMainLayout->addWidget(m_pLocationCnt); 55 pMainLayout->addStretch(); 56 57 /* Setup page connections: */ 58 connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltLocationEditorTextChanged(const QString &))); 59 connect(m_pLocationSelector, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked())); 60 61 /* Register 'mediumPath', 'mediumSize' fields: */ 62 registerField("mediumPath", this, "mediumPath"); 63 registerField("mediumSize", this, "mediumSize"); 64 } 65 66 void UIWizardCloneVDPageBasic4::sltLocationEditorTextChanged(const QString &strMediumName) 67 { 68 /* Compose new medium path: */ 69 m_strMediumPath = absoluteFilePath(toFileName(strMediumName, m_strDefaultExtension), m_strDefaultPath); 70 /* Notify wizard sub-system about complete status changed: */ 71 emit completeChanged(); 72 } 73 74 void UIWizardCloneVDPageBasic4::sltSelectLocationButtonClicked() 37 38 UIWizardCloneVDPage4::UIWizardCloneVDPage4() 39 { 40 } 41 42 void UIWizardCloneVDPage4::onSelectLocationButtonClicked() 75 43 { 76 44 /* Get current folder and filename: */ 77 QFileInfo fullFilePath(m _strMediumPath);45 QFileInfo fullFilePath(mediumPath()); 78 46 QDir folder = fullFilePath.path(); 79 47 QString strFileName = fullFilePath.fileName(); … … 97 65 98 66 /* Prepare backends list: */ 99 CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();100 67 QVector<QString> fileExtensions; 101 68 QVector<KDeviceType> deviceTypes; 69 CMediumFormat mediumFormat = fieldImp("mediumFormat").value<CMediumFormat>(); 102 70 mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes); 103 71 QStringList validExtensionList; … … 110 78 /* Open corresponding file-dialog: */ 111 79 QString strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName), 112 strBackendsList, this ,113 UIWizardCloneVD::tr("Select a file for the new hard disk imagefile"));80 strBackendsList, thisImp(), 81 VBoxGlobal::tr("Choose a virtual hard disk file")); 114 82 115 83 /* If there was something really chosen: */ … … 119 87 if (QFileInfo(strChosenFilePath).suffix().isEmpty()) 120 88 strChosenFilePath += QString(".%1").arg(m_strDefaultExtension); 121 m_pLocationEditor->setText(QDir::toNativeSeparators(strChosenFilePath)); 122 m_pLocationEditor->selectAll(); 123 m_pLocationEditor->setFocus(); 124 } 125 } 126 127 void UIWizardCloneVDPageBasic4::retranslateUi() 128 { 129 /* Translate page: */ 130 setTitle(UIWizardCloneVD::tr("Virtual disk file location")); 131 132 /* Translate widgets: */ 133 m_pLabel->setText(UIWizardCloneVD::tr("Please type the name of the new virtual disk file into the box below or " 134 "click on the folder icon to select a different folder to create the file in.")); 135 m_pLocationCnt->setTitle(UIWizardCloneVD::tr("&Location")); 136 } 137 138 void UIWizardCloneVDPageBasic4::initializePage() 139 { 140 /* Translate page: */ 141 retranslateUi(); 142 143 /* Get source virtual-disk: */ 144 const CMedium &sourceVirtualDisk = field("sourceVirtualDisk").value<CMedium>(); 145 /* Get default path: */ 146 m_strDefaultPath = QFileInfo(sourceVirtualDisk.GetLocation()).absolutePath(); 147 /* Get default name: */ 148 QString strMediumName = UIWizardCloneVD::tr("%1_copy", "copied virtual disk name") 149 .arg(QFileInfo(sourceVirtualDisk.GetLocation()).baseName()); 150 /* Get virtual-disk size: */ 151 m_uMediumSize = sourceVirtualDisk.GetLogicalSize(); 152 /* Get virtual-disk extension: */ 153 m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>()); 154 /* Compose path for cloned virtual-disk: */ 155 m_strMediumPath = absoluteFilePath(toFileName(strMediumName, m_strDefaultExtension), m_strDefaultPath); 156 /* Set text to location editor: */ 157 m_pLocationEditor->setText(strMediumName); 158 } 159 160 bool UIWizardCloneVDPageBasic4::isComplete() const 161 { 162 /* Check what current name is not empty! */ 163 return !m_pLocationEditor->text().trimmed().isEmpty(); 164 } 165 166 bool UIWizardCloneVDPageBasic4::validatePage() 167 { 168 if (QFileInfo(m_strMediumPath).exists()) 169 { 170 msgCenter().sayCannotOverwriteHardDiskStorage(this, m_strMediumPath); 171 return false; 172 } 173 return true; 89 m_pDestinationDiskEditor->setText(QDir::toNativeSeparators(strChosenFilePath)); 90 m_pDestinationDiskEditor->selectAll(); 91 m_pDestinationDiskEditor->setFocus(); 92 } 174 93 } 175 94 176 95 /* static */ 177 QString UIWizardCloneVDPage Basic4::toFileName(const QString &strName, const QString &strExtension)96 QString UIWizardCloneVDPage4::toFileName(const QString &strName, const QString &strExtension) 178 97 { 179 98 /* Convert passed name to native separators (it can be full, actually): */ … … 194 113 195 114 /* static */ 196 QString UIWizardCloneVDPage Basic4::absoluteFilePath(const QString &strFileName, const QString &strDefaultPath)115 QString UIWizardCloneVDPage4::absoluteFilePath(const QString &strFileName, const QString &strDefaultPath) 197 116 { 198 117 /* Wrap file-info around received file name: */ … … 209 128 210 129 /* static */ 211 QString UIWizardCloneVDPage Basic4::defaultExtension(const CMediumFormat &mediumFormatRef)130 QString UIWizardCloneVDPage4::defaultExtension(const CMediumFormat &mediumFormatRef) 212 131 { 213 132 /* Load extension / device list: */ … … 223 142 } 224 143 144 QString UIWizardCloneVDPage4::mediumPath() const 145 { 146 return absoluteFilePath(toFileName(m_pDestinationDiskEditor->text(), m_strDefaultExtension), m_strDefaultPath); 147 } 148 149 qulonglong UIWizardCloneVDPage4::mediumSize() const 150 { 151 const CMedium &sourceVirtualDisk = fieldImp("sourceVirtualDisk").value<CMedium>(); 152 return sourceVirtualDisk.isNull() ? 0 : sourceVirtualDisk.GetLogicalSize(); 153 } 154 155 UIWizardCloneVDPageBasic4::UIWizardCloneVDPageBasic4() 156 { 157 /* Create widgets: */ 158 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 159 { 160 m_pLabel = new QIRichTextLabel(this); 161 m_pDestinationCnt = new QGroupBox(this); 162 { 163 m_pDestinationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 164 QHBoxLayout *pLocationCntLayout = new QHBoxLayout(m_pDestinationCnt); 165 { 166 m_pDestinationDiskEditor = new QLineEdit(m_pDestinationCnt); 167 m_pDestinationDiskOpenButton = new QIToolButton(m_pDestinationCnt); 168 { 169 m_pDestinationDiskOpenButton->setAutoRaise(true); 170 m_pDestinationDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png")); 171 } 172 pLocationCntLayout->addWidget(m_pDestinationDiskEditor); 173 pLocationCntLayout->addWidget(m_pDestinationDiskOpenButton); 174 } 175 } 176 pMainLayout->addWidget(m_pLabel); 177 pMainLayout->addWidget(m_pDestinationCnt); 178 pMainLayout->addStretch(); 179 } 180 181 /* Setup page connections: */ 182 connect(m_pDestinationDiskEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged())); 183 connect(m_pDestinationDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked())); 184 185 /* Register fields: */ 186 registerField("mediumPath", this, "mediumPath"); 187 registerField("mediumSize", this, "mediumSize"); 188 } 189 190 void UIWizardCloneVDPageBasic4::sltSelectLocationButtonClicked() 191 { 192 /* Call to base-class: */ 193 onSelectLocationButtonClicked(); 194 } 195 196 void UIWizardCloneVDPageBasic4::retranslateUi() 197 { 198 /* Translate page: */ 199 setTitle(UIWizardCloneVD::tr("Virtual disk file location")); 200 201 /* Translate widgets: */ 202 m_pLabel->setText(UIWizardCloneVD::tr("Please type the name of the new virtual disk file into the box below or " 203 "click on the folder icon to select a different folder to create the file in.")); 204 m_pDestinationCnt->setTitle(UIWizardCloneVD::tr("&Location")); 205 m_pDestinationDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file...")); 206 } 207 208 void UIWizardCloneVDPageBasic4::initializePage() 209 { 210 /* Translate page: */ 211 retranslateUi(); 212 213 /* Get source virtual-disk file-information: */ 214 QFileInfo sourceFileInfo(field("sourceVirtualDisk").value<CMedium>().GetLocation()); 215 /* Get default path for virtual-disk copy: */ 216 m_strDefaultPath = sourceFileInfo.absolutePath(); 217 /* Get default extension for virtual-disk copy: */ 218 m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>()); 219 /* Compose default-name for virtual-disk copy: */ 220 QString strMediumName = UIWizardCloneVD::tr("%1_copy", "copied virtual disk name").arg(sourceFileInfo.baseName()); 221 /* Set default-name as text for location editor: */ 222 m_pDestinationDiskEditor->setText(strMediumName); 223 } 224 225 bool UIWizardCloneVDPageBasic4::isComplete() const 226 { 227 /* Make sure current name is not empty: */ 228 return !m_pDestinationDiskEditor->text().trimmed().isEmpty(); 229 } 230 231 bool UIWizardCloneVDPageBasic4::validatePage() 232 { 233 /* Make sure such virtual-disk doesn't exists already: */ 234 QString strMediumPath(mediumPath()); 235 if (QFileInfo(strMediumPath).exists()) 236 { 237 msgCenter().sayCannotOverwriteHardDiskStorage(this, strMediumPath); 238 return false; 239 } 240 return true; 241 } 242 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic4.h
r40870 r41021 20 20 #define __UIWizardCloneVDPageBasic4_h__ 21 21 22 /* Global includes: */ 23 #include <QVariant> 24 22 25 /* Local includes: */ 23 26 #include "UIWizardPage.h" … … 25 28 26 29 /* Forward declarations: */ 27 class QIRichTextLabel;30 class CMediumFormat; 28 31 class QGroupBox; 29 32 class QLineEdit; 30 33 class QIToolButton; 31 class CMediumFormat;34 class QIRichTextLabel; 32 35 33 /* 4th page of the Clone Virtual Disk wizard: */ 34 class UIWizardCloneVDPageBasic4 : public UIWizardPage 36 /* 4th page of the Clone Virtual Disk wizard (base part): */ 37 class UIWizardCloneVDPage4 : public UIWizardPageBase 38 { 39 protected: 40 41 /* Constructor: */ 42 UIWizardCloneVDPage4(); 43 44 /* Handlers: */ 45 void onSelectLocationButtonClicked(); 46 47 /* Location-editors stuff: */ 48 static QString toFileName(const QString &strName, const QString &strExtension); 49 static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath); 50 static QString defaultExtension(const CMediumFormat &mediumFormatRef); 51 52 /* Stuff for 'mediumPath' field: */ 53 QString mediumPath() const; 54 55 /* Stuff for 'mediumSize' field: */ 56 qulonglong mediumSize() const; 57 58 /* Variables: */ 59 QString m_strDefaultPath; 60 QString m_strDefaultExtension; 61 62 /* Widgets: */ 63 QGroupBox *m_pDestinationCnt; 64 QLineEdit *m_pDestinationDiskEditor; 65 QIToolButton *m_pDestinationDiskOpenButton; 66 }; 67 68 /* 4th page of the Clone Virtual Disk wizard (basic extension): */ 69 class UIWizardCloneVDPageBasic4 : public UIWizardPage, public UIWizardCloneVDPage4 35 70 { 36 71 Q_OBJECT; 37 Q_PROPERTY(QString mediumPath READ mediumPath WRITE setMediumPath);38 Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize);72 Q_PROPERTY(QString mediumPath READ mediumPath); 73 Q_PROPERTY(qulonglong mediumSize READ mediumSize); 39 74 40 75 public: … … 43 78 UIWizardCloneVDPageBasic4(); 44 79 80 protected: 81 82 /* Wrapper to access 'this' from base part: */ 83 UIWizardPage* thisImp() { return this; } 84 /* Wrapper to access 'wizard-field' from base part: */ 85 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 86 45 87 private slots: 46 88 47 /* Location editors stuff: */ 48 void sltLocationEditorTextChanged(const QString &strMediumName); 89 /* Location editor stuff: */ 49 90 void sltSelectLocationButtonClicked(); 50 91 … … 61 102 bool validatePage(); 62 103 63 /* Location-editors stuff: */64 static QString toFileName(const QString &strName, const QString &strExtension);65 static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath);66 static QString defaultExtension(const CMediumFormat &mediumFormatRef);67 68 /* Stuff for 'mediumPath' field: */69 QString mediumPath() const { return m_strMediumPath; }70 void setMediumPath(const QString &strMediumPath) { m_strMediumPath = strMediumPath; }71 QString m_strMediumPath;72 73 /* Stuff for 'mediumSize' field: */74 qulonglong mediumSize() const { return m_uMediumSize; }75 void setMediumSize(qulonglong uMediumSize) { m_uMediumSize = uMediumSize; }76 qulonglong m_uMediumSize;77 78 /* Location-editors variables: */79 QString m_strDefaultPath;80 QString m_strDefaultExtension;81 82 104 /* Widgets: */ 83 105 QIRichTextLabel *m_pLabel; 84 QGroupBox *m_pLocationCnt;85 QLineEdit *m_pLocationEditor;86 QIToolButton *m_pLocationSelector;87 106 }; 88 107 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic5.cpp
r40870 r41021 24 24 #include "QIRichTextLabel.h" 25 25 26 UIWizardCloneVDPage5::UIWizardCloneVDPage5() 27 { 28 } 29 26 30 UIWizardCloneVDPageBasic5::UIWizardCloneVDPageBasic5() 27 31 { 28 32 /* Create widgets: */ 29 33 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 34 { 30 35 m_pLabel1 = new QIRichTextLabel(this); 31 36 m_pSummaryText = new QIRichTextLabel(this); 32 37 m_pLabel2 = new QIRichTextLabel(this); 33 pMainLayout->addWidget(m_pLabel1); 34 pMainLayout->addWidget(m_pSummaryText); 35 pMainLayout->addWidget(m_pLabel2); 36 pMainLayout->addStretch(); 38 pMainLayout->addWidget(m_pLabel1); 39 pMainLayout->addWidget(m_pSummaryText); 40 pMainLayout->addWidget(m_pLabel2); 41 pMainLayout->addStretch(); 42 } 37 43 } 38 44 … … 81 87 bool UIWizardCloneVDPageBasic5::validatePage() 82 88 { 89 /* Initial result: */ 90 bool fResult = true; 91 92 /* Lock finish button: */ 93 startProcessing(); 94 83 95 /* Try to copy virtual-disk: */ 84 startProcessing(); 85 bool fResult = qobject_cast<UIWizardCloneVD*>(wizard())->copyVirtualDisk(); 96 if (fResult) 97 fResult = qobject_cast<UIWizardCloneVD*>(wizard())->copyVirtualDisk(); 98 99 /* Unlock finish button: */ 86 100 endProcessing(); 101 102 /* Return result: */ 87 103 return fResult; 88 104 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic5.h
r40870 r41021 27 27 class QIRichTextLabel; 28 28 29 /* 5th page of the Clone Virtual Disk wizard: */ 30 class UIWizardCloneVDPageBasic5 : public UIWizardPage 29 /* 5th page of the Clone Virtual Disk wizard (base part): */ 30 class UIWizardCloneVDPage5 : public UIWizardPageBase 31 { 32 protected: 33 34 /* Constructor: */ 35 UIWizardCloneVDPage5(); 36 }; 37 38 /* 5th page of the Clone Virtual Disk wizard (basic extension): */ 39 class UIWizardCloneVDPageBasic5 : public UIWizardPage, public UIWizardCloneVDPage5 31 40 { 32 41 Q_OBJECT; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageExpert.cpp
r40929 r41021 3 3 * 4 4 * VBox frontends: Qt4 GUI ("VirtualBox"): 5 * UIWizardCloneVDPage Basic1class implementation5 * UIWizardCloneVDPageExpert class implementation 6 6 */ 7 7 … … 19 19 20 20 /* Global includes: */ 21 #include <QGridLayout> 21 22 #include <QVBoxLayout> 22 23 #include <QHBoxLayout> 24 #include <QButtonGroup> 23 25 #include <QGroupBox> 26 #include <QRadioButton> 27 #include <QCheckBox> 28 #include <QLineEdit> 24 29 25 30 /* Local includes: */ 26 #include "UIWizardCloneVDPage Basic1.h"31 #include "UIWizardCloneVDPageExpert.h" 27 32 #include "UIWizardCloneVD.h" 33 #include "UIMessageCenter.h" 28 34 #include "UIIconPool.h" 29 #include "QIRichTextLabel.h"30 35 #include "VBoxMediaComboBox.h" 31 36 #include "QIToolButton.h" 32 37 33 UIWizardCloneVDPage Basic1::UIWizardCloneVDPageBasic1(const CMedium &sourceVirtualDisk)38 UIWizardCloneVDPageExpert::UIWizardCloneVDPageExpert(const CMedium &sourceVirtualDisk) 34 39 { 35 40 /* Create widgets: */ 36 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 37 m_pLabel = new QIRichTextLabel(this); 38 m_pSourceDiskContainer = new QGroupBox(this); 39 m_pSourceDiskContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 40 QHBoxLayout *pSourceDiskLayout = new QHBoxLayout(m_pSourceDiskContainer); 41 m_pSourceDiskSelector = new VBoxMediaComboBox(m_pSourceDiskContainer); 41 QGridLayout *pMainLayout = new QGridLayout(this); 42 { 43 pMainLayout->setContentsMargins(8, 6, 8, 6); 44 m_pSourceDiskCnt = new QGroupBox(this); 45 { 46 m_pSourceDiskCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 47 QHBoxLayout *pSourceDiskCntLayout = new QHBoxLayout(m_pSourceDiskCnt); 48 { 49 m_pSourceDiskSelector = new VBoxMediaComboBox(m_pSourceDiskCnt); 50 { 42 51 m_pSourceDiskSelector->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); 43 52 m_pSourceDiskSelector->setType(VBoxDefs::MediumType_HardDisk); 44 53 m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId()); 45 54 m_pSourceDiskSelector->repopulate(); 46 m_pOpenSourceDiskButton = new QIToolButton(m_pSourceDiskContainer); 47 m_pOpenSourceDiskButton->setAutoRaise(true); 48 m_pOpenSourceDiskButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png")); 49 pSourceDiskLayout->addWidget(m_pSourceDiskSelector); 50 pSourceDiskLayout->addWidget(m_pOpenSourceDiskButton); 51 pMainLayout->addWidget(m_pLabel); 52 pMainLayout->addWidget(m_pSourceDiskContainer); 53 pMainLayout->addStretch(); 55 } 56 m_pSourceDiskOpenButton = new QIToolButton(m_pSourceDiskCnt); 57 { 58 m_pSourceDiskOpenButton->setAutoRaise(true); 59 m_pSourceDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png")); 60 } 61 pSourceDiskCntLayout->addWidget(m_pSourceDiskSelector); 62 pSourceDiskCntLayout->addWidget(m_pSourceDiskOpenButton); 63 } 64 } 65 m_pDestinationCnt = new QGroupBox(this); 66 { 67 m_pDestinationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 68 QHBoxLayout *pLocationCntLayout = new QHBoxLayout(m_pDestinationCnt); 69 { 70 m_pDestinationDiskEditor = new QLineEdit(m_pDestinationCnt); 71 m_pDestinationDiskOpenButton = new QIToolButton(m_pDestinationCnt); 72 { 73 m_pDestinationDiskOpenButton->setAutoRaise(true); 74 m_pDestinationDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png")); 75 } 76 } 77 pLocationCntLayout->addWidget(m_pDestinationDiskEditor); 78 pLocationCntLayout->addWidget(m_pDestinationDiskOpenButton); 79 } 80 QVBoxLayout *pFormatWrappingLayout = new QVBoxLayout; 81 { 82 m_pFormatCnt = new QGroupBox(this); 83 { 84 m_pFormatCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 85 QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatCnt); 86 { 87 m_pFormatButtonGroup = new QButtonGroup(this); 88 { 89 CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties(); 90 const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats(); 91 for (int i = 0; i < medFormats.size(); ++i) 92 { 93 const CMediumFormat &medFormat = medFormats[i]; 94 QString strFormatName(medFormat.GetName()); 95 if (strFormatName == "VDI") 96 { 97 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat); 98 if (pButton) 99 { 100 m_formats << medFormat; 101 m_formatNames << strFormatName; 102 m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1); 103 } 104 } 105 } 106 for (int i = 0; i < medFormats.size(); ++i) 107 { 108 const CMediumFormat &medFormat = medFormats[i]; 109 QString strFormatName(medFormat.GetName()); 110 if (strFormatName != "VDI") 111 { 112 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat); 113 if (pButton) 114 { 115 m_formats << medFormat; 116 m_formatNames << strFormatName; 117 m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1); 118 } 119 } 120 } 121 m_pFormatButtonGroup->button(0)->click(); 122 m_pFormatButtonGroup->button(0)->setFocus(); 123 } 124 } 125 } 126 QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding); 127 pFormatWrappingLayout->addWidget(m_pFormatCnt); 128 pFormatWrappingLayout->addItem(m_pSizeSpacer); 129 } 130 QVBoxLayout *pVariantWrappingLayout = new QVBoxLayout; 131 { 132 m_pVariantCnt = new QGroupBox(this); 133 { 134 m_pVariantCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 135 QVBoxLayout *pVariantCntLayout = new QVBoxLayout(m_pVariantCnt); 136 { 137 m_pVariantButtonGroup = new QButtonGroup(m_pVariantCnt); 138 { 139 m_pDynamicalButton = new QRadioButton(m_pVariantCnt); 140 { 141 m_pDynamicalButton->click(); 142 m_pDynamicalButton->setFocus(); 143 } 144 m_pFixedButton = new QRadioButton(m_pVariantCnt); 145 m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0); 146 m_pVariantButtonGroup->addButton(m_pFixedButton, 1); 147 } 148 m_pSplitBox = new QCheckBox(m_pVariantCnt); 149 pVariantCntLayout->addWidget(m_pDynamicalButton); 150 pVariantCntLayout->addWidget(m_pFixedButton); 151 pVariantCntLayout->addWidget(m_pSplitBox); 152 } 153 } 154 QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding); 155 pVariantWrappingLayout->addWidget(m_pVariantCnt); 156 pVariantWrappingLayout->addItem(m_pSizeSpacer); 157 } 158 pMainLayout->addWidget(m_pSourceDiskCnt, 0, 0, 1, 2); 159 pMainLayout->addWidget(m_pDestinationCnt, 1, 0, 1, 2); 160 pMainLayout->addLayout(pFormatWrappingLayout, 2, 0); 161 pMainLayout->addLayout(pVariantWrappingLayout, 2, 1); 162 sltHandleSourceDiskChange(); 163 sltMediumFormatChanged(); 164 } 54 165 55 166 /* Setup connections: */ 56 connect(m_pSourceDiskSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged())); 57 connect(m_pOpenSourceDiskButton, SIGNAL(clicked()), this, SLOT(sltHandleOpenSourceDiskClick())); 58 59 /* Register CMedium class: */ 167 connect(m_pSourceDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(sltHandleSourceDiskChange())); 168 connect(m_pSourceDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltHandleOpenSourceDiskClick())); 169 connect(m_pFormatButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(sltMediumFormatChanged())); 170 connect(m_pVariantButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged())); 171 connect(m_pSplitBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged())); 172 connect(m_pDestinationDiskEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged())); 173 connect(m_pDestinationDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked())); 174 175 /* Register classes: */ 60 176 qRegisterMetaType<CMedium>(); 61 /* Register 'sourceVirtualDisk' field: */ 177 qRegisterMetaType<CMediumFormat>(); 178 /* Register fields: */ 62 179 registerField("sourceVirtualDisk", this, "sourceVirtualDisk"); 63 } 64 65 void UIWizardCloneVDPageBasic1::sltHandleOpenSourceDiskClick() 66 { 67 /* Get source virtual-disk using file-open dialog: */ 68 QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(VBoxDefs::MediumType_HardDisk, this); 69 if (!strMediumId.isNull()) 180 registerField("mediumFormat", this, "mediumFormat"); 181 registerField("mediumVariant", this, "mediumVariant"); 182 registerField("mediumPath", this, "mediumPath"); 183 registerField("mediumSize", this, "mediumSize"); 184 } 185 186 void UIWizardCloneVDPageExpert::sltHandleSourceDiskChange() 187 { 188 /* Get source virtual-disk file-information: */ 189 QFileInfo sourceFileInfo(sourceVirtualDisk().GetLocation()); 190 /* Get default path for virtual-disk copy: */ 191 m_strDefaultPath = sourceFileInfo.absolutePath(); 192 /* Compose name for virtual-disk copy: */ 193 QString strMediumName = UIWizardCloneVD::tr("%1_copy", "copied virtual disk name").arg(sourceFileInfo.baseName()); 194 /* Set text to location editor: */ 195 m_pDestinationDiskEditor->setText(strMediumName); 196 197 /* Broadcast complete-change: */ 198 emit completeChanged(); 199 } 200 201 void UIWizardCloneVDPageExpert::sltHandleOpenSourceDiskClick() 202 { 203 /* Call to base-class: */ 204 onHandleOpenSourceDiskClick(); 205 } 206 207 void UIWizardCloneVDPageExpert::sltMediumFormatChanged() 208 { 209 /* Get medium format: */ 210 CMediumFormat mf = mediumFormat(); 211 212 /* Enable/disable widgets: */ 213 ULONG uCapabilities = mf.GetCapabilities(); 214 bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic; 215 bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed; 216 bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G; 217 m_pDynamicalButton->setEnabled(fIsCreateDynamicPossible); 218 m_pFixedButton->setEnabled(fIsCreateFixedPossible); 219 m_pSplitBox->setEnabled(fIsCreateSplitPossible); 220 221 /* Compose virtual-disk extension: */ 222 m_strDefaultExtension = defaultExtension(mf); 223 224 /* Broadcast complete-change: */ 225 emit completeChanged(); 226 } 227 228 void UIWizardCloneVDPageExpert::sltSelectLocationButtonClicked() 229 { 230 /* Call to base-class: */ 231 onSelectLocationButtonClicked(); 232 } 233 234 void UIWizardCloneVDPageExpert::retranslateUi() 235 { 236 /* Translate widgets: */ 237 m_pSourceDiskCnt->setTitle(UIWizardCloneVD::tr("&Source virtual disk")); 238 m_pSourceDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file...")); 239 m_pDestinationCnt->setTitle(UIWizardCloneVD::tr("&Destination virtual disk")); 240 m_pDestinationDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file...")); 241 m_pFormatCnt->setTitle(UIWizardCloneVD::tr("File type")); 242 QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons(); 243 for (int i = 0; i < buttons.size(); ++i) 70 244 { 71 /* Update medium-combo if necessary: */ 72 m_pSourceDiskSelector->setCurrentItem(strMediumId); 73 /* Focus on virtual-disk combo: */ 74 m_pSourceDiskSelector->setFocus(); 245 QAbstractButton *pButton = buttons[i]; 246 pButton->setText(UIWizardCloneVD::fullFormatName(m_formatNames[m_pFormatButtonGroup->id(pButton)])); 75 247 } 76 } 77 78 void UIWizardCloneVDPageBasic1::retranslateUi() 79 { 80 /* Translate page: */ 81 setTitle(UIWizardCloneVD::tr("Welcome to the virtual disk copying wizard")); 82 83 /* Translate widgets: */ 84 m_pSourceDiskContainer->setTitle(UIWizardCloneVD::tr("Virtual disk to copy")); 85 m_pOpenSourceDiskButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file...")); 86 m_pLabel->setText(UIWizardCloneVD::tr("<p>This wizard will help you to copy a virtual disk.</p>")); 87 m_pLabel->setText(m_pLabel->text() + QString("<p>%1</p>").arg(standardHelpText())); 88 m_pLabel->setText(m_pLabel->text() + UIWizardCloneVD::tr("Please select the virtual disk which you would like " 89 "to copy if it is not already selected. You can either " 90 "choose one from the list or use the folder icon " 91 "beside the list to select a virtual disk file.")); 92 } 93 94 void UIWizardCloneVDPageBasic1::initializePage() 248 m_pVariantCnt->setTitle(UIWizardCloneVD::tr("Storage details")); 249 m_pDynamicalButton->setText(UIWizardCloneVD::tr("&Dynamically allocated")); 250 m_pFixedButton->setText(UIWizardCloneVD::tr("&Fixed size")); 251 m_pSplitBox->setText(UIWizardCloneVD::tr("&Split into files of less than 2GB")); 252 } 253 254 void UIWizardCloneVDPageExpert::initializePage() 95 255 { 96 256 /* Translate page: */ … … 98 258 } 99 259 100 bool UIWizardCloneVDPageBasic1::isComplete() const 101 { 102 /* Check what source virtual-disk feats the rules: */ 103 return !sourceVirtualDisk().isNull(); 104 } 105 106 CMedium UIWizardCloneVDPageBasic1::sourceVirtualDisk() const 107 { 108 return vboxGlobal().findMedium(m_pSourceDiskSelector->id()).medium(); 109 } 110 111 void UIWizardCloneVDPageBasic1::setSourceVirtualDisk(const CMedium &sourceVirtualDisk) 112 { 113 m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId()); 114 } 115 260 bool UIWizardCloneVDPageExpert::isComplete() const 261 { 262 /* Check what source virtual-disk feats the rules, 263 * medium format/variant is correct, 264 * current name is not empty: */ 265 return !sourceVirtualDisk().isNull() && 266 !mediumFormat().isNull() && 267 mediumVariant() != (qulonglong)KMediumVariant_Max && 268 !m_pDestinationDiskEditor->text().trimmed().isEmpty(); 269 } 270 271 bool UIWizardCloneVDPageExpert::validatePage() 272 { 273 /* Initial result: */ 274 bool fResult = true; 275 276 /* Lock finish button: */ 277 startProcessing(); 278 279 /* Make sure such virtual-disk doesn't exists already: */ 280 QString strMediumPath(mediumPath()); 281 if (fResult && QFileInfo(strMediumPath).exists()) 282 { 283 msgCenter().sayCannotOverwriteHardDiskStorage(this, strMediumPath); 284 fResult = false; 285 } 286 287 /* Try to copy virtual-disk: */ 288 if (fResult) 289 fResult = qobject_cast<UIWizardCloneVD*>(wizard())->copyVirtualDisk(); 290 291 /* Unlock finish button: */ 292 endProcessing(); 293 294 /* Return result: */ 295 return fResult; 296 } 297 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageExpert.h
r40929 r41021 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * UIWizardCloneVDPage Basic1class declaration4 * UIWizardCloneVDPageExpert class declaration 5 5 */ 6 6 … … 17 17 */ 18 18 19 #ifndef __UIWizardCloneVDPage Basic1_h__20 #define __UIWizardCloneVDPage Basic1_h__19 #ifndef __UIWizardCloneVDPageExpert_h__ 20 #define __UIWizardCloneVDPageExpert_h__ 21 21 22 22 /* Local includes: */ 23 #include "UIWizardPage.h" 24 #include "COMDefs.h" 23 #include "UIWizardCloneVDPageBasic1.h" 24 #include "UIWizardCloneVDPageBasic2.h" 25 #include "UIWizardCloneVDPageBasic3.h" 26 #include "UIWizardCloneVDPageBasic4.h" 27 #include "UIWizardCloneVDPageBasic5.h" 25 28 26 /* Forward declarations: */ 27 class QIRichTextLabel; 28 class QGroupBox; 29 class VBoxMediaComboBox; 30 class QIToolButton; 31 32 /* 1st page of the Clone Virtual Disk wizard: */ 33 class UIWizardCloneVDPageBasic1 : public UIWizardPage 29 /* Expert page of the Clone Virtual Disk wizard: */ 30 class UIWizardCloneVDPageExpert : public UIWizardPage, 31 public UIWizardCloneVDPage1, 32 public UIWizardCloneVDPage2, 33 public UIWizardCloneVDPage3, 34 public UIWizardCloneVDPage4, 35 public UIWizardCloneVDPage5 34 36 { 35 37 Q_OBJECT; 36 38 Q_PROPERTY(CMedium sourceVirtualDisk READ sourceVirtualDisk WRITE setSourceVirtualDisk); 39 Q_PROPERTY(CMediumFormat mediumFormat READ mediumFormat WRITE setMediumFormat); 40 Q_PROPERTY(qulonglong mediumVariant READ mediumVariant WRITE setMediumVariant); 41 Q_PROPERTY(QString mediumPath READ mediumPath); 42 Q_PROPERTY(qulonglong mediumSize READ mediumSize); 37 43 38 44 public: 39 45 40 46 /* Constructor: */ 41 UIWizardCloneVDPageBasic1(const CMedium &sourceVirtualDisk); 47 UIWizardCloneVDPageExpert(const CMedium &sourceVirtualDisk); 48 49 protected: 50 51 /* Wrapper to access 'this' from base part: */ 52 UIWizardPage* thisImp() { return this; } 53 /* Wrapper to access 'wizard-field' from base part: */ 54 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 42 55 43 56 private slots: 44 57 45 /* Handlers for source virtual-disk change: */ 58 /* Source virtual-disk stuff: */ 59 void sltHandleSourceDiskChange(); 46 60 void sltHandleOpenSourceDiskClick(); 61 62 /* Medium format stuff: */ 63 void sltMediumFormatChanged(); 64 65 /* Location editor stuff: */ 66 void sltSelectLocationButtonClicked(); 47 67 48 68 private: … … 56 76 /* Validation stuff: */ 57 77 bool isComplete() const; 58 59 /* Stuff for 'sourceVirtualDisk' field: */ 60 CMedium sourceVirtualDisk() const; 61 void setSourceVirtualDisk(const CMedium &sourceVirtualDisk); 62 63 /* Widgets: */ 64 QIRichTextLabel *m_pLabel; 65 QGroupBox *m_pSourceDiskContainer; 66 VBoxMediaComboBox *m_pSourceDiskSelector; 67 QIToolButton *m_pOpenSourceDiskButton; 78 bool validatePage(); 68 79 }; 69 80 70 #endif // __UIWizardCloneVDPage Basic1_h__81 #endif // __UIWizardCloneVDPageExpert_h__ 71 82 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp
r40870 r41021 23 23 #include "UIWizardCloneVMPageBasic2.h" 24 24 #include "UIWizardCloneVMPageBasic3.h" 25 #include "UIWizardCloneVMPageExpert.h" 25 26 #include "VBoxGlobal.h" 26 27 #include "UIMessageCenter.h" 27 28 28 29 UIWizardCloneVM::UIWizardCloneVM(QWidget *pParent, const CMachine &machine, CSnapshot snapshot /* = CSnapshot() */) 29 : UIWizard(pParent )30 : UIWizard(pParent, UIWizardType_CloneVM) 30 31 , m_machine(machine) 31 32 , m_snapshot(snapshot) 32 33 { 33 #ifdef Q_WS_WIN34 /* Hide window icon: */35 setWindowIcon(QIcon());36 #endif /* Q_WS_WIN */37 38 /* Create & add pages: */39 setPage(Page1, new UIWizardCloneVMPageBasic1(m_machine.GetName()));40 /* If we are having a snapshot we can show the "Linked" option. */41 setPage(Page2, new UIWizardCloneVMPageBasic2(snapshot.isNull()));42 /* If the machine has no snapshots, we don't bother the user about options for it. */43 if (m_machine.GetSnapshotCount() > 0)44 setPage(Page3, new UIWizardCloneVMPageBasic3(snapshot.isNull() ? false : snapshot.GetChildrenCount() > 0));45 46 /* Translate wizard: */47 retranslateUi();48 49 /* Translate wizard pages: */50 retranslateAllPages();51 52 34 #ifndef Q_WS_MAC 53 35 /* Assign watermark: */ … … 58 40 assignBackground(":/vmw_clone_bg.png"); 59 41 #endif /* Q_WS_MAC */ 60 61 /* Resize wizard to 'golden ratio': */62 resizeToGoldenRatio(UIWizardType_CloneVM);63 }64 65 void UIWizardCloneVM::retranslateUi()66 {67 /* Translate wizard: */68 setWindowTitle(tr("Clone Virtual Machine"));69 setButtonText(QWizard::FinishButton, tr("Clone"));70 42 } 71 43 … … 79 51 bool fLinked = field("linkedClone").toBool(); 80 52 /* Get clone mode: */ 81 KCloneMode mode = page(Page3) ? field("cloneMode").value<KCloneMode>() : KCloneMode_MachineState; 53 KCloneMode cloneMode = (mode() == UIWizardMode_Basic && page(Page3)) || 54 (mode() == UIWizardMode_Expert && page(PageExpert)) ? 55 field("cloneMode").value<KCloneMode>() : KCloneMode_MachineState; 82 56 57 /* Get VBox object: */ 83 58 CVirtualBox vbox = vboxGlobal().virtualBox(); 84 const QString &strSettingsFile = vbox.ComposeMachineFilename(strName, QString::null);85 59 60 /* Prepare machine for cloning: */ 86 61 CMachine srcMachine = m_machine; 62 87 63 /* If the user like to create a linked clone from the current machine, we 88 64 * have to take a little bit more action. First we create an snapshot, so … … 91 67 if (fLinked && m_snapshot.isNull()) 92 68 { 93 const QString &strId = m_machine.GetId();94 CSession session = vboxGlobal().openSession( strId);69 /* Open session: */ 70 CSession session = vboxGlobal().openSession(m_machine.GetId()); 95 71 if (session.isNull()) 96 72 return false; 73 74 /* Prepare console: */ 97 75 CConsole console = session.GetConsole(); 98 76 … … 132 110 133 111 /* Create a new machine object. */ 112 const QString &strSettingsFile = vbox.ComposeMachineFilename(strName, QString::null); 134 113 CMachine cloneMachine = vbox.CreateMachine(strSettingsFile, strName, QString::null, QString::null, false); 135 114 if (!vbox.isOk()) … … 148 127 149 128 /* Start cloning. */ 150 CProgress progress = srcMachine.CloneTo(cloneMachine, mode, options);129 CProgress progress = srcMachine.CloneTo(cloneMachine, cloneMode, options); 151 130 if (!srcMachine.isOk()) 152 131 { … … 176 155 } 177 156 157 void UIWizardCloneVM::retranslateUi() 158 { 159 /* Call to base-class: */ 160 UIWizard::retranslateUi(); 161 162 /* Translate wizard: */ 163 setWindowTitle(tr("Clone Virtual Machine")); 164 setButtonText(QWizard::FinishButton, tr("Clone")); 165 } 166 167 void UIWizardCloneVM::prepare() 168 { 169 /* Create corresponding pages: */ 170 switch (mode()) 171 { 172 case UIWizardMode_Basic: 173 { 174 setPage(Page1, new UIWizardCloneVMPageBasic1(m_machine.GetName())); 175 setPage(Page2, new UIWizardCloneVMPageBasic2(m_snapshot.isNull())); 176 if (m_machine.GetSnapshotCount() > 0) 177 setPage(Page3, new UIWizardCloneVMPageBasic3(m_snapshot.isNull() ? false : m_snapshot.GetChildrenCount() > 0)); 178 break; 179 } 180 case UIWizardMode_Expert: 181 { 182 setPage(PageExpert, new UIWizardCloneVMPageExpert(m_machine.GetName(), 183 m_snapshot.isNull(), 184 m_snapshot.isNull() ? false : m_snapshot.GetChildrenCount() > 0)); 185 break; 186 } 187 } 188 /* Call to base-class: */ 189 UIWizard::prepare(); 190 } 191 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.h
r40870 r41021 39 39 }; 40 40 41 /* Page IDs: */ 42 enum 43 { 44 PageExpert 45 }; 46 41 47 /* Constructor: */ 42 48 UIWizardCloneVM(QWidget *pParent, const CMachine &machine, CSnapshot snapshot = CSnapshot()); … … 51 57 friend class UIWizardCloneVMPageBasic2; 52 58 friend class UIWizardCloneVMPageBasic3; 59 friend class UIWizardCloneVMPageExpert; 53 60 54 61 private: … … 56 63 /* Translation stuff: */ 57 64 void retranslateUi(); 65 66 /* Pages related stuff: */ 67 void prepare(); 58 68 59 69 /* Variables: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp
r40870 r41021 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QGroupBox> 22 23 #include <QLineEdit> 23 24 #include <QCheckBox> … … 29 30 #include "QIRichTextLabel.h" 30 31 32 UIWizardCloneVMPage1::UIWizardCloneVMPage1(const QString &strOriginalName) 33 : m_strOriginalName(strOriginalName) 34 { 35 } 36 37 QString UIWizardCloneVMPage1::cloneName() const 38 { 39 return m_pNameEditor->text(); 40 } 41 42 void UIWizardCloneVMPage1::setCloneName(const QString &strName) 43 { 44 m_pNameEditor->setText(strName); 45 } 46 47 bool UIWizardCloneVMPage1::isReinitMACsChecked() const 48 { 49 return m_pReinitMACsCheckBox->isChecked(); 50 } 51 31 52 UIWizardCloneVMPageBasic1::UIWizardCloneVMPageBasic1(const QString &strOriginalName) 32 : m_strOriginalName(strOriginalName)53 : UIWizardCloneVMPage1(strOriginalName) 33 54 { 34 55 /* Create widgets: */ 35 56 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 57 { 36 58 m_pLabel1 = new QIRichTextLabel(this); 37 59 m_pLabel2 = new QIRichTextLabel(this); 38 m_pNameEditor = new QLineEdit(this); 39 m_pNameEditor->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName)); 60 m_pNameCnt = new QGroupBox(this); 61 { 62 QVBoxLayout *pNameCntLayout = new QVBoxLayout(m_pNameCnt); 63 { 64 m_pNameEditor = new QLineEdit(m_pNameCnt); 65 { 66 m_pNameEditor->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName)); 67 } 68 pNameCntLayout->addWidget(m_pNameEditor); 69 } 70 } 40 71 m_pReinitMACsCheckBox = new QCheckBox(this); 41 pMainLayout->addWidget(m_pLabel1); 42 pMainLayout->addWidget(m_pLabel2); 43 pMainLayout->addWidget(m_pNameEditor); 44 pMainLayout->addWidget(m_pReinitMACsCheckBox); 45 pMainLayout->addStretch(); 72 pMainLayout->addWidget(m_pLabel1); 73 pMainLayout->addWidget(m_pLabel2); 74 pMainLayout->addWidget(m_pNameCnt); 75 pMainLayout->addWidget(m_pReinitMACsCheckBox); 76 pMainLayout->addStretch(); 77 } 46 78 47 79 /* Setup connections: */ 48 connect(m_pNameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));80 connect(m_pNameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged())); 49 81 50 82 /* Register fields: */ … … 56 88 { 57 89 /* Translate page: */ 58 setTitle(UIWizardCloneVM::tr("Welcome to the virtual machine clone wizard"));90 setTitle(UIWizardCloneVM::tr("Welcome to the Clone Virtual Machine wizard!")); 59 91 60 92 /* Translate widgets: */ 61 93 m_pLabel1->setText(UIWizardCloneVM::tr("<p>This wizard will help you to create a clone of your virtual machine.</p>")); 94 m_pLabel1->setText(m_pLabel1->text() + QString("<p>%1</p>").arg(standardHelpText())); 62 95 m_pLabel2->setText(UIWizardCloneVM::tr("<p>Please choose a name for the new virtual machine:</p>")); 96 m_pNameCnt->setTitle(UIWizardCloneVM::tr("&Name")); 63 97 m_pReinitMACsCheckBox->setToolTip(UIWizardCloneVM::tr("When checked a new unique MAC address will be assigned to all configured network cards.")); 64 98 m_pReinitMACsCheckBox->setText(UIWizardCloneVM::tr("&Reinitialize the MAC address of all network cards")); 65 66 /* Append page text with common part: */67 QString strCommonPart = QString("<p>%1</p>").arg(standardHelpText());68 m_pLabel1->setText(m_pLabel1->text() + strCommonPart);69 99 } 70 100 … … 77 107 bool UIWizardCloneVMPageBasic1::isComplete() const 78 108 { 109 /* Make sure VM name feat the rules: */ 79 110 QString strName = m_pNameEditor->text().trimmed(); 80 111 return !strName.isEmpty() && strName != m_strOriginalName; 81 112 } 82 113 83 bool UIWizardCloneVMPageBasic1::validatePage()84 {85 if (isFinalPage())86 {87 /* Try to create the clone: */88 startProcessing();89 bool fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();90 endProcessing();91 return fResult;92 }93 else94 return true;95 }96 97 QString UIWizardCloneVMPageBasic1::cloneName() const98 {99 return m_pNameEditor->text();100 }101 102 void UIWizardCloneVMPageBasic1::setCloneName(const QString &strName)103 {104 m_pNameEditor->setText(strName);105 }106 107 bool UIWizardCloneVMPageBasic1::isReinitMACsChecked() const108 {109 return m_pReinitMACsCheckBox->isChecked();110 }111 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.h
r40870 r41021 24 24 25 25 /* Forward declarations: */ 26 class Q IRichTextLabel;26 class QGroupBox; 27 27 class QLineEdit; 28 28 class QCheckBox; 29 class QIRichTextLabel; 29 30 30 /* 1st page of the Clone Virtual Machine wizard: */ 31 class UIWizardCloneVMPageBasic1 : public UIWizardPage 31 /* 1st page of the Clone Virtual Machine wizard (base part): */ 32 class UIWizardCloneVMPage1 : public UIWizardPageBase 33 { 34 protected: 35 36 /* Constructor: */ 37 UIWizardCloneVMPage1(const QString &strOriginalName); 38 39 /* Stuff for 'cloneName' field: */ 40 QString cloneName() const; 41 void setCloneName(const QString &strName); 42 43 /* Stuff for 'reinitMACs' field: */ 44 bool isReinitMACsChecked() const; 45 46 /* Variables: */ 47 QString m_strOriginalName; 48 49 /* Widgets: */ 50 QGroupBox *m_pNameCnt; 51 QLineEdit *m_pNameEditor; 52 QCheckBox *m_pReinitMACsCheckBox; 53 }; 54 55 /* 1st page of the Clone Virtual Machine wizard (basic extension): */ 56 class UIWizardCloneVMPageBasic1 : public UIWizardPage, public UIWizardCloneVMPage1 32 57 { 33 58 Q_OBJECT; … … 50 75 /* Validation stuff: */ 51 76 bool isComplete() const; 52 bool validatePage();53 54 /* Stuff for 'cloneName' field: */55 QString cloneName() const;56 void setCloneName(const QString &strName);57 58 /* Stuff for 'reinitMACs' field: */59 bool isReinitMACsChecked() const;60 61 /* Variables: */62 QString m_strOriginalName;63 77 64 78 /* Widgets: */ 65 79 QIRichTextLabel *m_pLabel1; 66 80 QIRichTextLabel *m_pLabel2; 67 QLineEdit *m_pNameEditor;68 QCheckBox *m_pReinitMACsCheckBox;69 81 }; 70 82 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic2.cpp
r40870 r41021 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QGroupBox> 22 23 #include <QRadioButton> 23 24 #include <QButtonGroup> … … 29 30 #include "QIRichTextLabel.h" 30 31 32 UIWizardCloneVMPage2::UIWizardCloneVMPage2(bool fAdditionalInfo) 33 : m_fAdditionalInfo(fAdditionalInfo) 34 { 35 } 36 37 bool UIWizardCloneVMPage2::isLinkedClone() const 38 { 39 return m_pLinkedCloneRadio->isChecked(); 40 } 41 31 42 UIWizardCloneVMPageBasic2::UIWizardCloneVMPageBasic2(bool fAdditionalInfo) 32 : m_fAdditionalInfo(fAdditionalInfo)43 : UIWizardCloneVMPage2(fAdditionalInfo) 33 44 { 34 45 /* Create widgets: */ 35 46 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 47 { 36 48 m_pLabel = new QIRichTextLabel(this); 37 m_pFullCloneRadio = new QRadioButton(this); 38 m_pFullCloneRadio->setChecked(true); 39 m_pLinkedCloneRadio = new QRadioButton(this); 40 pMainLayout->addWidget(m_pLabel); 41 pMainLayout->addWidget(m_pFullCloneRadio); 42 pMainLayout->addWidget(m_pLinkedCloneRadio); 43 pMainLayout->addStretch(); 44 45 /* Create button-group: */ 46 QButtonGroup *pButtonGroup = new QButtonGroup(this); 47 pButtonGroup->addButton(m_pFullCloneRadio); 48 pButtonGroup->addButton(m_pLinkedCloneRadio); 49 m_pCloneTypeCnt = new QGroupBox(this); 50 { 51 m_pButtonGroup = new QButtonGroup(m_pCloneTypeCnt); 52 { 53 QVBoxLayout *pCloneTypeCntLayout = new QVBoxLayout(m_pCloneTypeCnt); 54 { 55 m_pFullCloneRadio = new QRadioButton(m_pCloneTypeCnt); 56 { 57 m_pFullCloneRadio->setChecked(true); 58 } 59 m_pLinkedCloneRadio = new QRadioButton(m_pCloneTypeCnt); 60 pCloneTypeCntLayout->addWidget(m_pFullCloneRadio); 61 pCloneTypeCntLayout->addWidget(m_pLinkedCloneRadio); 62 } 63 m_pButtonGroup->addButton(m_pFullCloneRadio); 64 m_pButtonGroup->addButton(m_pLinkedCloneRadio); 65 } 66 } 67 pMainLayout->addWidget(m_pLabel); 68 pMainLayout->addWidget(m_pCloneTypeCnt); 69 pMainLayout->addStretch(); 70 } 49 71 50 72 /* Setup connections: */ 51 connect( pButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));73 connect(m_pButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(sltButtonClicked(QAbstractButton *))); 52 74 53 75 /* Register fields: */ … … 55 77 } 56 78 57 void UIWizardCloneVMPageBasic2:: buttonClicked(QAbstractButton *pButton)79 void UIWizardCloneVMPageBasic2::sltButtonClicked(QAbstractButton *pButton) 58 80 { 59 81 setFinalPage(pButton != m_pFullCloneRadio); … … 72 94 73 95 /* Translate widgets: */ 74 m_pFullCloneRadio->setText(UIWizardCloneVM::tr("Full Clone"));75 m_pLinkedCloneRadio->setText(UIWizardCloneVM::tr("Linked Clone"));76 77 /* Set label text: */78 96 QString strLabel = UIWizardCloneVM::tr("<p>Please select the type of the clone.</p><p>If you choose <b>Full Clone</b> an exact copy " 79 97 "(including all virtual disk images) of the original VM will be created. If you select <b>Linked Clone</b>, " … … 82 100 strLabel += UIWizardCloneVM::tr("<p>Note that a new snapshot within the source VM is created in case you select <b>Linked Clone</b>.</p>"); 83 101 m_pLabel->setText(strLabel); 102 103 m_pCloneTypeCnt->setTitle(UIWizardCloneVM::tr("&Type")); 104 m_pFullCloneRadio->setText(UIWizardCloneVM::tr("Full Clone")); 105 m_pLinkedCloneRadio->setText(UIWizardCloneVM::tr("Linked Clone")); 84 106 } 85 107 … … 92 114 bool UIWizardCloneVMPageBasic2::validatePage() 93 115 { 116 /* This page could be final: */ 94 117 if (isFinalPage()) 95 118 { 96 /* Try to create the clone: */ 119 /* Initial result: */ 120 bool fResult = true; 121 122 /* Lock finish button: */ 97 123 startProcessing(); 98 bool fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM(); 124 125 /* Trying to clone VM: */ 126 if (fResult) 127 fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM(); 128 129 /* Unlock finish button: */ 99 130 endProcessing(); 131 132 /* Return result: */ 100 133 return fResult; 101 134 } … … 109 142 } 110 143 111 bool UIWizardCloneVMPageBasic2::isLinkedClone() const112 {113 return m_pLinkedCloneRadio->isChecked();114 }115 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic2.h
r40870 r41021 24 24 25 25 /* Forward declarations: */ 26 class QGroupBox; 27 class QButtonGroup; 28 class QRadioButton; 26 29 class QIRichTextLabel; 27 class QRadioButton;28 30 29 /* 2nd page of the Clone Virtual Machine wizard: */ 30 class UIWizardCloneVMPageBasic2 : public UIWizardPage 31 /* 2nd page of the Clone Virtual Machine wizard (base part): */ 32 class UIWizardCloneVMPage2 : public UIWizardPageBase 33 { 34 protected: 35 36 /* Constructor: */ 37 UIWizardCloneVMPage2(bool fAdditionalInfo); 38 39 /* Stuff for 'linkedClone' field: */ 40 bool isLinkedClone() const; 41 42 /* Variables: */ 43 bool m_fAdditionalInfo; 44 45 /* Widgets: */ 46 QGroupBox *m_pCloneTypeCnt; 47 QButtonGroup *m_pButtonGroup; 48 QRadioButton *m_pFullCloneRadio; 49 QRadioButton *m_pLinkedCloneRadio; 50 }; 51 52 /* 2nd page of the Clone Virtual Machine wizard (basic extension): */ 53 class UIWizardCloneVMPageBasic2 : public UIWizardPage, public UIWizardCloneVMPage2 31 54 { 32 55 Q_OBJECT; … … 41 64 42 65 /* Button click handler: */ 43 void buttonClicked(QAbstractButton *pButton);66 void sltButtonClicked(QAbstractButton *pButton); 44 67 45 68 private: … … 57 80 int nextId() const; 58 81 59 /* Stuff for 'linkedClone' field: */60 bool isLinkedClone() const;61 62 /* Variables: */63 bool m_fAdditionalInfo;64 65 82 /* Widgets: */ 66 83 QIRichTextLabel *m_pLabel; 67 QRadioButton *m_pFullCloneRadio;68 QRadioButton *m_pLinkedCloneRadio;69 84 }; 70 85 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic3.cpp
r40870 r41021 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QGroupBox> 22 23 #include <QRadioButton> 23 24 … … 27 28 #include "QIRichTextLabel.h" 28 29 29 UIWizardCloneVMPage Basic3::UIWizardCloneVMPageBasic3(bool fShowChildsOption /* = true */)30 UIWizardCloneVMPage3::UIWizardCloneVMPage3(bool fShowChildsOption) 30 31 : m_fShowChildsOption(fShowChildsOption) 32 { 33 } 34 35 KCloneMode UIWizardCloneVMPage3::cloneMode() const 36 { 37 if (m_pMachineAndChildsRadio->isChecked()) 38 return KCloneMode_MachineAndChildStates; 39 else if (m_pAllRadio->isChecked()) 40 return KCloneMode_AllStates; 41 return KCloneMode_MachineState; 42 } 43 44 void UIWizardCloneVMPage3::setCloneMode(KCloneMode cloneMode) 45 { 46 switch (cloneMode) 47 { 48 case KCloneMode_MachineState: m_pMachineRadio->setChecked(true); break; 49 case KCloneMode_MachineAndChildStates: m_pMachineAndChildsRadio->setChecked(true); break; 50 case KCloneMode_AllStates: m_pAllRadio->setChecked(true); break; 51 } 52 } 53 54 UIWizardCloneVMPageBasic3::UIWizardCloneVMPageBasic3(bool fShowChildsOption) 55 : UIWizardCloneVMPage3(fShowChildsOption) 31 56 { 32 57 /* Create widgets: */ 33 58 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 59 { 34 60 m_pLabel = new QIRichTextLabel(this); 35 m_pMachineRadio = new QRadioButton(this); 36 m_pMachineRadio->setChecked(true); 37 m_pMachineAndChildsRadio = new QRadioButton(this); 38 if (!m_fShowChildsOption) 39 m_pMachineAndChildsRadio->hide(); 40 m_pAllRadio = new QRadioButton(this); 41 pMainLayout->addWidget(m_pLabel); 42 pMainLayout->addWidget(m_pMachineRadio); 43 pMainLayout->addWidget(m_pMachineAndChildsRadio); 44 pMainLayout->addWidget(m_pAllRadio); 45 pMainLayout->addStretch(); 61 m_pCloneModeCnt = new QGroupBox(this); 62 { 63 QVBoxLayout *pCloneModeCntLayout = new QVBoxLayout(m_pCloneModeCnt); 64 { 65 m_pMachineRadio = new QRadioButton(m_pCloneModeCnt); 66 { 67 m_pMachineRadio->setChecked(true); 68 } 69 m_pMachineAndChildsRadio = new QRadioButton(m_pCloneModeCnt); 70 { 71 if (!m_fShowChildsOption) 72 m_pMachineAndChildsRadio->hide(); 73 } 74 m_pAllRadio = new QRadioButton(m_pCloneModeCnt); 75 pCloneModeCntLayout->addWidget(m_pMachineRadio); 76 pCloneModeCntLayout->addWidget(m_pMachineAndChildsRadio); 77 pCloneModeCntLayout->addWidget(m_pAllRadio); 78 } 79 } 80 pMainLayout->addWidget(m_pLabel); 81 pMainLayout->addWidget(m_pCloneModeCnt); 82 pMainLayout->addStretch(); 83 } 46 84 47 /* Register KCloneMode class: */85 /* Register classes: */ 48 86 qRegisterMetaType<KCloneMode>(); 87 /* Register fields: */ 49 88 registerField("cloneMode", this, "cloneMode"); 50 89 } … … 56 95 57 96 /* Translate widgets: */ 58 m_pMachineRadio->setText(UIWizardCloneVM::tr("Current machine state"));59 m_pMachineAndChildsRadio->setText(UIWizardCloneVM::tr("Current machine and all child states"));60 m_pAllRadio->setText(UIWizardCloneVM::tr("All states"));61 62 97 const QString strGeneral = UIWizardCloneVM::tr("Please choose which parts of the virtual machine should be cloned."); 63 98 const QString strOpt1 = UIWizardCloneVM::tr("If you select <b>Current machine state</b>, only the current state " … … 78 113 .arg(strOpt1) 79 114 .arg(strOpt3)); 115 116 m_pCloneModeCnt->setTitle(UIWizardCloneVM::tr("&Mode")); 117 m_pMachineRadio->setText(UIWizardCloneVM::tr("Current machine state")); 118 m_pMachineAndChildsRadio->setText(UIWizardCloneVM::tr("Current machine and all child states")); 119 m_pAllRadio->setText(UIWizardCloneVM::tr("All states")); 80 120 } 81 121 … … 88 128 bool UIWizardCloneVMPageBasic3::validatePage() 89 129 { 130 /* Initial result: */ 131 bool fResult = true; 132 133 /* Lock finish button: */ 134 startProcessing(); 135 90 136 /* Try to clone VM: */ 91 startProcessing(); 92 bool fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM(); 137 if (fResult) 138 fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM(); 139 140 /* Unlock finish button: */ 93 141 endProcessing(); 142 143 /* Return result: */ 94 144 return fResult; 95 145 } 96 146 97 KCloneMode UIWizardCloneVMPageBasic3::cloneMode() const98 {99 if (m_pMachineAndChildsRadio->isChecked())100 return KCloneMode_MachineAndChildStates;101 else if (m_pAllRadio->isChecked())102 return KCloneMode_AllStates;103 return KCloneMode_MachineState;104 }105 106 void UIWizardCloneVMPageBasic3::setCloneMode(KCloneMode cloneMode)107 {108 switch (cloneMode)109 {110 case KCloneMode_MachineState: m_pMachineRadio->setChecked(true); break;111 case KCloneMode_MachineAndChildStates: m_pMachineAndChildsRadio->setChecked(true); break;112 case KCloneMode_AllStates: m_pAllRadio->setChecked(true); break;113 }114 }115 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic3.h
r40870 r41021 25 25 26 26 /* Forward declaration: */ 27 class QGroupBox; 28 class QRadioButton; 27 29 class QIRichTextLabel; 28 class QRadioButton;29 30 30 /* 3rd page of the Clone Virtual Machine wizard: */ 31 class UIWizardCloneVMPageBasic3 : public UIWizardPage 31 /* 3rd page of the Clone Virtual Machine wizard (base part): */ 32 class UIWizardCloneVMPage3 : public UIWizardPageBase 33 { 34 protected: 35 36 /* Constructor: */ 37 UIWizardCloneVMPage3(bool fShowChildsOption); 38 39 /* Stuff for 'cloneMode' field: */ 40 KCloneMode cloneMode() const; 41 void setCloneMode(KCloneMode cloneMode); 42 43 /* Variables: */ 44 bool m_fShowChildsOption; 45 46 /* Widgets: */ 47 QGroupBox *m_pCloneModeCnt; 48 QRadioButton *m_pMachineRadio; 49 QRadioButton *m_pMachineAndChildsRadio; 50 QRadioButton *m_pAllRadio; 51 }; 52 53 /* 3rd page of the Clone Virtual Machine wizard (basic extension): */ 54 class UIWizardCloneVMPageBasic3 : public UIWizardPage, public UIWizardCloneVMPage3 32 55 { 33 56 Q_OBJECT; … … 37 60 38 61 /* Constructor: */ 39 UIWizardCloneVMPageBasic3(bool fShowChildsOption = true);62 UIWizardCloneVMPageBasic3(bool fShowChildsOption); 40 63 41 64 private: … … 50 73 bool validatePage(); 51 74 52 /* Stuff for 'cloneMode' field: */53 KCloneMode cloneMode() const;54 void setCloneMode(KCloneMode cloneMode);55 56 /* Variables: */57 bool m_fShowChildsOption;58 59 75 /* Widgets: */ 60 76 QIRichTextLabel *m_pLabel; 61 QRadioButton *m_pMachineRadio;62 QRadioButton *m_pMachineAndChildsRadio;63 QRadioButton *m_pAllRadio;64 77 }; 65 78 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.cpp
r40929 r41021 3 3 * 4 4 * VBox frontends: Qt4 GUI ("VirtualBox"): 5 * UIWizardCloneVMPage Basic1class implementation5 * UIWizardCloneVMPageExpert class implementation 6 6 */ 7 7 … … 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QButtonGroup> 23 #include <QGroupBox> 22 24 #include <QLineEdit> 23 25 #include <QCheckBox> 26 #include <QRadioButton> 24 27 25 28 /* Local includes: */ 26 #include "UIWizardCloneVMPage Basic1.h"29 #include "UIWizardCloneVMPageExpert.h" 27 30 #include "UIWizardCloneVM.h" 28 #include "COMDefs.h"29 #include "QIRichTextLabel.h"30 31 31 UIWizardCloneVMPageBasic1::UIWizardCloneVMPageBasic1(const QString &strOriginalName) 32 : m_strOriginalName(strOriginalName) 32 UIWizardCloneVMPageExpert::UIWizardCloneVMPageExpert(const QString &strOriginalName, bool fAdditionalInfo, bool fShowChildsOption) 33 : UIWizardCloneVMPage1(strOriginalName) 34 , UIWizardCloneVMPage2(fAdditionalInfo) 35 , UIWizardCloneVMPage3(fShowChildsOption) 33 36 { 34 37 /* Create widgets: */ 35 38 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 36 m_pLabel1 = new QIRichTextLabel(this); 37 m_pLabel2 = new QIRichTextLabel(this); 38 m_pNameEditor = new QLineEdit(this); 39 m_pNameEditor->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName)); 39 { 40 pMainLayout->setContentsMargins(8, 6, 8, 6); 41 m_pNameCnt = new QGroupBox(this); 42 { 43 QVBoxLayout *pNameCntLayout = new QVBoxLayout(m_pNameCnt); 44 { 45 m_pNameEditor = new QLineEdit(m_pNameCnt); 46 { 47 m_pNameEditor->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName)); 48 } 49 pNameCntLayout->addWidget(m_pNameEditor); 50 } 51 } 52 m_pCloneTypeCnt = new QGroupBox(this); 53 { 54 m_pButtonGroup = new QButtonGroup(m_pCloneTypeCnt); 55 { 56 QVBoxLayout *pCloneTypeCntLayout = new QVBoxLayout(m_pCloneTypeCnt); 57 { 58 m_pFullCloneRadio = new QRadioButton(m_pCloneTypeCnt); 59 { 60 m_pFullCloneRadio->setChecked(true); 61 } 62 m_pLinkedCloneRadio = new QRadioButton(m_pCloneTypeCnt); 63 pCloneTypeCntLayout->addWidget(m_pFullCloneRadio); 64 pCloneTypeCntLayout->addWidget(m_pLinkedCloneRadio); 65 } 66 m_pButtonGroup->addButton(m_pFullCloneRadio); 67 m_pButtonGroup->addButton(m_pLinkedCloneRadio); 68 } 69 } 70 m_pCloneModeCnt = new QGroupBox(this); 71 { 72 QVBoxLayout *pCloneModeCntLayout = new QVBoxLayout(m_pCloneModeCnt); 73 { 74 m_pMachineRadio = new QRadioButton(m_pCloneModeCnt); 75 { 76 m_pMachineRadio->setChecked(true); 77 } 78 m_pMachineAndChildsRadio = new QRadioButton(m_pCloneModeCnt); 79 { 80 if (!m_fShowChildsOption) 81 m_pMachineAndChildsRadio->hide(); 82 } 83 m_pAllRadio = new QRadioButton(m_pCloneModeCnt); 84 pCloneModeCntLayout->addWidget(m_pMachineRadio); 85 pCloneModeCntLayout->addWidget(m_pMachineAndChildsRadio); 86 pCloneModeCntLayout->addWidget(m_pAllRadio); 87 } 88 } 40 89 m_pReinitMACsCheckBox = new QCheckBox(this); 41 pMainLayout->addWidget(m_pLabel1); 42 pMainLayout->addWidget(m_pLabel2); 43 pMainLayout->addWidget(m_pNameEditor); 44 pMainLayout->addWidget(m_pReinitMACsCheckBox); 45 pMainLayout->addStretch(); 90 pMainLayout->addWidget(m_pNameCnt); 91 pMainLayout->addWidget(m_pCloneTypeCnt); 92 pMainLayout->addWidget(m_pCloneModeCnt); 93 pMainLayout->addWidget(m_pReinitMACsCheckBox); 94 pMainLayout->addStretch(); 95 sltButtonClicked(m_pFullCloneRadio); 96 } 46 97 47 98 /* Setup connections: */ 48 connect(m_pNameEditor, SIGNAL(textChanged(const QString&)), this, SIGNAL(completeChanged())); 99 connect(m_pNameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged())); 100 connect(m_pButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(sltButtonClicked(QAbstractButton *))); 49 101 102 /* Register classes: */ 103 qRegisterMetaType<KCloneMode>(); 50 104 /* Register fields: */ 51 105 registerField("cloneName", this, "cloneName"); 52 106 registerField("reinitMACs", this, "reinitMACs"); 107 registerField("linkedClone", this, "linkedClone"); 108 registerField("cloneMode", this, "cloneMode"); 53 109 } 54 110 55 void UIWizardCloneVMPage Basic1::retranslateUi()111 void UIWizardCloneVMPageExpert::sltButtonClicked(QAbstractButton *pButton) 56 112 { 57 /* Translate page: */ 58 setTitle(UIWizardCloneVM::tr("Welcome to the virtual machine clone wizard")); 113 /* Enabled/disable mode container: */ 114 m_pCloneModeCnt->setEnabled(pButton == m_pFullCloneRadio); 115 } 59 116 117 void UIWizardCloneVMPageExpert::retranslateUi() 118 { 60 119 /* Translate widgets: */ 61 m_pLabel1->setText(UIWizardCloneVM::tr("<p>This wizard will help you to create a clone of your virtual machine.</p>")); 62 m_pLabel2->setText(UIWizardCloneVM::tr("<p>Please choose a name for the new virtual machine:</p>")); 120 m_pNameCnt->setTitle(UIWizardCloneVM::tr("&Name")); 121 m_pCloneTypeCnt->setTitle(UIWizardCloneVM::tr("&Type")); 122 m_pFullCloneRadio->setText(UIWizardCloneVM::tr("Full Clone")); 123 m_pLinkedCloneRadio->setText(UIWizardCloneVM::tr("Linked Clone")); 124 m_pCloneModeCnt->setTitle(UIWizardCloneVM::tr("&Mode")); 125 m_pMachineRadio->setText(UIWizardCloneVM::tr("Current machine state")); 126 m_pMachineAndChildsRadio->setText(UIWizardCloneVM::tr("Current machine and all child states")); 127 m_pAllRadio->setText(UIWizardCloneVM::tr("All states")); 63 128 m_pReinitMACsCheckBox->setToolTip(UIWizardCloneVM::tr("When checked a new unique MAC address will be assigned to all configured network cards.")); 64 129 m_pReinitMACsCheckBox->setText(UIWizardCloneVM::tr("&Reinitialize the MAC address of all network cards")); 65 66 /* Append page text with common part: */67 QString strCommonPart = QString("<p>%1</p>").arg(standardHelpText());68 m_pLabel1->setText(m_pLabel1->text() + strCommonPart);69 130 } 70 131 71 void UIWizardCloneVMPage Basic1::initializePage()132 void UIWizardCloneVMPageExpert::initializePage() 72 133 { 73 134 /* Translate page: */ … … 75 136 } 76 137 77 bool UIWizardCloneVMPage Basic1::isComplete() const138 bool UIWizardCloneVMPageExpert::isComplete() const 78 139 { 140 /* Make sure VM name feat the rules: */ 79 141 QString strName = m_pNameEditor->text().trimmed(); 80 142 return !strName.isEmpty() && strName != m_strOriginalName; 81 143 } 82 144 83 bool UIWizardCloneVMPage Basic1::validatePage()145 bool UIWizardCloneVMPageExpert::validatePage() 84 146 { 85 if (isFinalPage()) 86 { 87 /* Try to create the clone: */ 88 startProcessing(); 89 bool fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM(); 90 endProcessing(); 91 return fResult; 92 } 93 else 94 return true; 147 /* Initial result: */ 148 bool fResult = true; 149 150 /* Lock finish button: */ 151 startProcessing(); 152 153 /* Trying to clone VM: */ 154 if (fResult) 155 fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM(); 156 157 /* Unlock finish button: */ 158 endProcessing(); 159 160 /* Return result: */ 161 return fResult; 95 162 } 96 163 97 QString UIWizardCloneVMPageBasic1::cloneName() const98 {99 return m_pNameEditor->text();100 }101 102 void UIWizardCloneVMPageBasic1::setCloneName(const QString &strName)103 {104 m_pNameEditor->setText(strName);105 }106 107 bool UIWizardCloneVMPageBasic1::isReinitMACsChecked() const108 {109 return m_pReinitMACsCheckBox->isChecked();110 }111 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.h
r40929 r41021 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * UIWizardCloneVMPage Basic1class declaration4 * UIWizardCloneVMPageExpert class declaration 5 5 */ 6 6 … … 17 17 */ 18 18 19 #ifndef __UIWizardCloneVMPage Basic1_h__20 #define __UIWizardCloneVMPage Basic1_h__19 #ifndef __UIWizardCloneVMPageExpert_h__ 20 #define __UIWizardCloneVMPageExpert_h__ 21 21 22 22 /* Local includes: */ 23 #include "UIWizardPage.h" 23 #include "UIWizardCloneVMPageBasic1.h" 24 #include "UIWizardCloneVMPageBasic2.h" 25 #include "UIWizardCloneVMPageBasic3.h" 24 26 25 /* Forward declarations: */ 26 class QIRichTextLabel; 27 class QLineEdit; 28 class QCheckBox; 29 30 /* 1st page of the Clone Virtual Machine wizard: */ 31 class UIWizardCloneVMPageBasic1 : public UIWizardPage 27 /* Expert page of the Clone Virtual Machine wizard: */ 28 class UIWizardCloneVMPageExpert : public UIWizardPage, 29 public UIWizardCloneVMPage1, 30 public UIWizardCloneVMPage2, 31 public UIWizardCloneVMPage3 32 32 { 33 33 Q_OBJECT; 34 34 Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName); 35 35 Q_PROPERTY(bool reinitMACs READ isReinitMACsChecked); 36 Q_PROPERTY(bool linkedClone READ isLinkedClone); 37 Q_PROPERTY(KCloneMode cloneMode READ cloneMode WRITE setCloneMode); 36 38 37 39 public: 38 40 39 41 /* Constructor: */ 40 UIWizardCloneVMPageBasic1(const QString &strOriginalName); 42 UIWizardCloneVMPageExpert(const QString &strOriginalName, bool fAdditionalInfo, bool fShowChildsOption); 43 44 private slots: 45 46 /* Button click handler: */ 47 void sltButtonClicked(QAbstractButton *pButton); 41 48 42 49 private: … … 51 58 bool isComplete() const; 52 59 bool validatePage(); 53 54 /* Stuff for 'cloneName' field: */55 QString cloneName() const;56 void setCloneName(const QString &strName);57 58 /* Stuff for 'reinitMACs' field: */59 bool isReinitMACsChecked() const;60 61 /* Variables: */62 QString m_strOriginalName;63 64 /* Widgets: */65 QIRichTextLabel *m_pLabel1;66 QIRichTextLabel *m_pLabel2;67 QLineEdit *m_pNameEditor;68 QCheckBox *m_pReinitMACsCheckBox;69 60 }; 70 61 71 #endif // __UIWizardCloneVMPage Basic1_h__62 #endif // __UIWizardCloneVMPageExpert_h__ 72 63 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportApp.cpp
r40870 r41021 29 29 #include "UIWizardExportAppPageBasic3.h" 30 30 #include "UIWizardExportAppPageBasic4.h" 31 #include "UIWizardExportAppPageExpert.h" 31 32 #include "COMDefs.h" 32 33 #include "UIMessageCenter.h" 33 34 34 35 UIWizardExportApp::UIWizardExportApp(QWidget *pParent, const QStringList &selectedVMNames) 35 : UIWizard(pParent) 36 { 37 /* Create & add pages */ 38 setPage(Page1, new UIWizardExportAppPageBasic1(selectedVMNames)); 39 setPage(Page2, new UIWizardExportAppPageBasic2); 40 setPage(Page3, new UIWizardExportAppPageBasic3); 41 setPage(Page4, new UIWizardExportAppPageBasic4); 42 43 /* Translate wizard: */ 44 retranslateUi(); 45 46 /* Translate wizard pages: */ 47 retranslateAllPages(); 48 36 : UIWizard(pParent, UIWizardType_ExportAppliance) 37 , m_selectedVMNames(selectedVMNames) 38 { 49 39 #ifndef Q_WS_MAC 50 40 /* Assign watermark: */ … … 54 44 assignBackground(":/vmw_ovf_export_bg.png"); 55 45 #endif /* Q_WS_MAC */ 56 57 /* Resize wizard to 'golden ratio': */58 resizeToGoldenRatio(UIWizardType_ExportAppliance);59 60 /* Setup connections: */61 AssertMsg(!field("applianceWidget").value<ExportAppliancePointer>().isNull(), ("Appliance Widget is not set!\n"));62 connect(this, SIGNAL(customButtonClicked(int)), field("applianceWidget").value<ExportAppliancePointer>(), SLOT(restoreDefaults()));63 connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(sltCurrentIdChanged(int)));64 46 } 65 47 … … 219 201 } 220 202 203 void UIWizardExportApp::sltCurrentIdChanged(int iId) 204 { 205 /* Call to base-class: */ 206 UIWizard::sltCurrentIdChanged(iId); 207 /* Enable 2nd button (Reset to Defaults) for 4th and Expert pages only! */ 208 setOption(QWizard::HaveCustomButton2, (mode() == UIWizardMode_Basic && iId == Page4) || 209 (mode() == UIWizardMode_Expert && iId == PageExpert)); 210 } 211 212 void UIWizardExportApp::sltCustomButtonClicked(int iId) 213 { 214 /* Call to base-class: */ 215 UIWizard::sltCustomButtonClicked(iId); 216 217 /* Handle 2nd button: */ 218 if (iId == CustomButton2) 219 { 220 /* Get appliance widget: */ 221 ExportAppliancePointer pApplianceWidget = field("applianceWidget").value<ExportAppliancePointer>(); 222 AssertMsg(!pApplianceWidget.isNull(), ("Appliance Widget is not set!\n")); 223 /* Reset it to default: */ 224 pApplianceWidget->restoreDefaults(); 225 } 226 } 227 221 228 void UIWizardExportApp::retranslateUi() 222 229 { 230 /* Call to base-class: */ 231 UIWizard::retranslateUi(); 232 223 233 /* Translate wizard: */ 224 234 setWindowTitle(tr("Appliance Export Wizard")); 225 setButtonText(QWizard::CustomButton 1, tr("Restore Defaults"));235 setButtonText(QWizard::CustomButton2, tr("Restore Defaults")); 226 236 setButtonText(QWizard::FinishButton, tr("Export")); 227 237 } 228 238 229 void UIWizardExportApp::sltCurrentIdChanged(int iId) 230 { 231 setOption(QWizard::HaveCustomButton1, iId == Page4); 232 } 233 239 void UIWizardExportApp::prepare() 240 { 241 /* Create corresponding pages: */ 242 switch (mode()) 243 { 244 case UIWizardMode_Basic: 245 { 246 setPage(Page1, new UIWizardExportAppPageBasic1(m_selectedVMNames)); 247 setPage(Page2, new UIWizardExportAppPageBasic2); 248 setPage(Page3, new UIWizardExportAppPageBasic3); 249 setPage(Page4, new UIWizardExportAppPageBasic4); 250 break; 251 } 252 case UIWizardMode_Expert: 253 { 254 setPage(PageExpert, new UIWizardExportAppPageExpert(m_selectedVMNames)); 255 break; 256 } 257 } 258 /* Call to base-class: */ 259 UIWizard::prepare(); 260 } 261 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportApp.h
r40870 r41021 42 42 }; 43 43 44 /* Page IDs: */ 45 enum 46 { 47 PageExpert 48 }; 49 44 50 /* Constructor: */ 45 51 UIWizardExportApp(QWidget *pParent, const QStringList &selectedVMNames = QStringList()); … … 53 59 54 60 /* Who will be able to export appliance: */ 61 friend class UIWizardExportAppPage4; 55 62 friend class UIWizardExportAppPageBasic4; 63 friend class UIWizardExportAppPageExpert; 56 64 57 65 private slots: … … 59 67 /* Page change handler: */ 60 68 void sltCurrentIdChanged(int iId); 69 /* Custom button 2 click handler: */ 70 void sltCustomButtonClicked(int iId); 61 71 62 72 private: … … 64 74 /* Translation stuff: */ 65 75 void retranslateUi(); 76 77 /* Pages related stuff: */ 78 void prepare(); 79 80 /* Variables: */ 81 QStringList m_selectedVMNames; 66 82 }; 67 83 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppDefs.h
r40870 r41021 23 23 #include <QMetaType> 24 24 #include <QPointer> 25 #include <QListWidget> 25 26 26 27 /* Local includes: */ … … 35 36 Q_DECLARE_METATYPE(ExportAppliancePointer); 36 37 38 class VMListWidgetItem : public QListWidgetItem 39 { 40 public: 41 42 VMListWidgetItem(QPixmap &pixIcon, QString &strText, QString strUuid, bool fInSaveState, QListWidget *pParent) 43 : QListWidgetItem(pixIcon, strText, pParent) 44 , m_strUuid(strUuid) 45 , m_fInSaveState(fInSaveState) 46 { 47 } 48 49 bool operator<(const QListWidgetItem &other) const 50 { 51 return text().toLower() < other.text().toLower(); 52 } 53 54 QString uuid() { return m_strUuid; } 55 bool isInSaveState() { return m_fInSaveState; } 56 57 private: 58 59 QString m_strUuid; 60 bool m_fInSaveState; 61 }; 62 37 63 #endif /* __UIWizardExportAppDefs_h__ */ 38 64 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic1.cpp
r40870 r41021 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QListWidget>23 22 24 23 /* Local includes: */ 25 24 #include "UIWizardExportAppPageBasic1.h" 26 25 #include "UIWizardExportApp.h" 26 #include "UIWizardExportAppDefs.h" 27 27 #include "VBoxGlobal.h" 28 28 #include "UIMessageCenter.h" 29 #include "QILabelSeparator.h" 29 30 #include "QIRichTextLabel.h" 30 31 31 class VMListWidgetItems : public QListWidgetItem 32 UIWizardExportAppPage1::UIWizardExportAppPage1() 32 33 { 33 public:34 35 VMListWidgetItems(QPixmap &pixIcon, QString &strText, QString strUuid, bool fInSaveState, QListWidget *pParent)36 : QListWidgetItem(pixIcon, strText, pParent)37 , m_strUuid(strUuid)38 , m_fInSaveState(fInSaveState)39 {40 }41 42 bool operator<(const QListWidgetItem &other) const43 {44 return text().toLower() < other.text().toLower();45 }46 47 QString uuid() { return m_strUuid; }48 bool isInSaveState() { return m_fInSaveState; }49 50 private:51 52 QString m_strUuid;53 bool m_fInSaveState;54 };55 56 UIWizardExportAppPageBasic1::UIWizardExportAppPageBasic1(const QStringList &selectedVMNames)57 : m_selectedVMNames(selectedVMNames)58 {59 /* Create widgets: */60 QVBoxLayout *pMainLayout = new QVBoxLayout(this);61 m_pLabel = new QIRichTextLabel(this);62 m_pVMSelector = new QListWidget(this);63 m_pVMSelector->setAlternatingRowColors(true);64 m_pVMSelector->setSelectionMode(QAbstractItemView::ExtendedSelection);65 populateVMSelectorItems();66 pMainLayout->addWidget(m_pLabel);67 pMainLayout->addWidget(m_pVMSelector);68 69 /* Choose initially selected items (if passed): */70 for (int i = 0; i < m_selectedVMNames.size(); ++i)71 {72 QList<QListWidgetItem*> list = m_pVMSelector->findItems(m_selectedVMNames[i], Qt::MatchExactly);73 if (list.size() > 0)74 {75 if (m_pVMSelector->selectedItems().isEmpty())76 m_pVMSelector->setCurrentItem(list.first());77 else78 list.first()->setSelected(true);79 }80 }81 82 /* Setup connections: */83 connect(m_pVMSelector, SIGNAL(itemSelectionChanged()), this, SIGNAL(completeChanged()));84 85 /* Register 'machineNames', 'machineIDs' fields! */86 registerField("machineNames", this, "machineNames");87 registerField("machineIDs", this, "machineIDs");88 34 } 89 35 90 void UIWizardExportAppPageBasic1::retranslateUi() 91 { 92 /* Translate page: */ 93 setTitle(UIWizardExportApp::tr("Welcome to the Appliance Export Wizard!")); 94 95 /* Translate widgets: */ 96 m_pLabel->setText(UIWizardExportApp::tr("<p>This wizard will guide you through the process of " 97 "exporting an appliance.</p><p>%1</p><p>Please select " 98 "the virtual machines that should be added to the " 99 "appliance. You can select more than one. Please note " 100 "that these machines have to be turned off before they " 101 "can be exported.</p>") 102 .arg(standardHelpText())); 103 } 104 105 void UIWizardExportAppPageBasic1::initializePage() 106 { 107 /* Translate page: */ 108 retranslateUi(); 109 } 110 111 bool UIWizardExportAppPageBasic1::isComplete() const 112 { 113 /* There should be at least one vm selected! */ 114 return m_pVMSelector->selectedItems().size() > 0; 115 } 116 117 bool UIWizardExportAppPageBasic1::validatePage() 118 { 119 /* Ask user machines which are in save state currently. */ 120 QStringList savedMachines; 121 QList<QListWidgetItem*> pItems = m_pVMSelector->selectedItems(); 122 for (int i=0; i < pItems.size(); ++i) 123 { 124 if (static_cast<VMListWidgetItems*>(pItems.at(i))->isInSaveState()) 125 savedMachines << pItems.at(i)->text(); 126 } 127 128 if (!savedMachines.isEmpty()) 129 return msgCenter().confirmExportMachinesInSaveState(savedMachines, this); 130 131 return true; 132 } 133 134 int UIWizardExportAppPageBasic1::nextId() const 135 { 136 /* Skip next (2nd, Storage-type) page for now! */ 137 return UIWizardExportApp::Page3; 138 } 139 140 void UIWizardExportAppPageBasic1::populateVMSelectorItems() 36 void UIWizardExportAppPage1::populateVMSelectorItems(const QStringList &selectedVMNames) 141 37 { 142 38 /* Add all VM items into 'VM Selector': */ … … 163 59 pixIcon = QPixmap(":/os_other.png").scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 164 60 } 165 QListWidgetItem *pItem = new VMListWidgetItem s(pixIcon, strName, strUuid, fInSaveState, m_pVMSelector);61 QListWidgetItem *pItem = new VMListWidgetItem(pixIcon, strName, strUuid, fInSaveState, m_pVMSelector); 166 62 if (!fEnabled) 167 63 pItem->setFlags(0); … … 169 65 } 170 66 m_pVMSelector->sortItems(); 67 68 /* Choose initially selected items (if passed): */ 69 for (int i = 0; i < selectedVMNames.size(); ++i) 70 { 71 QList<QListWidgetItem*> list = m_pVMSelector->findItems(selectedVMNames[i], Qt::MatchExactly); 72 if (list.size() > 0) 73 { 74 if (m_pVMSelector->selectedItems().isEmpty()) 75 m_pVMSelector->setCurrentItem(list.first()); 76 else 77 list.first()->setSelected(true); 78 } 79 } 171 80 } 172 81 173 QStringList UIWizardExportAppPage Basic1::machineNames() const82 QStringList UIWizardExportAppPage1::machineNames() const 174 83 { 175 84 /* Prepare list: */ … … 182 91 } 183 92 184 QStringList UIWizardExportAppPage Basic1::machineIDs() const93 QStringList UIWizardExportAppPage1::machineIDs() const 185 94 { 186 95 /* Prepare list: */ … … 188 97 /* Iterate over all the selected items: */ 189 98 foreach (QListWidgetItem *pItem, m_pVMSelector->selectedItems()) 190 machineIDs << static_cast<VMListWidgetItem s*>(pItem)->uuid();99 machineIDs << static_cast<VMListWidgetItem*>(pItem)->uuid(); 191 100 /* Return result list: */ 192 101 return machineIDs; 193 102 } 194 103 104 UIWizardExportAppPageBasic1::UIWizardExportAppPageBasic1(const QStringList &selectedVMNames) 105 { 106 /* Create widgets: */ 107 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 108 { 109 m_pLabel = new QIRichTextLabel(this); 110 m_pVMSelectorLabel = new QILabelSeparator(this); 111 { 112 m_pVMSelectorLabel->hide(); 113 } 114 m_pVMSelector = new QListWidget(this); 115 { 116 m_pVMSelector->setAlternatingRowColors(true); 117 m_pVMSelector->setSelectionMode(QAbstractItemView::ExtendedSelection); 118 m_pVMSelectorLabel->setBuddy(m_pVMSelector); 119 } 120 pMainLayout->addWidget(m_pLabel); 121 pMainLayout->addWidget(m_pVMSelectorLabel); 122 pMainLayout->addWidget(m_pVMSelector); 123 populateVMSelectorItems(selectedVMNames); 124 } 125 126 /* Setup connections: */ 127 connect(m_pVMSelector, SIGNAL(itemSelectionChanged()), this, SIGNAL(completeChanged())); 128 129 /* Register fields: */ 130 registerField("machineNames", this, "machineNames"); 131 registerField("machineIDs", this, "machineIDs"); 132 } 133 134 void UIWizardExportAppPageBasic1::retranslateUi() 135 { 136 /* Translate page: */ 137 setTitle(UIWizardExportApp::tr("Welcome to the Appliance Export wizard!")); 138 139 /* Translate widgets: */ 140 m_pLabel->setText(UIWizardExportApp::tr("<p>This wizard will guide you through the process of " 141 "exporting an appliance.</p><p>%1</p><p>Please select " 142 "the virtual machines that should be added to the " 143 "appliance. You can select more than one. Please note " 144 "that these machines have to be turned off before they " 145 "can be exported.</p>") 146 .arg(standardHelpText())); 147 m_pVMSelectorLabel->setText(UIWizardExportApp::tr("VM &List")); 148 } 149 150 void UIWizardExportAppPageBasic1::initializePage() 151 { 152 /* Translate page: */ 153 retranslateUi(); 154 } 155 156 bool UIWizardExportAppPageBasic1::isComplete() const 157 { 158 /* There should be at least one vm selected: */ 159 return m_pVMSelector->selectedItems().size() > 0; 160 } 161 162 bool UIWizardExportAppPageBasic1::validatePage() 163 { 164 /* Initial result: */ 165 bool fResult = true; 166 167 /* Ask user about machines which are in save state currently: */ 168 QStringList savedMachines; 169 QList<QListWidgetItem*> pItems = m_pVMSelector->selectedItems(); 170 for (int i=0; i < pItems.size(); ++i) 171 { 172 if (static_cast<VMListWidgetItem*>(pItems.at(i))->isInSaveState()) 173 savedMachines << pItems.at(i)->text(); 174 } 175 if (!savedMachines.isEmpty()) 176 fResult = msgCenter().confirmExportMachinesInSaveState(savedMachines, this); 177 178 /* Return result: */ 179 return fResult; 180 } 181 182 int UIWizardExportAppPageBasic1::nextId() const 183 { 184 /* Skip next (2nd, storage-type) page for now! */ 185 return UIWizardExportApp::Page3; 186 } 187 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic1.h
r40870 r41021 24 24 25 25 /* Forward declarations: */ 26 class QILabelSeparator; 27 class QListWidget; 26 28 class QIRichTextLabel; 27 class QListWidget;28 29 29 /* 1st page of the Export Appliance wizard: */ 30 class UIWizardExportAppPageBasic1 : public UIWizardPage 30 /* 1st page of the Export Appliance wizard (base part): */ 31 class UIWizardExportAppPage1 : public UIWizardPageBase 32 { 33 protected: 34 35 /* Constructor: */ 36 UIWizardExportAppPage1(); 37 38 /* Helping stuff: */ 39 void populateVMSelectorItems(const QStringList &selectedVMNames); 40 41 /* Stuff for 'machineNames' field: */ 42 QStringList machineNames() const; 43 44 /* Stuff for 'machineIDs' field: */ 45 QStringList machineIDs() const; 46 47 /* Widgets: */ 48 QILabelSeparator *m_pVMSelectorLabel; 49 QListWidget *m_pVMSelector; 50 }; 51 52 /* 1st page of the Export Appliance wizard (basic extension): */ 53 class UIWizardExportAppPageBasic1 : public UIWizardPage, public UIWizardExportAppPage1 31 54 { 32 55 Q_OBJECT; … … 54 77 int nextId() const; 55 78 56 /* Helping stuff: */57 void populateVMSelectorItems();58 59 /* Stuff for 'machineNames' field: */60 QStringList machineNames() const;61 62 /* Stuff for 'machineIDs' field: */63 QStringList machineIDs() const;64 65 /* Variables: */66 QStringList m_selectedVMNames;67 68 79 /* Widgets: */ 69 80 QIRichTextLabel *m_pLabel; 70 QListWidget *m_pVMSelector;71 81 }; 72 82 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.cpp
r40870 r41021 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QGroupBox> 22 23 #include <QRadioButton> 23 24 … … 27 28 #include "QIRichTextLabel.h" 28 29 29 UIWizardExportAppPage Basic2::UIWizardExportAppPageBasic2()30 UIWizardExportAppPage2::UIWizardExportAppPage2() 30 31 { 31 /* Create widgets: */ 32 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 33 m_pLabel = new QIRichTextLabel(this); 34 m_pTypeLocalFilesystem = new QRadioButton(this); 35 m_pTypeSunCloud = new QRadioButton(this); 36 m_pTypeSimpleStorageSystem = new QRadioButton(this); 37 pMainLayout->addWidget(m_pLabel); 38 pMainLayout->addWidget(m_pTypeLocalFilesystem); 39 pMainLayout->addWidget(m_pTypeSunCloud); 40 pMainLayout->addWidget(m_pTypeSimpleStorageSystem); 41 pMainLayout->addStretch(); 32 } 42 33 34 void UIWizardExportAppPage2::chooseDefaultStorageType() 35 { 43 36 /* Select default storage type: */ 44 37 #if 0 … … 52 45 setStorageType(Filesystem); 53 46 #endif 54 55 /* Setup connections: */56 connect(m_pTypeLocalFilesystem, SIGNAL(clicked()), this, SIGNAL(completeChanged()));57 connect(m_pTypeSunCloud, SIGNAL(clicked()), this, SIGNAL(completeChanged()));58 connect(m_pTypeSimpleStorageSystem, SIGNAL(clicked()), this, SIGNAL(completeChanged()));59 60 /* Register StorageType class: */61 qRegisterMetaType<StorageType>();62 /* Register 'storageType' field! */63 registerField("storageType", this, "storageType");64 47 } 65 48 66 void UIWizardExportAppPageBasic2::retranslateUi() 67 { 68 /* Translate page: */ 69 setTitle(UIWizardExportApp::tr("Appliance Export Settings")); 70 71 /* Translate widgets: */ 72 m_pLabel->setText(UIWizardExportApp::tr("Please specify the target for the OVF export. " 73 "You can choose between a local file system export, " 74 "uploading the OVF to the Sun Cloud service " 75 "or an S3 storage server.")); 76 m_pTypeLocalFilesystem->setText(UIWizardExportApp::tr("&Local Filesystem ")); 77 m_pTypeSunCloud->setText(UIWizardExportApp::tr("Sun &Cloud")); 78 m_pTypeSimpleStorageSystem->setText(UIWizardExportApp::tr("&Simple Storage System (S3)")); 79 } 80 81 void UIWizardExportAppPageBasic2::initializePage() 82 { 83 /* Translate page: */ 84 retranslateUi(); 85 } 86 87 StorageType UIWizardExportAppPageBasic2::storageType() const 49 StorageType UIWizardExportAppPage2::storageType() const 88 50 { 89 51 if (m_pTypeSunCloud->isChecked()) … … 94 56 } 95 57 96 void UIWizardExportAppPage Basic2::setStorageType(StorageType storageType)58 void UIWizardExportAppPage2::setStorageType(StorageType storageType) 97 59 { 98 60 switch (storageType) … … 113 75 } 114 76 77 UIWizardExportAppPageBasic2::UIWizardExportAppPageBasic2() 78 { 79 /* Create widgets: */ 80 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 81 { 82 m_pLabel = new QIRichTextLabel(this); 83 m_pTypeCnt = new QGroupBox(this); 84 { 85 QVBoxLayout *pTypeCntLayout = new QVBoxLayout(m_pTypeCnt); 86 { 87 m_pTypeLocalFilesystem = new QRadioButton(m_pTypeCnt); 88 m_pTypeSunCloud = new QRadioButton(m_pTypeCnt); 89 m_pTypeSimpleStorageSystem = new QRadioButton(m_pTypeCnt); 90 pTypeCntLayout->addWidget(m_pTypeLocalFilesystem); 91 pTypeCntLayout->addWidget(m_pTypeSunCloud); 92 pTypeCntLayout->addWidget(m_pTypeSimpleStorageSystem); 93 } 94 } 95 pMainLayout->addWidget(m_pLabel); 96 pMainLayout->addWidget(m_pTypeCnt); 97 pMainLayout->addStretch(); 98 chooseDefaultStorageType(); 99 } 100 101 /* Setup connections: */ 102 connect(m_pTypeLocalFilesystem, SIGNAL(clicked()), this, SIGNAL(completeChanged())); 103 connect(m_pTypeSunCloud, SIGNAL(clicked()), this, SIGNAL(completeChanged())); 104 connect(m_pTypeSimpleStorageSystem, SIGNAL(clicked()), this, SIGNAL(completeChanged())); 105 106 /* Register classes: */ 107 qRegisterMetaType<StorageType>(); 108 /* Register fields: */ 109 registerField("storageType", this, "storageType"); 110 } 111 112 void UIWizardExportAppPageBasic2::retranslateUi() 113 { 114 /* Translate page: */ 115 setTitle(UIWizardExportApp::tr("Appliance Export Settings")); 116 117 /* Translate widgets: */ 118 m_pLabel->setText(UIWizardExportApp::tr("Please specify the target for the OVF export. " 119 "You can choose between a local file system export, " 120 "uploading the OVF to the Sun Cloud service " 121 "or an S3 storage server.")); 122 m_pTypeCnt->setTitle(UIWizardExportApp::tr("&Destination")); 123 m_pTypeLocalFilesystem->setText(UIWizardExportApp::tr("&Local Filesystem ")); 124 m_pTypeSunCloud->setText(UIWizardExportApp::tr("Sun &Cloud")); 125 m_pTypeSimpleStorageSystem->setText(UIWizardExportApp::tr("&Simple Storage System (S3)")); 126 } 127 128 void UIWizardExportAppPageBasic2::initializePage() 129 { 130 /* Translate page: */ 131 retranslateUi(); 132 } 133 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.h
r40870 r41021 25 25 26 26 /* Forward declarations: */ 27 class QGroupBox; 28 class QRadioButton; 27 29 class QIRichTextLabel; 28 class QRadioButton;29 30 30 /* 2nd page of the Export Appliance wizard: */ 31 class UIWizardExportAppPageBasic2 : public UIWizardPage 31 /* 2nd page of the Export Appliance wizard (base part): */ 32 class UIWizardExportAppPage2 : public UIWizardPageBase 33 { 34 protected: 35 36 /* Constructor: */ 37 UIWizardExportAppPage2(); 38 39 /* Helpers: */ 40 void chooseDefaultStorageType(); 41 42 /* Stuff for 'storageType' field: */ 43 StorageType storageType() const; 44 void setStorageType(StorageType storageType); 45 46 /* Widgets: */ 47 QGroupBox *m_pTypeCnt; 48 QRadioButton *m_pTypeLocalFilesystem; 49 QRadioButton *m_pTypeSunCloud; 50 QRadioButton *m_pTypeSimpleStorageSystem; 51 }; 52 53 /* 2nd page of the Export Appliance wizard (basic extension): */ 54 class UIWizardExportAppPageBasic2 : public UIWizardPage, public UIWizardExportAppPage2 32 55 { 33 56 Q_OBJECT; … … 47 70 void initializePage(); 48 71 49 /* Stuff for 'storageType' field: */50 StorageType storageType() const;51 void setStorageType(StorageType storageType);52 53 72 /* Widgets: */ 54 73 QIRichTextLabel *m_pLabel; 55 QRadioButton *m_pTypeLocalFilesystem;56 QRadioButton *m_pTypeSunCloud;57 QRadioButton *m_pTypeSimpleStorageSystem;58 74 }; 59 75 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp
r40870 r41021 31 31 #include "UIWizardExportAppDefs.h" 32 32 #include "VBoxGlobal.h" 33 #include "VBoxFilePathSelectorWidget.h" 33 34 #include "QIRichTextLabel.h" 34 #include "VBoxFilePathSelectorWidget.h" 35 36 UIWizardExportAppPage3::UIWizardExportAppPage3() 37 { 38 } 39 40 void UIWizardExportAppPage3::chooseDefaultSettings() 41 { 42 /* Select default settings: */ 43 #if 0 44 m_pUsernameEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Username)); 45 m_pHostnameEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Hostname)); 46 m_pBucketEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Bucket)); 47 #else 48 /* Do nothing for now... */ 49 #endif 50 } 51 52 void UIWizardExportAppPage3::refreshCurrentSettings() 53 { 54 /* Setup components for chosen storage-type: */ 55 StorageType storageType = fieldImp("storageType").value<StorageType>(); 56 switch (storageType) 57 { 58 case Filesystem: 59 { 60 m_pUsernameLabel->setVisible(false); 61 m_pUsernameEditor->setVisible(false); 62 m_pPasswordLabel->setVisible(false); 63 m_pPasswordEditor->setVisible(false); 64 m_pHostnameLabel->setVisible(false); 65 m_pHostnameEditor->setVisible(false); 66 m_pBucketLabel->setVisible(false); 67 m_pBucketEditor->setVisible(false); 68 m_pOVF09Checkbox->setVisible(true); 69 m_pFileSelector->setChooserVisible(true); 70 break; 71 } 72 case SunCloud: 73 { 74 m_pUsernameLabel->setVisible(true); 75 m_pUsernameEditor->setVisible(true); 76 m_pPasswordLabel->setVisible(true); 77 m_pPasswordEditor->setVisible(true); 78 m_pHostnameLabel->setVisible(false); 79 m_pHostnameEditor->setVisible(false); 80 m_pBucketLabel->setVisible(true); 81 m_pBucketEditor->setVisible(true); 82 m_pOVF09Checkbox->setVisible(false); 83 m_pOVF09Checkbox->setChecked(false); 84 m_pFileSelector->setChooserVisible(false); 85 break; 86 } 87 case S3: 88 { 89 m_pUsernameLabel->setVisible(true); 90 m_pUsernameEditor->setVisible(true); 91 m_pPasswordLabel->setVisible(true); 92 m_pPasswordEditor->setVisible(true); 93 m_pHostnameLabel->setVisible(true); 94 m_pHostnameEditor->setVisible(true); 95 m_pBucketLabel->setVisible(true); 96 m_pBucketEditor->setVisible(true); 97 m_pOVF09Checkbox->setVisible(true); 98 m_pFileSelector->setChooserVisible(false); 99 break; 100 } 101 } 102 103 /* Use the default filename: */ 104 QString strName = m_strDefaultApplianceName; 105 /* If it is one VM only, we use the VM name as filename: */ 106 if (fieldImp("machineNames").toStringList().size() == 1) 107 strName = fieldImp("machineNames").toStringList()[0]; 108 strName += ".ova"; 109 if (storageType == Filesystem) 110 strName = QDir::toNativeSeparators(QString("%1/%2").arg(vboxGlobal().documentsPath()).arg(strName)); 111 m_pFileSelector->setPath(strName); 112 } 113 114 bool UIWizardExportAppPage3::isOVF09Selected() const 115 { 116 return m_pOVF09Checkbox->isChecked(); 117 } 118 119 void UIWizardExportAppPage3::setOVF09Selected(bool fChecked) 120 { 121 m_pOVF09Checkbox->setChecked(fChecked); 122 } 123 124 bool UIWizardExportAppPage3::isManifestSelected() const 125 { 126 return m_pManifestCheckbox->isChecked(); 127 } 128 129 void UIWizardExportAppPage3::setManifestSelected(bool fChecked) 130 { 131 m_pManifestCheckbox->setChecked(fChecked); 132 } 133 134 QString UIWizardExportAppPage3::username() const 135 { 136 return m_pUsernameEditor->text(); 137 } 138 139 void UIWizardExportAppPage3::setUserName(const QString &strUserName) 140 { 141 m_pUsernameEditor->setText(strUserName); 142 } 143 144 QString UIWizardExportAppPage3::password() const 145 { 146 return m_pPasswordEditor->text(); 147 } 148 149 void UIWizardExportAppPage3::setPassword(const QString &strPassword) 150 { 151 m_pPasswordEditor->setText(strPassword); 152 } 153 154 QString UIWizardExportAppPage3::hostname() const 155 { 156 return m_pHostnameEditor->text(); 157 } 158 159 void UIWizardExportAppPage3::setHostname(const QString &strHostname) 160 { 161 m_pHostnameEditor->setText(strHostname); 162 } 163 164 QString UIWizardExportAppPage3::bucket() const 165 { 166 return m_pBucketEditor->text(); 167 } 168 169 void UIWizardExportAppPage3::setBucket(const QString &strBucket) 170 { 171 m_pBucketEditor->setText(strBucket); 172 } 173 174 QString UIWizardExportAppPage3::path() const 175 { 176 return m_pFileSelector->path(); 177 } 178 179 void UIWizardExportAppPage3::setPath(const QString &strPath) 180 { 181 m_pFileSelector->setPath(strPath); 182 } 35 183 36 184 UIWizardExportAppPageBasic3::UIWizardExportAppPageBasic3() … … 38 186 /* Create widgets: */ 39 187 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 188 { 40 189 m_pLabel = new QIRichTextLabel(this); 41 190 QGridLayout *pSettingsLayout = new QGridLayout; 191 { 42 192 m_pUsernameEditor = new QLineEdit(this); 43 //m_pUsernameEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Username));44 193 m_pUsernameLabel = new QLabel(this); 194 { 45 195 m_pUsernameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 46 196 m_pUsernameLabel->setBuddy(m_pUsernameEditor); 197 } 47 198 m_pPasswordEditor = new QLineEdit(this); 199 { 48 200 m_pPasswordEditor->setEchoMode(QLineEdit::Password); 201 } 49 202 m_pPasswordLabel = new QLabel(this); 203 { 50 204 m_pPasswordLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 51 205 m_pPasswordLabel->setBuddy(m_pPasswordEditor); 206 } 52 207 m_pHostnameEditor = new QLineEdit(this); 53 //m_pHostnameEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Hostname));54 208 m_pHostnameLabel = new QLabel(this); 209 { 55 210 m_pHostnameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 56 211 m_pHostnameLabel->setBuddy(m_pHostnameEditor); 212 } 57 213 m_pBucketEditor = new QLineEdit(this); 58 //m_pBucketEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Bucket));59 214 m_pBucketLabel = new QLabel(this); 215 { 60 216 m_pBucketLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 61 217 m_pBucketLabel->setBuddy(m_pBucketEditor); 218 } 62 219 m_pFileSelector = new VBoxEmptyFileSelector(this); 220 { 63 221 m_pFileSelector->setMode(VBoxFilePathSelectorWidget::Mode_File_Save); 64 222 m_pFileSelector->setEditable(true); 65 223 m_pFileSelector->setButtonPosition(VBoxEmptyFileSelector::RightPosition); 66 224 m_pFileSelector->setDefaultSaveExt("ova"); 225 } 67 226 m_pFileSelectorLabel = new QLabel(this); 227 { 68 228 m_pFileSelectorLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 69 229 m_pFileSelectorLabel->setBuddy(m_pFileSelector); 70 pSettingsLayout->addWidget(m_pUsernameLabel, 0, 0); 71 pSettingsLayout->addWidget(m_pUsernameEditor, 0, 1); 72 pSettingsLayout->addWidget(m_pPasswordLabel, 1, 0); 73 pSettingsLayout->addWidget(m_pPasswordEditor, 1, 1); 74 pSettingsLayout->addWidget(m_pHostnameLabel, 2, 0); 75 pSettingsLayout->addWidget(m_pHostnameEditor, 2, 1); 76 pSettingsLayout->addWidget(m_pBucketLabel, 3, 0); 77 pSettingsLayout->addWidget(m_pBucketEditor, 3, 1); 78 pSettingsLayout->addWidget(m_pFileSelectorLabel, 4, 0); 79 pSettingsLayout->addWidget(m_pFileSelector, 4, 1); 230 } 231 pSettingsLayout->addWidget(m_pUsernameLabel, 0, 0); 232 pSettingsLayout->addWidget(m_pUsernameEditor, 0, 1); 233 pSettingsLayout->addWidget(m_pPasswordLabel, 1, 0); 234 pSettingsLayout->addWidget(m_pPasswordEditor, 1, 1); 235 pSettingsLayout->addWidget(m_pHostnameLabel, 2, 0); 236 pSettingsLayout->addWidget(m_pHostnameEditor, 2, 1); 237 pSettingsLayout->addWidget(m_pBucketLabel, 3, 0); 238 pSettingsLayout->addWidget(m_pBucketEditor, 3, 1); 239 pSettingsLayout->addWidget(m_pFileSelectorLabel, 4, 0); 240 pSettingsLayout->addWidget(m_pFileSelector, 4, 1); 241 } 80 242 m_pOVF09Checkbox = new QCheckBox(this); 81 243 m_pManifestCheckbox = new QCheckBox(this); 82 pMainLayout->addWidget(m_pLabel); 83 pMainLayout->addLayout(pSettingsLayout); 84 pMainLayout->addWidget(m_pOVF09Checkbox); 85 pMainLayout->addWidget(m_pManifestCheckbox); 86 pMainLayout->addStretch(); 244 pMainLayout->addWidget(m_pLabel); 245 pMainLayout->addLayout(pSettingsLayout); 246 pMainLayout->addWidget(m_pOVF09Checkbox); 247 pMainLayout->addWidget(m_pManifestCheckbox); 248 pMainLayout->addStretch(); 249 chooseDefaultSettings(); 250 } 87 251 88 252 /* Setup connections: */ … … 108 272 setTitle(UIWizardExportApp::tr("Appliance Export Settings")); 109 273 110 /* Translate defaults: */274 /* Translate objects: */ 111 275 m_strDefaultApplianceName = UIWizardExportApp::tr("Appliance"); 112 276 /* Translate widgets: */ … … 130 294 retranslateUi(); 131 295 132 /* Setup components for chosen storage-type */ 296 /* Refresh current settings: */ 297 refreshCurrentSettings(); 298 } 299 300 bool UIWizardExportAppPageBasic3::isComplete() const 301 { 302 /* Initial result: */ 303 bool fResult = true; 304 305 /* Check storage-type attributes: */ 306 if (fResult) 307 { 308 const QString &strFile = m_pFileSelector->path().toLower(); 309 fResult = VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts); 310 if (fResult) 311 { 312 StorageType storageType = field("storageType").value<StorageType>(); 313 switch (storageType) 314 { 315 case Filesystem: 316 break; 317 case SunCloud: 318 fResult &= !m_pUsernameEditor->text().isEmpty() && 319 !m_pPasswordEditor->text().isEmpty() && 320 !m_pBucketEditor->text().isEmpty(); 321 break; 322 case S3: 323 fResult &= !m_pUsernameEditor->text().isEmpty() && 324 !m_pPasswordEditor->text().isEmpty() && 325 !m_pHostnameEditor->text().isEmpty() && 326 !m_pBucketEditor->text().isEmpty(); 327 break; 328 } 329 } 330 } 331 332 /* Return result: */ 333 return fResult; 334 } 335 336 void UIWizardExportAppPageBasic3::refreshCurrentSettings() 337 { 338 /* Refresh base-class settings: */ 339 UIWizardExportAppPage3::refreshCurrentSettings(); 340 341 /* Setup components for chosen storage-type: */ 133 342 StorageType storageType = field("storageType").value<StorageType>(); 134 343 switch (storageType) … … 141 350 "If you use an <i>ovf</i> extension, several files " 142 351 "will be written separately. Other extensions are not allowed.")); 143 m_pUsernameLabel->setVisible(false);144 m_pUsernameEditor->setVisible(false);145 m_pPasswordLabel->setVisible(false);146 m_pPasswordEditor->setVisible(false);147 m_pHostnameLabel->setVisible(false);148 m_pHostnameEditor->setVisible(false);149 m_pBucketLabel->setVisible(false);150 m_pBucketEditor->setVisible(false);151 m_pOVF09Checkbox->setVisible(true);152 m_pFileSelector->setChooserVisible(true);153 352 m_pFileSelector->setFocus(); 154 353 break; … … 158 357 m_pLabel->setText(tr("Please complete the additional fields like the username, password " 159 358 "and the bucket, and provide a filename for the OVF target.")); 160 m_pUsernameLabel->setVisible(true);161 m_pUsernameEditor->setVisible(true);162 m_pPasswordLabel->setVisible(true);163 m_pPasswordEditor->setVisible(true);164 m_pHostnameLabel->setVisible(false);165 m_pHostnameEditor->setVisible(false);166 m_pBucketLabel->setVisible(true);167 m_pBucketEditor->setVisible(true);168 m_pOVF09Checkbox->setVisible(false);169 m_pOVF09Checkbox->setChecked(false);170 m_pFileSelector->setChooserVisible(false);171 359 m_pUsernameEditor->setFocus(); 172 360 break; … … 176 364 m_pLabel->setText(tr("Please complete the additional fields like the username, password, " 177 365 "hostname and the bucket, and provide a filename for the OVF target.")); 178 m_pUsernameLabel->setVisible(true);179 m_pUsernameEditor->setVisible(true);180 m_pPasswordLabel->setVisible(true);181 m_pPasswordEditor->setVisible(true);182 m_pHostnameLabel->setVisible(true);183 m_pHostnameEditor->setVisible(true);184 m_pBucketLabel->setVisible(true);185 m_pBucketEditor->setVisible(true);186 m_pOVF09Checkbox->setVisible(true);187 m_pFileSelector->setChooserVisible(false);188 366 m_pUsernameEditor->setFocus(); 189 367 break; 190 368 } 191 369 } 192 193 if (!m_pFileSelector->path().isEmpty()) 194 { 195 QFileInfo fi(m_pFileSelector->path()); 196 QString strName = fi.fileName(); 197 if (storageType == Filesystem) 198 strName = QDir::toNativeSeparators(QString("%1/%2").arg(vboxGlobal().documentsPath()).arg(strName)); 199 m_pFileSelector->setPath(strName); 200 } 201 202 if (m_pFileSelector->path().isEmpty()) 203 { 204 /* Set the default filename: */ 205 QString strName = m_strDefaultApplianceName; 206 /* If it is one VM only, we use the VM name as file name: */ 207 if (field("machineNames").toStringList().size() == 1) 208 strName = field("machineNames").toStringList()[0]; 209 210 strName += ".ova"; 211 212 if (storageType == Filesystem) 213 strName = QDir::toNativeSeparators(QString("%1/%2").arg(vboxGlobal().documentsPath()).arg(strName)); 214 m_pFileSelector->setPath(strName); 215 } 216 } 217 218 bool UIWizardExportAppPageBasic3::isComplete() const 219 { 220 const QString &strFile = m_pFileSelector->path().toLower(); 221 bool bComplete = VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts); 222 StorageType storageType = field("storageType").value<StorageType>(); 223 switch (storageType) 224 { 225 case Filesystem: 226 break; 227 case SunCloud: 228 bComplete &= !m_pUsernameEditor->text().isEmpty() && !m_pPasswordEditor->text().isEmpty() && 229 !m_pBucketEditor->text().isEmpty(); 230 break; 231 case S3: 232 bComplete &= !m_pUsernameEditor->text().isEmpty() && !m_pPasswordEditor->text().isEmpty() && 233 !m_pHostnameEditor->text().isEmpty() && !m_pBucketEditor->text().isEmpty(); 234 break; 235 } 236 return bComplete; 237 } 238 239 bool UIWizardExportAppPageBasic3::isOVF09Selected() const 240 { 241 return m_pOVF09Checkbox->isChecked(); 242 } 243 244 void UIWizardExportAppPageBasic3::setOVF09Selected(bool fChecked) 245 { 246 m_pOVF09Checkbox->setChecked(fChecked); 247 } 248 249 bool UIWizardExportAppPageBasic3::isManifestSelected() const 250 { 251 return m_pManifestCheckbox->isChecked(); 252 } 253 254 void UIWizardExportAppPageBasic3::setManifestSelected(bool fChecked) 255 { 256 m_pManifestCheckbox->setChecked(fChecked); 257 } 258 259 QString UIWizardExportAppPageBasic3::username() const 260 { 261 return m_pUsernameEditor->text(); 262 } 263 264 void UIWizardExportAppPageBasic3::setUserName(const QString &strUserName) 265 { 266 m_pUsernameEditor->setText(strUserName); 267 } 268 269 QString UIWizardExportAppPageBasic3::password() const 270 { 271 return m_pPasswordEditor->text(); 272 } 273 274 void UIWizardExportAppPageBasic3::setPassword(const QString &strPassword) 275 { 276 m_pPasswordEditor->setText(strPassword); 277 } 278 279 QString UIWizardExportAppPageBasic3::hostname() const 280 { 281 return m_pHostnameEditor->text(); 282 } 283 284 void UIWizardExportAppPageBasic3::setHostname(const QString &strHostname) 285 { 286 m_pHostnameEditor->setText(strHostname); 287 } 288 289 QString UIWizardExportAppPageBasic3::bucket() const 290 { 291 return m_pBucketEditor->text(); 292 } 293 294 void UIWizardExportAppPageBasic3::setBucket(const QString &strBucket) 295 { 296 m_pBucketEditor->setText(strBucket); 297 } 298 299 QString UIWizardExportAppPageBasic3::path() const 300 { 301 return m_pFileSelector->path(); 302 } 303 304 void UIWizardExportAppPageBasic3::setPath(const QString &strPath) 305 { 306 m_pFileSelector->setPath(strPath); 307 } 308 370 } 371 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.h
r40870 r41021 20 20 #define __UIWizardExportAppPageBasic3_h__ 21 21 22 /* Global includes: */ 23 #include <QVariant> 24 22 25 /* Local includes: */ 23 26 #include "UIWizardPage.h" 24 27 25 28 /* Forward declarations: */ 26 class QIRichTextLabel;27 29 class QLabel; 28 30 class QLineEdit; 29 31 class VBoxEmptyFileSelector; 30 32 class QCheckBox; 33 class QIRichTextLabel; 31 34 32 /* 3rd page of the Export Appliance wizard : */33 class UIWizardExportAppPage Basic3 : public UIWizardPage35 /* 3rd page of the Export Appliance wizard (base part): */ 36 class UIWizardExportAppPage3 : public UIWizardPageBase 34 37 { 35 Q_OBJECT; 36 Q_PROPERTY(bool OVF09Selected READ isOVF09Selected WRITE setOVF09Selected); 37 Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected); 38 Q_PROPERTY(QString username READ username WRITE setUserName); 39 Q_PROPERTY(QString password READ password WRITE setPassword); 40 Q_PROPERTY(QString hostname READ hostname WRITE setHostname); 41 Q_PROPERTY(QString bucket READ bucket WRITE setBucket); 42 Q_PROPERTY(QString path READ path WRITE setPath); 43 44 public: 38 protected: 45 39 46 40 /* Constructor: */ 47 UIWizardExportAppPage Basic3();41 UIWizardExportAppPage3(); 48 42 49 private: 50 51 /* Translate stuff: */ 52 void retranslateUi(); 53 54 /* Prepare stuff: */ 55 void initializePage(); 56 57 /* Validation stuff: */ 58 bool isComplete() const; 43 /* Helpers: */ 44 void chooseDefaultSettings(); 45 virtual void refreshCurrentSettings(); 59 46 60 47 /* Stuff for 'OVF09Selected' field: */ … … 84 71 85 72 /* Widgets: */ 86 QIRichTextLabel *m_pLabel;87 73 QLabel *m_pUsernameLabel; 88 74 QLineEdit *m_pUsernameEditor; … … 99 85 }; 100 86 87 /* 3rd page of the Export Appliance wizard (basic extension): */ 88 class UIWizardExportAppPageBasic3 : public UIWizardPage, public UIWizardExportAppPage3 89 { 90 Q_OBJECT; 91 Q_PROPERTY(bool OVF09Selected READ isOVF09Selected WRITE setOVF09Selected); 92 Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected); 93 Q_PROPERTY(QString username READ username WRITE setUserName); 94 Q_PROPERTY(QString password READ password WRITE setPassword); 95 Q_PROPERTY(QString hostname READ hostname WRITE setHostname); 96 Q_PROPERTY(QString bucket READ bucket WRITE setBucket); 97 Q_PROPERTY(QString path READ path WRITE setPath); 98 99 public: 100 101 /* Constructor: */ 102 UIWizardExportAppPageBasic3(); 103 104 protected: 105 106 /* Wrapper to access 'wizard-field' from base part: */ 107 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 108 109 private: 110 111 /* Translate stuff: */ 112 void retranslateUi(); 113 114 /* Prepare stuff: */ 115 void initializePage(); 116 117 /* Validation stuff: */ 118 bool isComplete() const; 119 120 /* Helpers: */ 121 void refreshCurrentSettings(); 122 123 /* Widgets: */ 124 QIRichTextLabel *m_pLabel; 125 }; 126 101 127 #endif /* __UIWizardExportAppPageBasic3_h__ */ 102 128 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic4.cpp
r40870 r41021 26 26 #include "VBoxGlobal.h" 27 27 #include "UIMessageCenter.h" 28 #include "QILabelSeparator.h" 28 29 #include "QIRichTextLabel.h" 29 30 30 UIWizardExportAppPage Basic4::UIWizardExportAppPageBasic4()31 UIWizardExportAppPage4::UIWizardExportAppPage4() 31 32 { 32 /* Create widgets: */33 QVBoxLayout *pMainLayout = new QVBoxLayout(this);34 m_pLabel = new QIRichTextLabel(this);35 m_pApplianceWidget = new UIApplianceExportEditorWidget(this);36 m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);37 pMainLayout->addWidget(m_pLabel);38 pMainLayout->addWidget(m_pApplianceWidget);39 40 /* Register ExportAppliancePointer class: */41 qRegisterMetaType<ExportAppliancePointer>();42 /* Register 'applianceWidget' field! */43 registerField("applianceWidget", this, "applianceWidget");44 33 } 45 34 46 void UIWizardExportAppPage Basic4::retranslateUi()35 void UIWizardExportAppPage4::refreshApplianceSettingsWidget() 47 36 { 48 /* Translate page: */ 49 setTitle(UIWizardExportApp::tr("Appliance Export Settings")); 50 51 /* Translate widgets: */ 52 m_pLabel->setText(UIWizardExportApp::tr("Here you can change additional configuration " 53 "values of the selected virtual machines. " 54 "You can modify most of the properties shown " 55 "by double-clicking on the items.")); 56 } 57 58 void UIWizardExportAppPageBasic4::initializePage() 59 { 60 /* Translate page: */ 61 retranslateUi(); 62 63 /* Prepare settings widget: */ 37 /* Refresh settings widget: */ 64 38 CVirtualBox vbox = vboxGlobal().virtualBox(); 65 39 CAppliance *pAppliance = m_pApplianceWidget->init(); … … 68 42 { 69 43 /* Iterate over all the selected machine ids: */ 70 QStringList uuids = field ("machineIDs").toStringList();44 QStringList uuids = fieldImp("machineIDs").toStringList(); 71 45 foreach (const QString &uuid, uuids) 72 46 { … … 77 51 { 78 52 /* Add the export description to our appliance object: */ 79 CVirtualSystemDescription vsd = machine.Export(*pAppliance, qobject_cast<UIWizardExportApp*>(wizard ())->uri());53 CVirtualSystemDescription vsd = machine.Export(*pAppliance, qobject_cast<UIWizardExportApp*>(wizardImp())->uri()); 80 54 fResult = machine.isOk(); 81 55 if (!fResult) 82 56 { 83 msgCenter().cannotExportAppliance(machine, pAppliance, this );57 msgCenter().cannotExportAppliance(machine, pAppliance, thisImp()); 84 58 return; 85 59 } … … 99 73 } 100 74 if (!fResult) 101 msgCenter().cannotExportAppliance(pAppliance, this); 75 msgCenter().cannotExportAppliance(pAppliance, thisImp()); 76 } 77 78 UIWizardExportAppPageBasic4::UIWizardExportAppPageBasic4() 79 { 80 /* Create widgets: */ 81 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 82 { 83 m_pLabel = new QIRichTextLabel(this); 84 m_pVMApplianceLabel = new QILabelSeparator(this); 85 { 86 m_pVMApplianceLabel->hide(); 87 } 88 m_pApplianceWidget = new UIApplianceExportEditorWidget(this); 89 { 90 m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); 91 m_pVMApplianceLabel->setBuddy(m_pApplianceWidget); 92 } 93 pMainLayout->addWidget(m_pLabel); 94 pMainLayout->addWidget(m_pVMApplianceLabel); 95 pMainLayout->addWidget(m_pApplianceWidget); 96 } 97 98 /* Register classes: */ 99 qRegisterMetaType<ExportAppliancePointer>(); 100 /* Register fields: */ 101 registerField("applianceWidget", this, "applianceWidget"); 102 } 103 104 void UIWizardExportAppPageBasic4::retranslateUi() 105 { 106 /* Translate page: */ 107 setTitle(UIWizardExportApp::tr("Appliance Export Settings")); 108 109 /* Translate widgets: */ 110 m_pLabel->setText(UIWizardExportApp::tr("Here you can change additional configuration " 111 "values of the selected virtual machines. " 112 "You can modify most of the properties shown " 113 "by double-clicking on the items.")); 114 m_pVMApplianceLabel->setText(UIWizardExportApp::tr("&Settings")); 115 } 116 117 void UIWizardExportAppPageBasic4::initializePage() 118 { 119 /* Translate page: */ 120 retranslateUi(); 121 122 /* Refresh appliance settings widget: */ 123 refreshApplianceSettingsWidget(); 102 124 } 103 125 104 126 bool UIWizardExportAppPageBasic4::validatePage() 105 127 { 128 /* Initial result: */ 129 bool fResult = true; 130 131 /* Lock finish button: */ 132 startProcessing(); 133 106 134 /* Try to export appliance: */ 107 startProcessing(); 108 bool fResult = qobject_cast<UIWizardExportApp*>(wizard())->exportAppliance(); 135 if (fResult) 136 fResult = qobject_cast<UIWizardExportApp*>(wizard())->exportAppliance(); 137 138 /* Unlock finish button: */ 109 139 endProcessing(); 140 141 /* Return result: */ 110 142 return fResult; 111 143 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic4.h
r40870 r41021 20 20 #define __UIWizardExportAppPageBasic4_h__ 21 21 22 /* Global includes: */ 23 #include <QVariant> 24 22 25 /* Local includes: */ 23 26 #include "UIWizardPage.h" … … 25 28 26 29 /* Forward declarations: */ 30 class QILabelSeparator; 31 class UIWizardExportApp; 27 32 class QIRichTextLabel; 28 33 29 /* 4th page of the Export Appliance wizard: */ 30 class UIWizardExportAppPageBasic4 : public UIWizardPage 34 /* 4th page of the Export Appliance wizard (base part): */ 35 class UIWizardExportAppPage4 : public UIWizardPageBase 36 { 37 protected: 38 39 /* Constructor: */ 40 UIWizardExportAppPage4(); 41 42 /* Helpers: */ 43 void refreshApplianceSettingsWidget( ); 44 45 /* Stuff for 'applianceWidget' field: */ 46 ExportAppliancePointer applianceWidget() const { return m_pApplianceWidget; } 47 48 /* Widgets: */ 49 QILabelSeparator *m_pVMApplianceLabel; 50 UIApplianceExportEditorWidget *m_pApplianceWidget; 51 }; 52 53 /* 4th page of the Export Appliance wizard (basic extension): */ 54 class UIWizardExportAppPageBasic4 : public UIWizardPage, public UIWizardExportAppPage4 31 55 { 32 56 Q_OBJECT; … … 37 61 /* Constructor: */ 38 62 UIWizardExportAppPageBasic4(); 63 64 protected: 65 66 /* Wrapper to access 'wizard' from base part: */ 67 UIWizard* wizardImp() { return UIWizardPage::wizard(); } 68 /* Wrapper to access 'this' from base part: */ 69 UIWizardPage* thisImp() { return this; } 70 /* Wrapper to access 'wizard-field' from base part: */ 71 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 39 72 40 73 private: … … 49 82 bool validatePage(); 50 83 51 /* Stuff for 'applianceWidget' field: */52 ExportAppliancePointer applianceWidget() const { return m_pApplianceWidget; }53 54 84 /* Widgets: */ 55 85 QIRichTextLabel *m_pLabel; 56 UIApplianceExportEditorWidget *m_pApplianceWidget;57 86 }; 58 87 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp
r40929 r41021 3 3 * 4 4 * VBox frontends: Qt4 GUI ("VirtualBox"): 5 * UIWizardExportAppPage Basic1class implementation5 * UIWizardExportAppPageExpert class implementation 6 6 */ 7 7 … … 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QGridLayout> 22 23 #include <QListWidget> 24 #include <QGroupBox> 25 #include <QRadioButton> 26 #include <QLineEdit> 27 #include <QLabel> 28 #include <QCheckBox> 23 29 24 30 /* Local includes: */ 25 #include "UIWizardExportAppPage Basic1.h"31 #include "UIWizardExportAppPageExpert.h" 26 32 #include "UIWizardExportApp.h" 33 #include "UIWizardExportAppDefs.h" 27 34 #include "VBoxGlobal.h" 28 35 #include "UIMessageCenter.h" 29 #include "QIRichTextLabel.h" 30 31 class VMListWidgetItems : public QListWidgetItem 32 { 33 public: 34 35 VMListWidgetItems(QPixmap &pixIcon, QString &strText, QString strUuid, bool fInSaveState, QListWidget *pParent) 36 : QListWidgetItem(pixIcon, strText, pParent) 37 , m_strUuid(strUuid) 38 , m_fInSaveState(fInSaveState) 36 #include "QILabelSeparator.h" 37 #include "VBoxFilePathSelectorWidget.h" 38 #include "UIApplianceExportEditorWidget.h" 39 40 UIWizardExportAppPageExpert::UIWizardExportAppPageExpert(const QStringList &selectedVMNames) 41 { 42 /* Create widgets: */ 43 QGridLayout *pMainLayout = new QGridLayout(this); 39 44 { 40 } 41 42 bool operator<(const QListWidgetItem &other) const 43 { 44 return text().toLower() < other.text().toLower(); 45 } 46 47 QString uuid() { return m_strUuid; } 48 bool isInSaveState() { return m_fInSaveState; } 49 50 private: 51 52 QString m_strUuid; 53 bool m_fInSaveState; 54 }; 55 56 UIWizardExportAppPageBasic1::UIWizardExportAppPageBasic1(const QStringList &selectedVMNames) 57 : m_selectedVMNames(selectedVMNames) 58 { 59 /* Create widgets: */ 60 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 61 m_pLabel = new QIRichTextLabel(this); 45 pMainLayout->setContentsMargins(8, 6, 8, 6); 46 m_pVMSelectorLabel = new QILabelSeparator(this); 62 47 m_pVMSelector = new QListWidget(this); 48 { 63 49 m_pVMSelector->setAlternatingRowColors(true); 64 50 m_pVMSelector->setSelectionMode(QAbstractItemView::ExtendedSelection); 65 populateVMSelectorItems(); 66 pMainLayout->addWidget(m_pLabel); 67 pMainLayout->addWidget(m_pVMSelector); 68 69 /* Choose initially selected items (if passed): */ 70 for (int i = 0; i < m_selectedVMNames.size(); ++i) 71 { 72 QList<QListWidgetItem*> list = m_pVMSelector->findItems(m_selectedVMNames[i], Qt::MatchExactly); 73 if (list.size() > 0) 74 { 75 if (m_pVMSelector->selectedItems().isEmpty()) 76 m_pVMSelector->setCurrentItem(list.first()); 77 else 78 list.first()->setSelected(true); 79 } 51 m_pVMSelectorLabel->setBuddy(m_pVMSelector); 52 } 53 m_pVMApplianceLabel = new QILabelSeparator(this); 54 m_pApplianceWidget = new UIApplianceExportEditorWidget(this); 55 { 56 m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); 57 m_pVMApplianceLabel->setBuddy(m_pApplianceWidget); 58 } 59 m_pTypeCnt = new QGroupBox(this); 60 { 61 m_pTypeCnt->hide(); 62 QVBoxLayout *pTypeCntLayout = new QVBoxLayout(m_pTypeCnt); 63 { 64 m_pTypeLocalFilesystem = new QRadioButton(m_pTypeCnt); 65 m_pTypeSunCloud = new QRadioButton(m_pTypeCnt); 66 m_pTypeSimpleStorageSystem = new QRadioButton(m_pTypeCnt); 67 pTypeCntLayout->addWidget(m_pTypeLocalFilesystem); 68 pTypeCntLayout->addWidget(m_pTypeSunCloud); 69 pTypeCntLayout->addWidget(m_pTypeSimpleStorageSystem); 70 } 71 } 72 QGridLayout *pSettingsLayout = new QGridLayout; 73 { 74 m_pUsernameEditor = new QLineEdit(this); 75 m_pUsernameLabel = new QLabel(this); 76 { 77 m_pUsernameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 78 m_pUsernameLabel->setBuddy(m_pUsernameEditor); 79 } 80 m_pPasswordEditor = new QLineEdit(this); 81 { 82 m_pPasswordEditor->setEchoMode(QLineEdit::Password); 83 } 84 m_pPasswordLabel = new QLabel(this); 85 { 86 m_pPasswordLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 87 m_pPasswordLabel->setBuddy(m_pPasswordEditor); 88 } 89 m_pHostnameEditor = new QLineEdit(this); 90 m_pHostnameLabel = new QLabel(this); 91 { 92 m_pHostnameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 93 m_pHostnameLabel->setBuddy(m_pHostnameEditor); 94 } 95 m_pBucketEditor = new QLineEdit(this); 96 m_pBucketLabel = new QLabel(this); 97 { 98 m_pBucketLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 99 m_pBucketLabel->setBuddy(m_pBucketEditor); 100 } 101 m_pFileSelector = new VBoxEmptyFileSelector(this); 102 { 103 m_pFileSelector->setMode(VBoxFilePathSelectorWidget::Mode_File_Save); 104 m_pFileSelector->setEditable(true); 105 m_pFileSelector->setButtonPosition(VBoxEmptyFileSelector::RightPosition); 106 m_pFileSelector->setDefaultSaveExt("ova"); 107 } 108 m_pFileSelectorLabel = new QLabel(this); 109 { 110 m_pFileSelectorLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 111 m_pFileSelectorLabel->setBuddy(m_pFileSelector); 112 } 113 pSettingsLayout->addWidget(m_pUsernameLabel, 0, 0); 114 pSettingsLayout->addWidget(m_pUsernameEditor, 0, 1); 115 pSettingsLayout->addWidget(m_pPasswordLabel, 1, 0); 116 pSettingsLayout->addWidget(m_pPasswordEditor, 1, 1); 117 pSettingsLayout->addWidget(m_pHostnameLabel, 2, 0); 118 pSettingsLayout->addWidget(m_pHostnameEditor, 2, 1); 119 pSettingsLayout->addWidget(m_pBucketLabel, 3, 0); 120 pSettingsLayout->addWidget(m_pBucketEditor, 3, 1); 121 pSettingsLayout->addWidget(m_pFileSelectorLabel, 4, 0); 122 pSettingsLayout->addWidget(m_pFileSelector, 4, 1); 123 } 124 m_pOVF09Checkbox = new QCheckBox(this); 125 m_pManifestCheckbox = new QCheckBox(this); 126 pMainLayout->addWidget(m_pVMSelectorLabel, 0, 0); 127 pMainLayout->addWidget(m_pVMApplianceLabel, 0, 1); 128 pMainLayout->addWidget(m_pVMSelector, 1, 0); 129 pMainLayout->addWidget(m_pApplianceWidget, 1, 1); 130 pMainLayout->addWidget(m_pTypeCnt, 2, 0, 1, 2); 131 pMainLayout->addLayout(pSettingsLayout, 3, 0, 1, 2); 132 pMainLayout->addWidget(m_pOVF09Checkbox, 4, 0, 1, 2); 133 pMainLayout->addWidget(m_pManifestCheckbox, 5, 0, 1, 2); 134 populateVMSelectorItems(selectedVMNames); 135 chooseDefaultStorageType(); 136 chooseDefaultSettings(); 80 137 } 81 138 82 139 /* Setup connections: */ 83 connect(m_pVMSelector, SIGNAL(itemSelectionChanged()), this, SIGNAL(completeChanged())); 84 85 /* Register 'machineNames', 'machineIDs' fields! */ 140 connect(m_pVMSelector, SIGNAL(itemSelectionChanged()), this, SLOT(sltVMSelectionChangeHandler())); 141 connect(m_pTypeLocalFilesystem, SIGNAL(clicked()), this, SLOT(sltStorageTypeChangeHandler())); 142 connect(m_pTypeSunCloud, SIGNAL(clicked()), this, SLOT(sltStorageTypeChangeHandler())); 143 connect(m_pTypeSimpleStorageSystem, SIGNAL(clicked()), this, SLOT(sltStorageTypeChangeHandler())); 144 connect(m_pUsernameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged())); 145 connect(m_pPasswordEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged())); 146 connect(m_pHostnameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged())); 147 connect(m_pBucketEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged())); 148 connect(m_pFileSelector, SIGNAL(pathChanged(const QString &)), this, SIGNAL(completeChanged())); 149 150 /* Register classes: */ 151 qRegisterMetaType<StorageType>(); 152 qRegisterMetaType<ExportAppliancePointer>(); 153 /* Register fields: */ 86 154 registerField("machineNames", this, "machineNames"); 87 155 registerField("machineIDs", this, "machineIDs"); 88 } 89 90 void UIWizardExportAppPageBasic1::retranslateUi() 91 { 92 /* Translate page: */ 93 setTitle(UIWizardExportApp::tr("Welcome to the Appliance Export Wizard!")); 94 156 registerField("storageType", this, "storageType"); 157 registerField("OVF09Selected", this, "OVF09Selected"); 158 registerField("manifestSelected", this, "manifestSelected"); 159 registerField("username", this, "username"); 160 registerField("password", this, "password"); 161 registerField("hostname", this, "hostname"); 162 registerField("bucket", this, "bucket"); 163 registerField("path", this, "path"); 164 registerField("applianceWidget", this, "applianceWidget"); 165 } 166 167 void UIWizardExportAppPageExpert::sltVMSelectionChangeHandler() 168 { 169 /* Call to base-class: */ 170 refreshApplianceSettingsWidget(); 171 refreshCurrentSettings(); 172 173 /* Broadcast complete-change: */ 174 emit completeChanged(); 175 } 176 177 void UIWizardExportAppPageExpert::sltStorageTypeChangeHandler() 178 { 179 /* Call to base-class: */ 180 refreshCurrentSettings(); 181 182 /* Broadcast complete-change: */ 183 emit completeChanged(); 184 } 185 186 void UIWizardExportAppPageExpert::retranslateUi() 187 { 188 /* Translate objects: */ 189 m_strDefaultApplianceName = UIWizardExportApp::tr("Appliance"); 95 190 /* Translate widgets: */ 96 m_pLabel->setText(UIWizardExportApp::tr("<p>This wizard will guide you through the process of " 97 "exporting an appliance.</p><p>%1</p><p>Please select " 98 "the virtual machines that should be added to the " 99 "appliance. You can select more than one. Please note " 100 "that these machines have to be turned off before they " 101 "can be exported.</p>") 102 .arg(standardHelpText())); 103 } 104 105 void UIWizardExportAppPageBasic1::initializePage() 191 m_pVMSelectorLabel->setText(UIWizardExportApp::tr("VM &List")); 192 m_pVMApplianceLabel->setText(UIWizardExportApp::tr("&Settings")); 193 m_pTypeCnt->setTitle(UIWizardExportApp::tr("&Destination")); 194 m_pTypeLocalFilesystem->setText(UIWizardExportApp::tr("&Local Filesystem ")); 195 m_pTypeSunCloud->setText(UIWizardExportApp::tr("Sun &Cloud")); 196 m_pTypeSimpleStorageSystem->setText(UIWizardExportApp::tr("&Simple Storage System (S3)")); 197 m_pUsernameLabel->setText(UIWizardExportApp::tr("&Username:")); 198 m_pPasswordLabel->setText(UIWizardExportApp::tr("&Password:")); 199 m_pHostnameLabel->setText(UIWizardExportApp::tr("&Hostname:")); 200 m_pBucketLabel->setText(UIWizardExportApp::tr("&Bucket:")); 201 m_pFileSelectorLabel->setText(UIWizardExportApp::tr("&File:")); 202 m_pFileSelector->setFileDialogTitle(UIWizardExportApp::tr("Select a file to export into")); 203 m_pFileSelector->setFileFilters(UIWizardExportApp::tr("Open Virtualization Format Archive (%1)").arg("*.ova") + ";;" + 204 UIWizardExportApp::tr("Open Virtualization Format (%1)").arg("*.ovf")); 205 m_pOVF09Checkbox->setToolTip(UIWizardExportApp::tr("Write in legacy OVF 0.9 format for compatibility with other virtualization products.")); 206 m_pOVF09Checkbox->setText(UIWizardExportApp::tr("&Write legacy OVF 0.9")); 207 m_pManifestCheckbox->setToolTip(UIWizardExportApp::tr("Create a Manifest file for automatic data integrity checks on import.")); 208 m_pManifestCheckbox->setText(UIWizardExportApp::tr("Write &Manifest file")); 209 } 210 211 void UIWizardExportAppPageExpert::initializePage() 106 212 { 107 213 /* Translate page: */ 108 214 retranslateUi(); 109 } 110 111 bool UIWizardExportAppPageBasic1::isComplete() const 112 { 113 /* There should be at least one vm selected! */ 114 return m_pVMSelector->selectedItems().size() > 0; 115 } 116 117 bool UIWizardExportAppPageBasic1::validatePage() 118 { 119 /* Ask user machines which are in save state currently. */ 215 216 /* Call to base-class: */ 217 refreshApplianceSettingsWidget(); 218 refreshCurrentSettings(); 219 } 220 221 bool UIWizardExportAppPageExpert::isComplete() const 222 { 223 /* Initial result: */ 224 bool fResult = true; 225 226 /* There should be at least one vm selected: */ 227 if (fResult) 228 fResult = (m_pVMSelector->selectedItems().size() > 0); 229 230 /* Check storage-type attributes: */ 231 if (fResult) 232 { 233 const QString &strFile = m_pFileSelector->path().toLower(); 234 fResult = VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts); 235 if (fResult) 236 { 237 StorageType st = storageType(); 238 switch (st) 239 { 240 case Filesystem: 241 break; 242 case SunCloud: 243 fResult &= !m_pUsernameEditor->text().isEmpty() && 244 !m_pPasswordEditor->text().isEmpty() && 245 !m_pBucketEditor->text().isEmpty(); 246 break; 247 case S3: 248 fResult &= !m_pUsernameEditor->text().isEmpty() && 249 !m_pPasswordEditor->text().isEmpty() && 250 !m_pHostnameEditor->text().isEmpty() && 251 !m_pBucketEditor->text().isEmpty(); 252 break; 253 } 254 } 255 } 256 257 /* Return result: */ 258 return fResult; 259 } 260 261 bool UIWizardExportAppPageExpert::validatePage() 262 { 263 /* Initial result: */ 264 bool fResult = true; 265 266 /* Lock finish button: */ 267 startProcessing(); 268 269 /* Ask user about machines which are in save state currently: */ 120 270 QStringList savedMachines; 121 271 QList<QListWidgetItem*> pItems = m_pVMSelector->selectedItems(); 122 272 for (int i=0; i < pItems.size(); ++i) 123 273 { 124 if (static_cast<VMListWidgetItem s*>(pItems.at(i))->isInSaveState())274 if (static_cast<VMListWidgetItem*>(pItems.at(i))->isInSaveState()) 125 275 savedMachines << pItems.at(i)->text(); 126 276 } 127 128 277 if (!savedMachines.isEmpty()) 129 return msgCenter().confirmExportMachinesInSaveState(savedMachines, this); 130 131 return true; 132 } 133 134 int UIWizardExportAppPageBasic1::nextId() const 135 { 136 /* Skip next (2nd, Storage-type) page for now! */ 137 return UIWizardExportApp::Page3; 138 } 139 140 void UIWizardExportAppPageBasic1::populateVMSelectorItems() 141 { 142 /* Add all VM items into 'VM Selector': */ 143 foreach (const CMachine &machine, vboxGlobal().virtualBox().GetMachines()) 144 { 145 QPixmap pixIcon; 146 QString strName; 147 QString strUuid; 148 bool fInSaveState = false; 149 bool fEnabled = false; 150 if (machine.GetAccessible()) 151 { 152 pixIcon = vboxGlobal().vmGuestOSTypeIcon(machine.GetOSTypeId()).scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 153 strName = machine.GetName(); 154 strUuid = machine.GetId(); 155 fEnabled = machine.GetSessionState() == KSessionState_Unlocked; 156 fInSaveState = machine.GetState() == KMachineState_Saved; 157 } 158 else 159 { 160 QString settingsFile = machine.GetSettingsFilePath(); 161 QFileInfo fi(settingsFile); 162 strName = VBoxGlobal::hasAllowedExtension(fi.completeSuffix(), VBoxDefs::VBoxFileExts) ? fi.completeBaseName() : fi.fileName(); 163 pixIcon = QPixmap(":/os_other.png").scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 164 } 165 QListWidgetItem *pItem = new VMListWidgetItems(pixIcon, strName, strUuid, fInSaveState, m_pVMSelector); 166 if (!fEnabled) 167 pItem->setFlags(0); 168 m_pVMSelector->addItem(pItem); 169 } 170 m_pVMSelector->sortItems(); 171 } 172 173 QStringList UIWizardExportAppPageBasic1::machineNames() const 174 { 175 /* Prepare list: */ 176 QStringList machineNames; 177 /* Iterate over all the selected items: */ 178 foreach (QListWidgetItem *pItem, m_pVMSelector->selectedItems()) 179 machineNames << pItem->text(); 180 /* Return result list: */ 181 return machineNames; 182 } 183 184 QStringList UIWizardExportAppPageBasic1::machineIDs() const 185 { 186 /* Prepare list: */ 187 QStringList machineIDs; 188 /* Iterate over all the selected items: */ 189 foreach (QListWidgetItem *pItem, m_pVMSelector->selectedItems()) 190 machineIDs << static_cast<VMListWidgetItems*>(pItem)->uuid(); 191 /* Return result list: */ 192 return machineIDs; 193 } 194 278 fResult = msgCenter().confirmExportMachinesInSaveState(savedMachines, this); 279 280 /* Try to export appliance: */ 281 if (fResult) 282 fResult = qobject_cast<UIWizardExportApp*>(wizard())->exportAppliance(); 283 284 /* Unlock finish button: */ 285 endProcessing(); 286 287 /* Return result: */ 288 return fResult; 289 } 290 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.h
r40929 r41021 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * UIWizardExportAppPage Basic1class declaration4 * UIWizardExportAppPageExpert class declaration 5 5 */ 6 6 … … 17 17 */ 18 18 19 #ifndef __UIWizardExportAppPage Basic1_h__20 #define __UIWizardExportAppPage Basic1_h__19 #ifndef __UIWizardExportAppPageExpert_h__ 20 #define __UIWizardExportAppPageExpert_h__ 21 21 22 22 /* Local includes: */ 23 #include "UIWizardPage.h" 23 #include "UIWizardExportAppPageBasic1.h" 24 #include "UIWizardExportAppPageBasic2.h" 25 #include "UIWizardExportAppPageBasic3.h" 26 #include "UIWizardExportAppPageBasic4.h" 24 27 25 /* Forward declarations: */26 class QIRichTextLabel;27 class QListWidget; 28 29 /* 1st page of the Export Appliance wizard: */ 30 class UIWizardExportAppPageBasic1 : public UIWizardPage 28 /* Expert page of the Export Appliance wizard: */ 29 class UIWizardExportAppPageExpert : public UIWizardPage, 30 public UIWizardExportAppPage1, 31 public UIWizardExportAppPage2, 32 public UIWizardExportAppPage3, 33 public UIWizardExportAppPage4 31 34 { 32 35 Q_OBJECT; 33 36 Q_PROPERTY(QStringList machineNames READ machineNames); 34 37 Q_PROPERTY(QStringList machineIDs READ machineIDs); 38 Q_PROPERTY(StorageType storageType READ storageType WRITE setStorageType); 39 Q_PROPERTY(bool OVF09Selected READ isOVF09Selected WRITE setOVF09Selected); 40 Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected); 41 Q_PROPERTY(QString username READ username WRITE setUserName); 42 Q_PROPERTY(QString password READ password WRITE setPassword); 43 Q_PROPERTY(QString hostname READ hostname WRITE setHostname); 44 Q_PROPERTY(QString bucket READ bucket WRITE setBucket); 45 Q_PROPERTY(QString path READ path WRITE setPath); 46 Q_PROPERTY(ExportAppliancePointer applianceWidget READ applianceWidget); 35 47 36 48 public: 37 49 38 50 /* Constructor: */ 39 UIWizardExportAppPageBasic1(const QStringList &selectedVMNames); 51 UIWizardExportAppPageExpert(const QStringList &selectedVMNames); 52 53 protected: 54 55 /* Wrapper to access 'wizard' from base part: */ 56 UIWizard* wizardImp() { return UIWizardPage::wizard(); } 57 /* Wrapper to access 'this' from base part: */ 58 UIWizardPage* thisImp() { return this; } 59 /* Wrapper to access 'wizard-field' from base part: */ 60 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 61 62 private slots: 63 64 /* VM Selector selection change handler: */ 65 void sltVMSelectionChangeHandler(); 66 67 /* Storage-type change handler: */ 68 void sltStorageTypeChangeHandler(); 40 69 41 70 private: 71 72 /* Field API: */ 73 QVariant field(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 42 74 43 75 /* Translate stuff: */ … … 50 82 bool isComplete() const; 51 83 bool validatePage(); 52 53 /* Navigation stuff: */54 int nextId() const;55 56 /* Helping stuff: */57 void populateVMSelectorItems();58 59 /* Stuff for 'machineNames' field: */60 QStringList machineNames() const;61 62 /* Stuff for 'machineIDs' field: */63 QStringList machineIDs() const;64 65 /* Variables: */66 QStringList m_selectedVMNames;67 68 /* Widgets: */69 QIRichTextLabel *m_pLabel;70 QListWidget *m_pVMSelector;71 84 }; 72 85 73 #endif /* __UIWizardExportAppPage Basic1_h__ */86 #endif /* __UIWizardExportAppPageExpert_h__ */ 74 87 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRun.cpp
r40870 r41021 23 23 #include "UIWizardFirstRunPageBasic2.h" 24 24 #include "UIWizardFirstRunPageBasic3.h" 25 #include "UIWizardFirstRunPageExpert.h" 25 26 #include "VBoxGlobal.h" 26 27 #include "UIMessageCenter.h" 27 28 28 29 UIWizardFirstRun::UIWizardFirstRun(QWidget *pParent, const CMachine &machine) 29 : UIWizard(pParent )30 : UIWizard(pParent, UIWizardType_FirstRun) 30 31 , m_machine(machine) 32 , m_fHardDiskWasSet(isBootHardDiskAttached(m_machine)) 31 33 { 32 /* Check if boot hard disk was set: */33 bool fHardDiskWasSet = isBootHardDiskAttached(machine);34 35 /* Create & add pages: */36 setPage(Page1, new UIWizardFirstRunPageBasic1(fHardDiskWasSet));37 setPage(Page2, new UIWizardFirstRunPageBasic2(machine, fHardDiskWasSet));38 setPage(Page3, new UIWizardFirstRunPageBasic3(fHardDiskWasSet));39 40 /* Translate wizard: */41 retranslateUi();42 43 /* Translate wizard pages: */44 retranslateAllPages();45 46 34 #ifndef Q_WS_MAC 47 35 /* Assign watermark: */ … … 51 39 assignBackground(":/vmw_first_run_bg.png"); 52 40 #endif /* Q_WS_MAC */ 53 54 /* Resize to 'golden ratio': */55 resizeToGoldenRatio(UIWizardType_FirstRun);56 41 } 57 42 … … 103 88 void UIWizardFirstRun::retranslateUi() 104 89 { 90 /* Call to base-class: */ 91 UIWizard::retranslateUi(); 92 105 93 /* Translate wizard: */ 106 94 setWindowTitle(tr("First Run Wizard")); 107 95 setButtonText(QWizard::FinishButton, tr("Start")); 96 } 97 98 void UIWizardFirstRun::prepare() 99 { 100 /* Create corresponding pages: */ 101 switch (mode()) 102 { 103 case UIWizardMode_Basic: 104 { 105 setPage(Page1, new UIWizardFirstRunPageBasic1(m_fHardDiskWasSet)); 106 setPage(Page2, new UIWizardFirstRunPageBasic2(m_machine.GetId(), m_fHardDiskWasSet)); 107 setPage(Page3, new UIWizardFirstRunPageBasic3(m_fHardDiskWasSet)); 108 break; 109 } 110 case UIWizardMode_Expert: 111 { 112 setPage(PageExpert, new UIWizardFirstRunPageExpert(m_machine.GetId(), m_fHardDiskWasSet)); 113 break; 114 } 115 } 116 /* Call to base-class: */ 117 UIWizard::prepare(); 108 118 } 109 119 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRun.h
r40870 r41021 39 39 }; 40 40 41 /* Page IDs: */ 42 enum 43 { 44 PageExpert 45 }; 46 41 47 /* Constructor: */ 42 48 UIWizardFirstRun(QWidget *pParent, const CMachine &machine); … … 49 55 /* Who will be able to export appliance: */ 50 56 friend class UIWizardFirstRunPageBasic3; 57 friend class UIWizardFirstRunPageExpert; 51 58 52 59 private: … … 55 62 void retranslateUi(); 56 63 64 /* Pages related stuff: */ 65 void prepare(); 66 57 67 /* Helping stuff: */ 58 68 static bool isBootHardDiskAttached(const CMachine &machine); … … 60 70 /* Variables: */ 61 71 CMachine m_machine; 72 bool m_fHardDiskWasSet; 62 73 }; 63 74 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic1.cpp
r40870 r41021 26 26 #include "QIRichTextLabel.h" 27 27 28 UIWizardFirstRunPage1::UIWizardFirstRunPage1(bool fBootHardDiskWasSet) 29 : m_fBootHardDiskWasSet(fBootHardDiskWasSet) 30 { 31 } 32 28 33 UIWizardFirstRunPageBasic1::UIWizardFirstRunPageBasic1(bool fBootHardDiskWasSet) 29 : m_fBootHardDiskWasSet(fBootHardDiskWasSet)34 : UIWizardFirstRunPage1(fBootHardDiskWasSet) 30 35 { 31 36 /* Create widgets: */ 32 37 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 38 { 33 39 m_pLabel = new QIRichTextLabel(this); 34 pMainLayout->addWidget(m_pLabel); 35 pMainLayout->addStretch(); 40 pMainLayout->addWidget(m_pLabel); 41 pMainLayout->addStretch(); 42 } 36 43 } 37 44 … … 39 46 { 40 47 /* Translate page: */ 41 setTitle(UIWizardFirstRun::tr("Welcome to the First Run Wizard!"));48 setTitle(UIWizardFirstRun::tr("Welcome to the First Run wizard!")); 42 49 43 50 /* Translate widgets: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic1.h
r40870 r41021 26 26 class QIRichTextLabel; 27 27 28 /* 1st page of the First Run wizard: */ 29 class UIWizardFirstRunPageBasic1 : public UIWizardPage 28 /* 1st page of the First Run wizard (base part): */ 29 class UIWizardFirstRunPage1 : public UIWizardPageBase 30 { 31 protected: 32 33 /* Constructor: */ 34 UIWizardFirstRunPage1(bool fBootHardDiskWasSet); 35 36 /* Variables: */ 37 bool m_fBootHardDiskWasSet; 38 }; 39 40 /* 1st page of the First Run wizard (basic extension): */ 41 class UIWizardFirstRunPageBasic1 : public UIWizardPage, public UIWizardFirstRunPage1 30 42 { 31 43 Q_OBJECT; … … 44 56 void initializePage(); 45 57 46 /* Variables: */47 bool m_fBootHardDiskWasSet;48 49 58 /* Widgets: */ 50 59 QIRichTextLabel *m_pLabel; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic2.cpp
r40870 r41021 28 28 #include "COMDefs.h" 29 29 #include "UIIconPool.h" 30 #include "VBoxGlobal.h" 30 31 #include "UIMessageCenter.h" 31 #include "QIRichTextLabel.h"32 32 #include "VBoxMediaComboBox.h" 33 33 #include "QIToolButton.h" 34 #include "QIRichTextLabel.h" 34 35 35 UIWizardFirstRunPage Basic2::UIWizardFirstRunPageBasic2(const CMachine &machine,bool fBootHardDiskWasSet)36 UIWizardFirstRunPage2::UIWizardFirstRunPage2(bool fBootHardDiskWasSet) 36 37 : m_fBootHardDiskWasSet(fBootHardDiskWasSet) 38 { 39 } 40 41 void UIWizardFirstRunPage2::onOpenMediumWithFileOpenDialog() 42 { 43 /* Get opened vboxMedium id: */ 44 QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(m_pMediaSelector->type(), thisImp()); 45 /* Update medium-combo if necessary: */ 46 if (!strMediumId.isNull()) 47 m_pMediaSelector->setCurrentItem(strMediumId); 48 } 49 50 QString UIWizardFirstRunPage2::id() const 51 { 52 return m_pMediaSelector->id(); 53 } 54 55 void UIWizardFirstRunPage2::setId(const QString &strId) 56 { 57 m_pMediaSelector->setCurrentItem(strId); 58 } 59 60 UIWizardFirstRunPageBasic2::UIWizardFirstRunPageBasic2(const QString &strMachineId, bool fBootHardDiskWasSet) 61 : UIWizardFirstRunPage2(fBootHardDiskWasSet) 37 62 { 38 63 /* Create widgets: */ 39 64 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 65 { 40 66 m_pLabel = new QIRichTextLabel(this); 41 m_pCntSource = new QGroupBox(this); 42 m_pCntSource->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 43 QHBoxLayout *pSourceLayout = new QHBoxLayout(m_pCntSource); 44 m_pMediaSelector = new VBoxMediaComboBox(m_pCntSource); 45 m_pMediaSelector->setMachineId(machine.GetId()); 67 m_pSourceCnt = new QGroupBox(this); 68 { 69 m_pSourceCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 70 QHBoxLayout *pSourceCntLayout = new QHBoxLayout(m_pSourceCnt); 71 { 72 m_pMediaSelector = new VBoxMediaComboBox(m_pSourceCnt); 73 { 74 m_pMediaSelector->setMachineId(strMachineId); 46 75 m_pMediaSelector->setType(VBoxDefs::MediumType_DVD); 47 76 m_pMediaSelector->repopulate(); 48 m_pSelectMediaButton = new QIToolButton(m_pCntSource); 77 } 78 m_pSelectMediaButton = new QIToolButton(m_pSourceCnt); 79 { 49 80 m_pSelectMediaButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png")); 50 81 m_pSelectMediaButton->setAutoRaise(true); 51 pSourceLayout->addWidget(m_pMediaSelector); 52 pSourceLayout->addWidget(m_pSelectMediaButton); 53 pMainLayout->addWidget(m_pLabel); 54 pMainLayout->addWidget(m_pCntSource); 55 pMainLayout->addStretch(); 82 } 83 pSourceCntLayout->addWidget(m_pMediaSelector); 84 pSourceCntLayout->addWidget(m_pSelectMediaButton); 85 } 86 } 87 pMainLayout->addWidget(m_pLabel); 88 pMainLayout->addWidget(m_pSourceCnt); 89 pMainLayout->addStretch(); 90 } 56 91 57 92 /* Setup connections: */ 58 93 connect(m_pMediaSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged())); 59 connect(m_pSelectMediaButton, SIGNAL(clicked()), this, SLOT(sltOpen WithFileOpenDialog()));94 connect(m_pSelectMediaButton, SIGNAL(clicked()), this, SLOT(sltOpenMediumWithFileOpenDialog())); 60 95 61 96 /* Register fields: */ … … 64 99 } 65 100 66 void UIWizardFirstRunPageBasic2::sltOpen WithFileOpenDialog()101 void UIWizardFirstRunPageBasic2::sltOpenMediumWithFileOpenDialog() 67 102 { 68 /* Get opened vboxMedium id: */ 69 QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(m_pMediaSelector->type(), this); 70 /* Update medium-combo if necessary: */ 71 if (!strMediumId.isNull()) 72 m_pMediaSelector->setCurrentItem(strMediumId); 103 /* Call to base-class: */ 104 onOpenMediumWithFileOpenDialog(); 73 105 } 74 106 … … 87 119 "you want to work with. This media must be bootable, " 88 120 "otherwise the operating system will not be able to start.</p>")); 89 m_pCntSource->setTitle(UIWizardFirstRun::tr("Media Source")); 121 m_pSourceCnt->setTitle(UIWizardFirstRun::tr("Media Source")); 122 m_pSelectMediaButton->setToolTip(VBoxGlobal::tr("Choose a virtual CD/DVD disk file")); 90 123 } 91 124 … … 94 127 /* Translate page: */ 95 128 retranslateUi(); 96 97 /* Media selector should have focus initially: */98 m_pMediaSelector->setFocus();99 129 } 100 130 101 131 bool UIWizardFirstRunPageBasic2::isComplete() const 102 132 { 133 /* Make sure valid medium chosen: */ 103 134 return !vboxGlobal().findMedium(id()).isNull(); 104 135 } … … 109 140 } 110 141 111 QString UIWizardFirstRunPageBasic2::id() const112 {113 return m_pMediaSelector->id();114 }115 116 void UIWizardFirstRunPageBasic2::setId(const QString &strId)117 {118 m_pMediaSelector->setCurrentItem(strId);119 }120 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic2.h
r40870 r41021 25 25 /* Forward declarations: */ 26 26 class CMachine; 27 class QIRichTextLabel;28 27 class QGroupBox; 29 28 class VBoxMediaComboBox; 30 29 class QIToolButton; 30 class QIRichTextLabel; 31 31 32 /* 2nd page of the First Run wizard: */ 33 class UIWizardFirstRunPageBasic2 : public UIWizardPage 32 /* 2nd page of the First Run wizard (base part): */ 33 class UIWizardFirstRunPage2 : public UIWizardPageBase 34 { 35 protected: 36 37 /* Constructor: */ 38 UIWizardFirstRunPage2(bool fBootHardDiskWasSet); 39 40 /* Handlers: */ 41 void onOpenMediumWithFileOpenDialog(); 42 43 /* Stuff for 'id' field: */ 44 QString id() const; 45 void setId(const QString &strId); 46 47 /* Variables: */ 48 bool m_fBootHardDiskWasSet; 49 50 /* Widgets: */ 51 QGroupBox *m_pSourceCnt; 52 VBoxMediaComboBox *m_pMediaSelector; 53 QIToolButton *m_pSelectMediaButton; 54 }; 55 56 /* 2nd page of the First Run wizard (basic extension): */ 57 class UIWizardFirstRunPageBasic2 : public UIWizardPage, public UIWizardFirstRunPage2 34 58 { 35 59 Q_OBJECT; … … 40 64 41 65 /* Constructor: */ 42 UIWizardFirstRunPageBasic2(const CMachine &machine, bool fBootHardDiskWasSet); 66 UIWizardFirstRunPageBasic2(const QString &strMachineId, bool fBootHardDiskWasSet); 67 68 protected: 69 70 /* Wrapper to access 'this' from base part: */ 71 UIWizardPage* thisImp() { return this; } 43 72 44 73 private slots: 45 74 46 75 /* Open with file-open dialog: */ 47 void sltOpen WithFileOpenDialog();76 void sltOpenMediumWithFileOpenDialog(); 48 77 49 78 private: … … 61 90 QString source() const; 62 91 63 /* Stuff for 'id' field: */64 QString id() const;65 void setId(const QString &strId);66 67 /* Variables: */68 bool m_fBootHardDiskWasSet;69 70 92 /* Widgets: */ 71 93 QIRichTextLabel *m_pLabel; 72 QGroupBox *m_pCntSource;73 VBoxMediaComboBox *m_pMediaSelector;74 QIToolButton *m_pSelectMediaButton;75 94 }; 76 95 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic3.cpp
r40870 r41021 26 26 #include "QIRichTextLabel.h" 27 27 28 UIWizardFirstRunPage3::UIWizardFirstRunPage3(bool fBootHardDiskWasSet) 29 : m_fBootHardDiskWasSet(fBootHardDiskWasSet) 30 { 31 } 32 28 33 UIWizardFirstRunPageBasic3::UIWizardFirstRunPageBasic3(bool fBootHardDiskWasSet) 29 : m_fBootHardDiskWasSet(fBootHardDiskWasSet)34 : UIWizardFirstRunPage3(fBootHardDiskWasSet) 30 35 { 31 36 /* Create widgets: */ 32 37 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 38 { 33 39 m_pLabel1 = new QIRichTextLabel(this); 34 40 m_pSummaryText = new QIRichTextLabel(this); 35 41 m_pLabel2 = new QIRichTextLabel(this); 36 pMainLayout->addWidget(m_pLabel1); 37 pMainLayout->addWidget(m_pSummaryText); 38 pMainLayout->addWidget(m_pLabel2); 39 pMainLayout->addStretch(); 42 pMainLayout->addWidget(m_pLabel1); 43 pMainLayout->addWidget(m_pSummaryText); 44 pMainLayout->addWidget(m_pLabel2); 45 pMainLayout->addStretch(); 46 } 40 47 } 41 48 … … 93 100 bool UIWizardFirstRunPageBasic3::validatePage() 94 101 { 95 /* Insert chosen medium: */ 102 /* Initial result: */ 103 bool fResult = true; 104 105 /* Lock finish button: */ 96 106 startProcessing(); 97 bool fResult = qobject_cast<UIWizardFirstRun*>(wizard())->insertMedium(); 107 108 /* Try to insert chosen medium: */ 109 if (fResult) 110 fResult = qobject_cast<UIWizardFirstRun*>(wizard())->insertMedium(); 111 112 /* Unlock finish button: */ 98 113 endProcessing(); 114 115 /* Return result: */ 99 116 return fResult; 100 117 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic3.h
r40870 r41021 26 26 class QIRichTextLabel; 27 27 28 /* 3rd page of the First Run wizard: */ 29 class UIWizardFirstRunPageBasic3 : public UIWizardPage 28 /* 3rd page of the First Run wizard (base part): */ 29 class UIWizardFirstRunPage3 : public UIWizardPageBase 30 { 31 protected: 32 33 /* Constructor: */ 34 UIWizardFirstRunPage3(bool fBootHardDiskWasSet); 35 36 /* Variables: */ 37 bool m_fBootHardDiskWasSet; 38 }; 39 40 /* 3rd page of the First Run wizard (basic extension): */ 41 class UIWizardFirstRunPageBasic3 : public UIWizardPage, public UIWizardFirstRunPage3 30 42 { 31 43 Q_OBJECT; … … 47 59 bool validatePage(); 48 60 49 /* Variables: */50 bool m_fBootHardDiskWasSet;51 52 61 /* Widgets: */ 53 62 QIRichTextLabel *m_pLabel1; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageExpert.cpp
r40929 r41021 3 3 * 4 4 * VBox frontends: Qt4 GUI ("VirtualBox"): 5 * UIWizardFirstRunPage Basic1class implementation5 * UIWizardFirstRunPageExpert class implementation 6 6 */ 7 7 … … 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QHBoxLayout> 23 #include <QGroupBox> 22 24 23 25 /* Local includes: */ 24 #include "UIWizardFirstRunPage Basic1.h"26 #include "UIWizardFirstRunPageExpert.h" 25 27 #include "UIWizardFirstRun.h" 26 #include "QIRichTextLabel.h" 28 #include "VBoxGlobal.h" 29 #include "UIIconPool.h" 30 #include "VBoxMediaComboBox.h" 31 #include "QIToolButton.h" 27 32 28 UIWizardFirstRunPageBasic1::UIWizardFirstRunPageBasic1(bool fBootHardDiskWasSet) 29 : m_fBootHardDiskWasSet(fBootHardDiskWasSet) 33 UIWizardFirstRunPageExpert::UIWizardFirstRunPageExpert(const QString &strMachineId, bool fBootHardDiskWasSet) 34 : UIWizardFirstRunPage1(fBootHardDiskWasSet) 35 , UIWizardFirstRunPage2(fBootHardDiskWasSet) 36 , UIWizardFirstRunPage3(fBootHardDiskWasSet) 30 37 { 31 38 /* Create widgets: */ 32 39 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 33 m_pLabel = new QIRichTextLabel(this); 34 pMainLayout->addWidget(m_pLabel); 35 pMainLayout->addStretch(); 40 { 41 pMainLayout->setContentsMargins(8, 6, 8, 6); 42 m_pSourceCnt = new QGroupBox(this); 43 { 44 m_pSourceCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 45 QHBoxLayout *pSourceCntLayout = new QHBoxLayout(m_pSourceCnt); 46 { 47 m_pMediaSelector = new VBoxMediaComboBox(m_pSourceCnt); 48 { 49 m_pMediaSelector->setMachineId(strMachineId); 50 m_pMediaSelector->setType(VBoxDefs::MediumType_DVD); 51 m_pMediaSelector->repopulate(); 52 } 53 m_pSelectMediaButton = new QIToolButton(m_pSourceCnt); 54 { 55 m_pSelectMediaButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png")); 56 m_pSelectMediaButton->setAutoRaise(true); 57 } 58 pSourceCntLayout->addWidget(m_pMediaSelector); 59 pSourceCntLayout->addWidget(m_pSelectMediaButton); 60 } 61 } 62 pMainLayout->addWidget(m_pSourceCnt); 63 pMainLayout->addStretch(); 64 } 65 66 /* Setup connections: */ 67 connect(m_pMediaSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged())); 68 connect(m_pSelectMediaButton, SIGNAL(clicked()), this, SLOT(sltOpenMediumWithFileOpenDialog())); 69 70 /* Register fields: */ 71 registerField("id", this, "id"); 36 72 } 37 73 38 void UIWizardFirstRunPage Basic1::retranslateUi()74 void UIWizardFirstRunPageExpert::sltOpenMediumWithFileOpenDialog() 39 75 { 40 /* Translate page: */ 41 setTitle(UIWizardFirstRun::tr("Welcome to the First Run Wizard!")); 42 43 /* Translate widgets: */ 44 if (m_fBootHardDiskWasSet) 45 m_pLabel->setText(UIWizardFirstRun::tr("<p>You have started a newly created virtual machine for the " 46 "first time. This wizard will help you to perform the steps " 47 "necessary for installing an operating system of your choice " 48 "onto this virtual machine.</p><p>%1</p>") 49 .arg(standardHelpText())); 50 else 51 m_pLabel->setText(UIWizardFirstRun::tr("<p>You have started a newly created virtual machine for the " 52 "first time. This wizard will help you to perform the steps " 53 "necessary for booting an operating system of your choice on " 54 "the virtual machine.</p><p>Note that you will not be able to " 55 "install an operating system into this virtual machine right " 56 "now because you did not attach any hard disk to it. If this " 57 "is not what you want, you can cancel the execution of this " 58 "wizard, select <b>Settings</b> from the <b>Machine</b> menu " 59 "of the main VirtualBox window to access the settings dialog " 60 "of this machine and change the hard disk configuration.</p>" 61 "<p>%1</p>") 62 .arg(standardHelpText())); 76 /* Call to base-class: */ 77 onOpenMediumWithFileOpenDialog(); 63 78 } 64 79 65 void UIWizardFirstRunPageBasic1::initializePage() 80 void UIWizardFirstRunPageExpert::retranslateUi() 81 { 82 /* Translate widgets: */ 83 m_pSourceCnt->setTitle(UIWizardFirstRun::tr("Media Source")); 84 m_pSelectMediaButton->setToolTip(VBoxGlobal::tr("Choose a virtual CD/DVD disk file")); 85 } 86 87 void UIWizardFirstRunPageExpert::initializePage() 66 88 { 67 89 /* Translate page: */ … … 69 91 } 70 92 93 bool UIWizardFirstRunPageExpert::isComplete() const 94 { 95 /* Make sure valid medium chosen: */ 96 return !vboxGlobal().findMedium(id()).isNull(); 97 } 98 99 bool UIWizardFirstRunPageExpert::validatePage() 100 { 101 /* Initial result: */ 102 bool fResult = true; 103 104 /* Lock finish button: */ 105 startProcessing(); 106 107 /* Try to insert chosen medium: */ 108 if (fResult) 109 fResult = qobject_cast<UIWizardFirstRun*>(wizard())->insertMedium(); 110 111 /* Unlock finish button: */ 112 endProcessing(); 113 114 /* Return result: */ 115 return fResult; 116 } 117 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageExpert.h
r40929 r41021 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * UIWizardFirstRunPage Basic1class declaration4 * UIWizardFirstRunPageExpert class declaration 5 5 */ 6 6 … … 17 17 */ 18 18 19 #ifndef __UIWizardFirstRunPage Basic1_h__20 #define __UIWizardFirstRunPage Basic1_h__19 #ifndef __UIWizardFirstRunPageExpert_h__ 20 #define __UIWizardFirstRunPageExpert_h__ 21 21 22 22 /* Local includes: */ 23 #include "UIWizardPage.h" 23 #include "UIWizardFirstRunPageBasic1.h" 24 #include "UIWizardFirstRunPageBasic2.h" 25 #include "UIWizardFirstRunPageBasic3.h" 24 26 25 /* Forward declarations: */26 class QIRichTextLabel;27 28 /* 1st page of the First Run wizard: */ 29 class UIWizardFirstRunPageBasic1 : public UIWizardPage 27 /* Expert page of the First Run wizard: */ 28 class UIWizardFirstRunPageExpert : public UIWizardPage, 29 public UIWizardFirstRunPage1, 30 public UIWizardFirstRunPage2, 31 public UIWizardFirstRunPage3 30 32 { 31 33 Q_OBJECT; 34 Q_PROPERTY(QString id READ id WRITE setId); 32 35 33 36 public: 34 37 35 38 /* Constructor: */ 36 UIWizardFirstRunPageBasic1(bool fBootHardDiskWasSet); 39 UIWizardFirstRunPageExpert(const QString &strMachineId, bool fBootHardDiskWasSet); 40 41 protected: 42 43 /* Wrapper to access 'this' from base part: */ 44 UIWizardPage* thisImp() { return this; } 45 46 private slots: 47 48 /* Open with file-open dialog: */ 49 void sltOpenMediumWithFileOpenDialog(); 37 50 38 51 private: … … 44 57 void initializePage(); 45 58 46 /* Variables: */ 47 bool m_fBootHardDiskWasSet; 48 49 /* Widgets: */ 50 QIRichTextLabel *m_pLabel; 59 /* Validation stuff: */ 60 bool isComplete() const; 61 bool validatePage(); 51 62 }; 52 63 53 #endif // __UIWizardFirstRunPage Basic1_h__64 #endif // __UIWizardFirstRunPageExpert_h__ 54 65 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportApp.cpp
r40870 r41021 29 29 #include "UIWizardImportAppPageBasic1.h" 30 30 #include "UIWizardImportAppPageBasic2.h" 31 #include "UIWizardImportAppPageExpert.h" 31 32 #include "VBoxGlobal.h" 32 33 #include "QIDialog.h" … … 134 135 }; 135 136 136 UIWizardImportApp::UIWizardImportApp(const QString &strFileName /* = QString() */, QWidget *pParent /* = 0 */) 137 : UIWizard(pParent) 138 { 139 /* Create & add pages: */ 140 if (strFileName.isEmpty()) 141 setPage(Page1, new UIWizardImportAppPageBasic1); 142 setPage(Page2, new UIWizardImportAppPageBasic2(strFileName)); 143 144 /* Translate wizard: */ 145 retranslateUi(); 146 147 /* Translate wizard pages: */ 148 retranslateAllPages(); 149 137 UIWizardImportApp::UIWizardImportApp(QWidget *pParent, const QString &strFileName) 138 : UIWizard(pParent, UIWizardType_ImportAppliance) 139 , m_strFileName(strFileName) 140 { 150 141 #ifndef Q_WS_MAC 151 142 /* Assign watermark: */ … … 155 146 assignBackground(":/vmw_ovf_import_bg.png"); 156 147 #endif /* Q_WS_MAC */ 157 158 /* Resize wizard to 'golden ratio': */159 resizeToGoldenRatio(UIWizardType_ImportAppliance);160 161 /* Setup connections: */162 AssertMsg(!field("applianceWidget").value<ImportAppliancePointer>().isNull(), ("Appliance Widget is not set!\n"));163 connect(this, SIGNAL(customButtonClicked(int)), field("applianceWidget").value<ImportAppliancePointer>(), SLOT(restoreDefaults()));164 connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(sltCurrentIdChanged(int)));165 166 /* Make sure custom button shown even if final page is first to show: */167 sltCurrentIdChanged(startId());168 148 } 169 149 … … 174 154 fResult = pImportApplianceWidget->isValid(); 175 155 return fResult; 176 }177 178 void UIWizardImportApp::retranslateUi()179 {180 /* Translate wizard: */181 setWindowTitle(tr("Appliance Import Wizard"));182 setButtonText(QWizard::CustomButton1, tr("Restore Defaults"));183 setButtonText(QWizard::FinishButton, tr("Import"));184 }185 186 void UIWizardImportApp::sltCurrentIdChanged(int iId)187 {188 setOption(QWizard::HaveCustomButton1, iId == Page2);189 156 } 190 157 … … 212 179 } 213 180 181 void UIWizardImportApp::sltCurrentIdChanged(int iId) 182 { 183 /* Call to base-class: */ 184 UIWizard::sltCurrentIdChanged(iId); 185 /* Enable 2nd button (Reset to Defaults) for 2nd and Expert pages only! */ 186 setOption(QWizard::HaveCustomButton2, (mode() == UIWizardMode_Basic && iId == Page2) || 187 (mode() == UIWizardMode_Expert && iId == PageExpert)); 188 } 189 190 void UIWizardImportApp::sltCustomButtonClicked(int iId) 191 { 192 /* Call to base-class: */ 193 UIWizard::sltCustomButtonClicked(iId); 194 195 /* Handle 2nd button: */ 196 if (iId == CustomButton2) 197 { 198 /* Get appliance widget: */ 199 ImportAppliancePointer pApplianceWidget = field("applianceWidget").value<ImportAppliancePointer>(); 200 AssertMsg(!pApplianceWidget.isNull(), ("Appliance Widget is not set!\n")); 201 /* Reset it to default: */ 202 pApplianceWidget->restoreDefaults(); 203 } 204 } 205 206 void UIWizardImportApp::retranslateUi() 207 { 208 /* Call to base-class: */ 209 UIWizard::retranslateUi(); 210 211 /* Translate wizard: */ 212 setWindowTitle(tr("Appliance Import Wizard")); 213 setButtonText(QWizard::CustomButton2, tr("Restore Defaults")); 214 setButtonText(QWizard::FinishButton, tr("Import")); 215 } 216 217 void UIWizardImportApp::prepare() 218 { 219 /* Create corresponding pages: */ 220 switch (mode()) 221 { 222 case UIWizardMode_Basic: 223 { 224 if (m_strFileName.isEmpty()) 225 setPage(Page1, new UIWizardImportAppPageBasic1); 226 setPage(Page2, new UIWizardImportAppPageBasic2(m_strFileName)); 227 break; 228 } 229 case UIWizardMode_Expert: 230 { 231 setPage(PageExpert, new UIWizardImportAppPageExpert(m_strFileName)); 232 break; 233 } 234 } 235 /* Call to base-class: */ 236 UIWizard::prepare(); 237 } 238 214 239 #include "UIWizardImportApp.moc" 215 240 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportApp.h
r40870 r41021 37 37 }; 38 38 39 /* Page IDs: */ 40 enum 41 { 42 PageExpert 43 }; 44 39 45 /* Constructor: */ 40 UIWizardImportApp( const QString &strFileName = QString(), QWidget *pParent = 0);46 UIWizardImportApp(QWidget *pParent, const QString &strFileName); 41 47 42 48 /* Is appliance valid? */ … … 50 56 /* Who will be able to import appliance: */ 51 57 friend class UIWizardImportAppPageBasic2; 58 friend class UIWizardImportAppPageExpert; 52 59 53 60 private slots: … … 55 62 /* Page change handler: */ 56 63 void sltCurrentIdChanged(int iId); 64 /* Custom button 2 click handler: */ 65 void sltCustomButtonClicked(int iId); 57 66 58 67 private: … … 60 69 /* Translation stuff: */ 61 70 void retranslateUi(); 71 72 /* Pages related stuff: */ 73 void prepare(); 74 75 /* Variables: */ 76 QString m_strFileName; 62 77 }; 63 78 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp
r40870 r41021 27 27 #include "UIWizardImportApp.h" 28 28 #include "VBoxGlobal.h" 29 #include "VBoxFilePathSelectorWidget.h" 29 30 #include "QIRichTextLabel.h" 30 #include "VBoxFilePathSelectorWidget.h" 31 32 UIWizardImportAppPage1::UIWizardImportAppPage1() 33 { 34 } 31 35 32 36 UIWizardImportAppPageBasic1::UIWizardImportAppPageBasic1() … … 34 38 /* Create widgets: */ 35 39 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 40 { 36 41 m_pLabel = new QIRichTextLabel(this); 37 42 m_pFileSelector = new VBoxEmptyFileSelector(this); 43 { 38 44 m_pFileSelector->setMode(VBoxFilePathSelectorWidget::Mode_File_Open); 39 45 m_pFileSelector->setHomeDir(vboxGlobal().documentsPath()); 40 pMainLayout->addWidget(m_pLabel); 41 pMainLayout->addWidget(m_pFileSelector); 42 pMainLayout->addStretch(); 46 } 47 pMainLayout->addWidget(m_pLabel); 48 pMainLayout->addWidget(m_pFileSelector); 49 pMainLayout->addStretch(); 50 } 43 51 44 52 /* Setup connections: */ … … 49 57 { 50 58 /* Translate page: */ 51 setTitle(UIWizardImportApp::tr("Welcome to the Appliance Import Wizard!"));59 setTitle(UIWizardImportApp::tr("Welcome to the Appliance Import wizard!")); 52 60 53 61 /* Translate widgets: */ 54 m_pFileSelector->setFileDialogTitle(UIWizardImportApp::tr("Select an appliance to import"));55 m_pFileSelector->setFileFilters(UIWizardImportApp::tr("Open Virtualization Format (%1)").arg("*.ova *.ovf"));56 62 m_pLabel->setText(UIWizardImportApp::tr("<p>This wizard will guide you through importing an appliance.</p>" 57 63 "<p>%1</p><p>VirtualBox currently supports importing appliances " … … 59 65 "select the file to import below:</p>") 60 66 .arg(standardHelpText())); 67 m_pFileSelector->setChooseButtonText(UIWizardImportApp::tr("Open appliance...")); 68 m_pFileSelector->setFileDialogTitle(UIWizardImportApp::tr("Select an appliance to import")); 69 m_pFileSelector->setFileFilters(UIWizardImportApp::tr("Open Virtualization Format (%1)").arg("*.ova *.ovf")); 61 70 } 62 71 … … 69 78 bool UIWizardImportAppPageBasic1::isComplete() const 70 79 { 71 const QString &strFile = m_pFileSelector->path().toLower(); 72 return VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts) && QFileInfo(m_pFileSelector->path()).exists(); 80 /* Make sure appliance file has allowed extension and exists: */ 81 return VBoxGlobal::hasAllowedExtension(m_pFileSelector->path().toLower(), VBoxDefs::OVFFileExts) && 82 QFileInfo(m_pFileSelector->path()).exists(); 73 83 } 74 84 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.h
r40870 r41021 24 24 25 25 /* Forward declarations: */ 26 class VBoxEmptyFileSelector; 26 27 class QIRichTextLabel; 27 class VBoxEmptyFileSelector;28 28 29 /* 1st page of the Import Appliance wizard: */ 30 class UIWizardImportAppPageBasic1 : public UIWizardPage 29 /* 1st page of the Import Appliance wizard (base part): */ 30 class UIWizardImportAppPage1 : public UIWizardPageBase 31 { 32 protected: 33 34 /* Constructor: */ 35 UIWizardImportAppPage1(); 36 37 /* Widgets: */ 38 VBoxEmptyFileSelector *m_pFileSelector; 39 }; 40 41 /* 1st page of the Import Appliance wizard (basic extension): */ 42 class UIWizardImportAppPageBasic1 : public UIWizardPage, public UIWizardImportAppPage1 31 43 { 32 44 Q_OBJECT; … … 51 63 /* Widgets: */ 52 64 QIRichTextLabel *m_pLabel; 53 VBoxEmptyFileSelector *m_pFileSelector;54 65 }; 55 66 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.cpp
r40870 r41021 26 26 #include "QIRichTextLabel.h" 27 27 28 UIWizardImportAppPage2::UIWizardImportAppPage2() 29 { 30 } 31 28 32 UIWizardImportAppPageBasic2::UIWizardImportAppPageBasic2(const QString &strFileName) 29 33 { 30 34 /* Create widgets: */ 31 35 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 36 { 32 37 m_pLabel = new QIRichTextLabel(this); 33 38 m_pApplianceWidget = new UIApplianceImportEditorWidget(this); 39 { 34 40 m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); 35 41 m_pApplianceWidget->setFile(strFileName); 36 pMainLayout->addWidget(m_pLabel); 37 pMainLayout->addWidget(m_pApplianceWidget); 42 } 43 pMainLayout->addWidget(m_pLabel); 44 pMainLayout->addWidget(m_pApplianceWidget); 45 } 38 46 39 /* Register ImportAppliancePointer class: */47 /* Register classes: */ 40 48 qRegisterMetaType<ImportAppliancePointer>(); 41 /* Register 'applianceWidget' field!*/49 /* Register fields: */ 42 50 registerField("applianceWidget", this, "applianceWidget"); 43 51 } … … 71 79 bool UIWizardImportAppPageBasic2::validatePage() 72 80 { 73 /* Import appliance: */ 81 /* Initial result: */ 82 bool fResult = true; 83 84 /* Lock finish button: */ 74 85 startProcessing(); 75 bool fResult = qobject_cast<UIWizardImportApp*>(wizard())->importAppliance(); 86 87 /* Try to import appliance: */ 88 if (fResult) 89 fResult = qobject_cast<UIWizardImportApp*>(wizard())->importAppliance(); 90 91 /* Unlock finish button: */ 76 92 endProcessing(); 93 94 /* Return result: */ 77 95 return fResult; 78 96 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.h
r40870 r41021 28 28 class QIRichTextLabel; 29 29 30 /* 2nd page of the Import Appliance wizard: */ 31 class UIWizardImportAppPageBasic2 : public UIWizardPage 30 /* 2nd page of the Import Appliance wizard (base part): */ 31 class UIWizardImportAppPage2 : public UIWizardPageBase 32 { 33 protected: 34 35 /* Constructor: */ 36 UIWizardImportAppPage2(); 37 38 /* Stuff for 'applianceWidget' field: */ 39 ImportAppliancePointer applianceWidget() const { return m_pApplianceWidget; } 40 41 /* Widgets: */ 42 ImportAppliancePointer m_pApplianceWidget; 43 }; 44 45 /* 2nd page of the Import Appliance wizard (basic extension): */ 46 class UIWizardImportAppPageBasic2 : public UIWizardPage, public UIWizardImportAppPage2 32 47 { 33 48 Q_OBJECT; … … 36 51 public: 37 52 53 /* Constructor: */ 38 54 UIWizardImportAppPageBasic2(const QString &strFileName); 39 55 … … 50 66 bool validatePage(); 51 67 52 /* Stuff for 'applianceWidget' field: */53 ImportAppliancePointer applianceWidget() const { return m_pApplianceWidget; }54 55 68 /* Widgets: */ 56 69 QIRichTextLabel *m_pLabel; 57 ImportAppliancePointer m_pApplianceWidget;58 70 }; 59 71 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageExpert.cpp
r40929 r41021 3 3 * 4 4 * VBox frontends: Qt4 GUI ("VirtualBox"): 5 * UIWizardImportAppPage Basic1class implementation5 * UIWizardImportAppPageExpert class implementation 6 6 */ 7 7 … … 23 23 24 24 /* Local includes: */ 25 #include "UIWizardImportAppPageBasic1.h" 26 #include "UIWizardImportAppPageBasic2.h" 25 #include "UIWizardImportAppPageExpert.h" 27 26 #include "UIWizardImportApp.h" 28 27 #include "VBoxGlobal.h" 29 #include "QIRichTextLabel.h"30 28 #include "VBoxFilePathSelectorWidget.h" 29 #include "UIApplianceImportEditorWidget.h" 31 30 32 UIWizardImportAppPage Basic1::UIWizardImportAppPageBasic1()31 UIWizardImportAppPageExpert::UIWizardImportAppPageExpert(const QString &strFileName) 33 32 { 34 33 /* Create widgets: */ 35 34 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 36 m_pLabel = new QIRichTextLabel(this); 35 { 36 pMainLayout->setContentsMargins(8, 6, 8, 6); 37 37 m_pFileSelector = new VBoxEmptyFileSelector(this); 38 { 38 39 m_pFileSelector->setMode(VBoxFilePathSelectorWidget::Mode_File_Open); 39 40 m_pFileSelector->setHomeDir(vboxGlobal().documentsPath()); 40 pMainLayout->addWidget(m_pLabel); 41 pMainLayout->addWidget(m_pFileSelector); 42 pMainLayout->addStretch(); 41 } 42 m_pApplianceWidget = new UIApplianceImportEditorWidget(this); 43 { 44 m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); 45 m_pApplianceWidget->setFile(strFileName); 46 } 47 pMainLayout->addWidget(m_pFileSelector); 48 pMainLayout->addWidget(m_pApplianceWidget); 49 } 43 50 44 51 /* Setup connections: */ 45 connect(m_pFileSelector, SIGNAL(pathChanged(const QString&)), this, SIGNAL(completeChanged())); 52 connect(m_pFileSelector, SIGNAL(pathChanged(const QString&)), this, SLOT(sltFilePathChangeHandler())); 53 54 /* Register classes: */ 55 qRegisterMetaType<ImportAppliancePointer>(); 56 /* Register fields: */ 57 registerField("applianceWidget", this, "applianceWidget"); 46 58 } 47 59 48 void UIWizardImportAppPage Basic1::retranslateUi()60 void UIWizardImportAppPageExpert::sltFilePathChangeHandler() 49 61 { 50 /* Translate page: */ 51 setTitle(UIWizardImportApp::tr("Welcome to the Appliance Import Wizard!")); 62 /* Check if set file contains valid appliance: */ 63 if (m_pApplianceWidget->setFile(m_pFileSelector->path())) 64 { 65 /* Reset the modified bit if file was correctly set: */ 66 m_pFileSelector->resetModified(); 67 } 52 68 69 emit completeChanged(); 70 } 71 72 void UIWizardImportAppPageExpert::retranslateUi() 73 { 53 74 /* Translate widgets: */ 75 m_pFileSelector->setChooseButtonText(UIWizardImportApp::tr("Open appliance...")); 54 76 m_pFileSelector->setFileDialogTitle(UIWizardImportApp::tr("Select an appliance to import")); 55 77 m_pFileSelector->setFileFilters(UIWizardImportApp::tr("Open Virtualization Format (%1)").arg("*.ova *.ovf")); 56 m_pLabel->setText(UIWizardImportApp::tr("<p>This wizard will guide you through importing an appliance.</p>"57 "<p>%1</p><p>VirtualBox currently supports importing appliances "58 "saved in the Open Virtualization Format (OVF). To continue, "59 "select the file to import below:</p>")60 .arg(standardHelpText()));61 78 } 62 79 63 void UIWizardImportAppPage Basic1::initializePage()80 void UIWizardImportAppPageExpert::initializePage() 64 81 { 65 82 /* Translate page: */ … … 67 84 } 68 85 69 bool UIWizardImportAppPage Basic1::isComplete() const86 bool UIWizardImportAppPageExpert::isComplete() const 70 87 { 71 const QString &strFile = m_pFileSelector->path().toLower(); 72 return VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts) && QFileInfo(m_pFileSelector->path()).exists(); 88 /* Make sure appliance file has allowed extension and exists and appliance widget is valid: */ 89 return VBoxGlobal::hasAllowedExtension(m_pFileSelector->path().toLower(), VBoxDefs::OVFFileExts) && 90 QFileInfo(m_pFileSelector->path()).exists() && 91 m_pApplianceWidget->isValid(); 73 92 } 74 93 75 bool UIWizardImportAppPage Basic1::validatePage()94 bool UIWizardImportAppPageExpert::validatePage() 76 95 { 77 /* Get import appliance widget: */ 78 ImportAppliancePointer pImportApplianceWidget = field("applianceWidget").value<ImportAppliancePointer>(); 79 AssertMsg(!pImportApplianceWidget.isNull(), ("Appliance Widget is not set!\n")); 96 /* Initial result: */ 97 bool fResult = true; 80 98 81 /* If file name was changed: */ 82 if (m_pFileSelector->isModified()) 83 { 84 /* Check if set file contains valid appliance: */ 85 if (!pImportApplianceWidget->setFile(m_pFileSelector->path())) 86 return false; 87 /* Reset the modified bit afterwards: */ 88 m_pFileSelector->resetModified(); 89 } 99 /* Lock finish button: */ 100 startProcessing(); 90 101 91 /* If we have a valid ovf proceed to the appliance settings page: */ 92 return pImportApplianceWidget->isValid(); 102 /* Try to import appliance: */ 103 if (fResult) 104 fResult = qobject_cast<UIWizardImportApp*>(wizard())->importAppliance(); 105 106 /* Unlock finish button: */ 107 endProcessing(); 108 109 /* Return result: */ 110 return fResult; 93 111 } 94 112 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageExpert.h
r40929 r41021 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * UIWizardImportAppPage Basic1class declaration4 * UIWizardImportAppPageExpert class declaration 5 5 */ 6 6 … … 17 17 */ 18 18 19 #ifndef __UIWizardImportAppPage Basic1_h__20 #define __UIWizardImportAppPage Basic1_h__19 #ifndef __UIWizardImportAppPageExpert_h__ 20 #define __UIWizardImportAppPageExpert_h__ 21 21 22 22 /* Local includes: */ 23 #include "UIWizardPage.h" 23 #include "UIWizardImportAppPageBasic1.h" 24 #include "UIWizardImportAppPageBasic2.h" 24 25 25 /* Forward declarations: */ 26 class QIRichTextLabel; 27 class VBoxEmptyFileSelector; 28 29 /* 1st page of the Import Appliance wizard: */ 30 class UIWizardImportAppPageBasic1 : public UIWizardPage 26 /* Expert page of the Import Appliance wizard: */ 27 class UIWizardImportAppPageExpert : public UIWizardPage, 28 public UIWizardImportAppPage1, 29 public UIWizardImportAppPage2 31 30 { 32 31 Q_OBJECT; 32 Q_PROPERTY(ImportAppliancePointer applianceWidget READ applianceWidget); 33 33 34 34 public: 35 35 36 36 /* Constructor: */ 37 UIWizardImportAppPageBasic1(); 37 UIWizardImportAppPageExpert(const QString &strFileName); 38 39 private slots: 40 41 /* File-path change handler: */ 42 void sltFilePathChangeHandler(); 38 43 39 44 private: … … 48 53 bool isComplete() const; 49 54 bool validatePage(); 50 51 /* Widgets: */52 QIRichTextLabel *m_pLabel;53 VBoxEmptyFileSelector *m_pFileSelector;54 55 }; 55 56 56 #endif /* __UIWizardImportAppPage Basic1_h__ */57 #endif /* __UIWizardImportAppPageExpert_h__ */ 57 58 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVD.cpp
r40870 r41021 27 27 #include "UIWizardNewVDPageBasic3.h" 28 28 #include "UIWizardNewVDPageBasic4.h" 29 #include "UIWizardNewVDPageExpert.h" 29 30 #include "VBoxGlobal.h" 30 31 #include "UIMessageCenter.h" 31 32 32 33 UIWizardNewVD::UIWizardNewVD(QWidget *pParent, const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize) 33 : UIWizard(pParent) 34 : UIWizard(pParent, UIWizardType_NewVD) 35 , m_strDefaultName(strDefaultName) 36 , m_strDefaultPath(strDefaultPath) 37 , m_uDefaultSize(uDefaultSize) 34 38 { 35 #ifdef Q_WS_WIN36 /* Hide window icon: */37 setWindowIcon(QIcon());38 #endif /* Q_WS_WIN */39 40 /* Create & add pages: */41 setPage(Page1, new UIWizardNewVDPageBasic1);42 setPage(Page2, new UIWizardNewVDPageBasic2);43 setPage(Page3, new UIWizardNewVDPageBasic3(strDefaultName, strDefaultPath, uDefaultSize));44 setPage(Page4, new UIWizardNewVDPageBasic4);45 46 /* Translate wizard: */47 retranslateUi();48 49 /* Translate wizard pages: */50 retranslateAllPages();51 52 39 #ifndef Q_WS_MAC 53 40 /* Assign watermark: */ … … 57 44 assignBackground(":/vmw_new_harddisk_bg.png"); 58 45 #endif /* Q_WS_MAC */ 59 60 /* Resize wizard to 'golden ratio': */61 resizeToGoldenRatio(UIWizardType_NewVD);62 46 } 63 47 … … 87 71 QString strMediumPath = field("mediumPath").toString(); 88 72 qulonglong uSize = field("mediumSize").toULongLong(); 89 90 73 /* Check attributes: */ 91 74 AssertReturn(!strMediumPath.isNull(), false); … … 106 89 /* Create base storage for the new hard disk: */ 107 90 progress = virtualDisk.CreateBaseStorage(uSize, uVariant); 108 109 /* Check for errors: */110 91 if (!virtualDisk.isOk()) 111 92 { … … 113 94 return false; 114 95 } 96 97 /* Show creation progress: */ 115 98 msgCenter().showModalProgressDialog(progress, windowTitle(), ":/progress_media_create_90px.png", this, true); 116 99 if (progress.GetCanceled()) … … 122 105 } 123 106 124 /* Assign virtualDisk field value: */107 /* Remember created virtual-disk: */ 125 108 m_virtualDisk = virtualDisk; 126 109 … … 133 116 void UIWizardNewVD::retranslateUi() 134 117 { 118 /* Call to base-class: */ 119 UIWizard::retranslateUi(); 120 135 121 /* Translate wizard: */ 136 122 setWindowTitle(tr("Create New Virtual Disk")); … … 138 124 } 139 125 126 void UIWizardNewVD::prepare() 127 { 128 /* Create corresponding pages: */ 129 switch (mode()) 130 { 131 case UIWizardMode_Basic: 132 { 133 setPage(Page1, new UIWizardNewVDPageBasic1); 134 setPage(Page2, new UIWizardNewVDPageBasic2); 135 setPage(Page3, new UIWizardNewVDPageBasic3(m_strDefaultName, m_strDefaultPath, m_uDefaultSize)); 136 setPage(Page4, new UIWizardNewVDPageBasic4); 137 break; 138 } 139 case UIWizardMode_Expert: 140 { 141 setPage(PageExpert, new UIWizardNewVDPageExpert(m_strDefaultName, m_strDefaultPath, m_uDefaultSize)); 142 break; 143 } 144 } 145 /* Call to base-class: */ 146 UIWizard::prepare(); 147 } 148 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVD.h
r40870 r41021 40 40 }; 41 41 42 /* Page IDs: */ 43 enum 44 { 45 PageExpert 46 }; 47 42 48 /* Constructor: */ 43 UIWizardNewVD(QWidget *pParent, const QString &strDefaultName, 44 const QString &strDefaultPath, qulonglong uDefaultSize); 49 UIWizardNewVD(QWidget *pParent, 50 const QString &strDefaultName, const QString &strDefaultPath, 51 qulonglong uDefaultSize); 45 52 46 53 /* Returns virtual-disk: */ … … 57 64 /* Who will be able to create virtual-disk: */ 58 65 friend class UIWizardNewVDPageBasic4; 66 friend class UIWizardNewVDPageExpert; 59 67 60 68 private: … … 63 71 void retranslateUi(); 64 72 73 /* Pages related stuff: */ 74 void prepare(); 75 65 76 /* Variables: */ 77 QString m_strDefaultName; 78 QString m_strDefaultPath; 79 qulonglong m_uDefaultSize; 66 80 CMedium m_virtualDisk; 67 81 }; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.cpp
r40870 r41021 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QButtonGroup> 23 #include <QGroupBox> 22 24 #include <QRadioButton> 23 #include <QGroupBox>24 #include <QButtonGroup>25 25 26 26 /* Local includes: */ … … 30 30 #include "QIRichTextLabel.h" 31 31 32 UIWizardNewVDPage1::UIWizardNewVDPage1() 33 { 34 } 35 36 QRadioButton* UIWizardNewVDPage1::addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mf) 37 { 38 /* Check that medium format supports creation: */ 39 ULONG uFormatCapabilities = mf.GetCapabilities(); 40 if (!(uFormatCapabilities & MediumFormatCapabilities_CreateFixed || 41 uFormatCapabilities & MediumFormatCapabilities_CreateDynamic)) 42 return 0; 43 44 /* Check that medium format supports creation of virtual hard-disks: */ 45 QVector<QString> fileExtensions; 46 QVector<KDeviceType> deviceTypes; 47 mf.DescribeFileExtensions(fileExtensions, deviceTypes); 48 if (!deviceTypes.contains(KDeviceType_HardDisk)) 49 return 0; 50 51 /* Create/add corresponding radio-button: */ 52 QRadioButton *pFormatButton = new QRadioButton(m_pFormatCnt); 53 pFormatsLayout->addWidget(pFormatButton); 54 return pFormatButton; 55 } 56 57 CMediumFormat UIWizardNewVDPage1::mediumFormat() const 58 { 59 return m_pFormatButtonGroup->checkedButton() ? m_formats[m_pFormatButtonGroup->checkedId()] : CMediumFormat(); 60 } 61 62 void UIWizardNewVDPage1::setMediumFormat(const CMediumFormat &mediumFormat) 63 { 64 int iPosition = m_formats.indexOf(mediumFormat); 65 if (iPosition >= 0) 66 { 67 m_pFormatButtonGroup->button(iPosition)->click(); 68 m_pFormatButtonGroup->button(iPosition)->setFocus(); 69 } 70 } 71 32 72 UIWizardNewVDPageBasic1::UIWizardNewVDPageBasic1() 33 73 { 34 74 /* Create widgets: */ 35 75 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 76 { 36 77 m_pLabel = new QIRichTextLabel(this); 37 m_pFormatContainer = new QGroupBox(this); 38 m_pFormatContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 39 QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatContainer); 40 pMainLayout->addWidget(m_pLabel); 41 pMainLayout->addWidget(m_pFormatContainer); 42 pMainLayout->addStretch(); 43 44 /* Greate button group: */ 45 m_pButtonGroup = new QButtonGroup(this); 46 47 /* Enumerate supportable formats: */ 48 CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties(); 49 const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats(); 50 /* Search for default (VDI) format first: */ 51 for (int i = 0; i < medFormats.size(); ++i) 52 { 53 /* Get iterated medium format: */ 54 const CMediumFormat &medFormat = medFormats[i]; 55 QString strFormatName(medFormat.GetName()); 56 if (strFormatName == "VDI") 78 m_pFormatCnt = new QGroupBox(this); 57 79 { 58 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);59 if (pButton)80 m_pFormatCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 81 m_pFormatButtonGroup = new QButtonGroup(m_pFormatCnt); 60 82 { 61 m_formats << medFormat; 62 m_formatNames << strFormatName; 63 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1); 83 QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatCnt); 84 { 85 CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties(); 86 const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats(); 87 for (int i = 0; i < medFormats.size(); ++i) 88 { 89 const CMediumFormat &medFormat = medFormats[i]; 90 QString strFormatName(medFormat.GetName()); 91 if (strFormatName == "VDI") 92 { 93 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat); 94 if (pButton) 95 { 96 m_formats << medFormat; 97 m_formatNames << strFormatName; 98 m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1); 99 } 100 } 101 } 102 for (int i = 0; i < medFormats.size(); ++i) 103 { 104 const CMediumFormat &medFormat = medFormats[i]; 105 QString strFormatName(medFormat.GetName()); 106 if (strFormatName != "VDI") 107 { 108 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat); 109 if (pButton) 110 { 111 m_formats << medFormat; 112 m_formatNames << strFormatName; 113 m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1); 114 } 115 } 116 } 117 } 118 m_pFormatButtonGroup->button(0)->click(); 119 m_pFormatButtonGroup->button(0)->setFocus(); 64 120 } 65 121 } 66 } 67 /* Look for other formats: */ 68 for (int i = 0; i < medFormats.size(); ++i) 69 { 70 /* Get iterated medium format: */ 71 const CMediumFormat &medFormat = medFormats[i]; 72 QString strFormatName(medFormat.GetName()); 73 if (strFormatName != "VDI") 74 { 75 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat); 76 if (pButton) 77 { 78 m_formats << medFormat; 79 m_formatNames << strFormatName; 80 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1); 81 } 82 } 122 pMainLayout->addWidget(m_pLabel); 123 pMainLayout->addWidget(m_pFormatCnt); 124 pMainLayout->addStretch(); 83 125 } 84 126 85 127 /* Setup connections: */ 86 connect(m_p ButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(completeChanged()));128 connect(m_pFormatButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(completeChanged())); 87 129 88 /* Initialize connections: */ 89 m_pButtonGroup->button(0)->click(); 90 m_pButtonGroup->button(0)->setFocus(); 91 92 /* Register CMediumFormat class: */ 130 /* Register classes: */ 93 131 qRegisterMetaType<CMediumFormat>(); 94 /* Register 'mediumFormat' field: */132 /* Register fields: */ 95 133 registerField("mediumFormat", this, "mediumFormat"); 96 134 } … … 99 137 { 100 138 /* Translate page: */ 101 setTitle(UIWizardNewVD::tr("Welcome to the virtual disk creation wizard"));139 setTitle(UIWizardNewVD::tr("Welcome to the New Virtual Disk wizard!")); 102 140 103 141 /* Translate widgets: */ … … 108 146 "to use it with other virtualization software you can " 109 147 "leave this setting unchanged.</p>")); 110 m_pFormatContainer->setTitle(UIWizardNewVD::tr("File type")); 111 112 /* Translate 'format' buttons: */ 113 QList<QAbstractButton*> buttons = m_pButtonGroup->buttons(); 148 m_pFormatCnt->setTitle(UIWizardNewVD::tr("File type")); 149 QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons(); 114 150 for (int i = 0; i < buttons.size(); ++i) 115 151 { 116 152 QAbstractButton *pButton = buttons[i]; 117 pButton->setText(UIWizardNewVD::fullFormatName(m_formatNames[m_p ButtonGroup->id(pButton)]));153 pButton->setText(UIWizardNewVD::fullFormatName(m_formatNames[m_pFormatButtonGroup->id(pButton)])); 118 154 } 119 155 } … … 127 163 bool UIWizardNewVDPageBasic1::isComplete() const 128 164 { 165 /* Make sure medium format is correct: */ 129 166 return !mediumFormat().isNull(); 130 167 } … … 132 169 int UIWizardNewVDPageBasic1::nextId() const 133 170 { 134 CMediumFormat medFormat = mediumFormat(); 135 ULONG uCapabilities = medFormat.GetCapabilities(); 171 /* Show variant page only if there is something to show: */ 172 CMediumFormat mf = mediumFormat(); 173 ULONG uCapabilities = mf.GetCapabilities(); 136 174 int cTest = 0; 137 175 if (uCapabilities & KMediumFormatCapabilities_CreateDynamic) … … 143 181 if (cTest > 1) 144 182 return UIWizardNewVD::Page2; 183 /* Skip otherwise: */ 145 184 return UIWizardNewVD::Page3; 146 185 } 147 186 148 QRadioButton* UIWizardNewVDPageBasic1::addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat medFormat)149 {150 /* Check that medium format supports creation: */151 ULONG uFormatCapabilities = medFormat.GetCapabilities();152 if (!(uFormatCapabilities & MediumFormatCapabilities_CreateFixed ||153 uFormatCapabilities & MediumFormatCapabilities_CreateDynamic))154 return 0;155 156 /* Check that medium format supports creation of virtual hard-disks: */157 QVector<QString> fileExtensions;158 QVector<KDeviceType> deviceTypes;159 medFormat.DescribeFileExtensions(fileExtensions, deviceTypes);160 if (!deviceTypes.contains(KDeviceType_HardDisk))161 return 0;162 163 /* Create/add corresponding radio-button: */164 QRadioButton *pFormatButton = new QRadioButton(m_pFormatContainer);165 pFormatsLayout->addWidget(pFormatButton);166 return pFormatButton;167 }168 169 CMediumFormat UIWizardNewVDPageBasic1::mediumFormat() const170 {171 return m_pButtonGroup->checkedButton() ? m_formats[m_pButtonGroup->checkedId()] : CMediumFormat();172 }173 174 void UIWizardNewVDPageBasic1::setMediumFormat(const CMediumFormat &mediumFormat)175 {176 int iPosition = m_formats.indexOf(mediumFormat);177 if (iPosition >= 0)178 {179 m_pButtonGroup->button(iPosition)->click();180 m_pButtonGroup->button(iPosition)->setFocus();181 }182 }183 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.h
r40870 r41021 26 26 /* Forward declarations: */ 27 27 class QVBoxLayout; 28 class QButtonGroup; 29 class QGroupBox; 28 30 class QRadioButton; 29 31 class QIRichTextLabel; 30 class QGroupBox;31 class QButtonGroup;32 32 33 /* 1st page of the New Virtual Disk wizard: */ 34 class UIWizardNewVDPageBasic1 : public UIWizardPage 33 /* 1st page of the New Virtual Disk wizard (base part): */ 34 class UIWizardNewVDPage1 : public UIWizardPageBase 35 { 36 protected: 37 38 /* Constructor: */ 39 UIWizardNewVDPage1(); 40 41 /* Helping stuff: */ 42 QRadioButton* addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mf); 43 44 /* Stuff for 'mediumFormat' field: */ 45 CMediumFormat mediumFormat() const; 46 void setMediumFormat(const CMediumFormat &mediumFormat); 47 48 /* Variables: */ 49 QButtonGroup *m_pFormatButtonGroup; 50 QList<CMediumFormat> m_formats; 51 QStringList m_formatNames; 52 53 /* Widgets: */ 54 QGroupBox *m_pFormatCnt; 55 }; 56 57 /* 1st page of the New Virtual Disk wizard (basic extension): */ 58 class UIWizardNewVDPageBasic1 : public UIWizardPage, public UIWizardNewVDPage1 35 59 { 36 60 Q_OBJECT; … … 56 80 int nextId() const; 57 81 58 /* Helping stuff: */59 QRadioButton* addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mediumFormat);60 61 /* Stuff for 'mediumFormat' field: */62 CMediumFormat mediumFormat() const;63 void setMediumFormat(const CMediumFormat &mediumFormat);64 65 /* Variables: */66 QButtonGroup *m_pButtonGroup;67 QList<CMediumFormat> m_formats;68 QStringList m_formatNames;69 70 82 /* Widgets: */ 71 83 QIRichTextLabel *m_pLabel; 72 QGroupBox *m_pFormatContainer;73 84 }; 74 85 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic2.cpp
r40870 r41021 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QGroupBox> 23 #include <QButtonGroup> 22 24 #include <QRadioButton> 23 25 #include <QCheckBox> 24 #include <QGroupBox>25 26 26 27 /* Local includes: */ … … 30 31 #include "QIRichTextLabel.h" 31 32 33 UIWizardNewVDPage2::UIWizardNewVDPage2() 34 { 35 } 36 37 qulonglong UIWizardNewVDPage2::mediumVariant() const 38 { 39 /* Initial value: */ 40 qulonglong uMediumVariant = (qulonglong)KMediumVariant_Max; 41 42 /* Exclusive options: */ 43 if (m_pDynamicalButton->isChecked()) 44 uMediumVariant = (qulonglong)KMediumVariant_Standard; 45 else if (m_pFixedButton->isChecked()) 46 uMediumVariant = (qulonglong)KMediumVariant_Fixed; 47 48 /* Additional options: */ 49 if (m_pSplitBox->isChecked()) 50 uMediumVariant |= (qulonglong)KMediumVariant_VmdkSplit2G; 51 52 /* Return options: */ 53 return uMediumVariant; 54 } 55 56 void UIWizardNewVDPage2::setMediumVariant(qulonglong uMediumVariant) 57 { 58 /* Exclusive options: */ 59 if (uMediumVariant & (qulonglong)KMediumVariant_Fixed) 60 { 61 m_pFixedButton->click(); 62 m_pFixedButton->setFocus(); 63 } 64 else 65 { 66 m_pDynamicalButton->click(); 67 m_pDynamicalButton->setFocus(); 68 } 69 70 /* Additional options: */ 71 m_pSplitBox->setChecked(uMediumVariant & (qulonglong)KMediumVariant_VmdkSplit2G); 72 } 73 32 74 UIWizardNewVDPageBasic2::UIWizardNewVDPageBasic2() 33 : m_pDynamicalButton(0), m_pFixedButton(0), m_pSplitBox(0)34 75 { 35 76 /* Create widgets: */ 36 77 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 78 { 37 79 m_pDescriptionLabel = new QIRichTextLabel(this); 38 80 m_pDynamicLabel = new QIRichTextLabel(this); 39 81 m_pFixedLabel = new QIRichTextLabel(this); 40 82 m_pSplitLabel = new QIRichTextLabel(this); 41 m_pVariantContainer = new QGroupBox(this); 42 m_pVariantContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 43 QVBoxLayout *pVariantsLayout = new QVBoxLayout(m_pVariantContainer); 44 m_pDynamicalButton = new QRadioButton(m_pVariantContainer); 45 m_pDynamicalButton->click(); 46 m_pDynamicalButton->setFocus(); 47 m_pFixedButton = new QRadioButton(m_pVariantContainer); 48 m_pSplitBox = new QCheckBox(m_pVariantContainer); 49 pVariantsLayout->addWidget(m_pDynamicalButton); 50 pVariantsLayout->addWidget(m_pFixedButton); 51 pVariantsLayout->addWidget(m_pSplitBox); 52 pMainLayout->addWidget(m_pDescriptionLabel); 53 pMainLayout->addWidget(m_pDynamicLabel); 54 pMainLayout->addWidget(m_pFixedLabel); 55 pMainLayout->addWidget(m_pSplitLabel); 56 pMainLayout->addWidget(m_pVariantContainer); 57 pMainLayout->addStretch(); 83 m_pVariantCnt = new QGroupBox(this); 84 { 85 m_pVariantCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 86 QVBoxLayout *pVariantCntLayout = new QVBoxLayout(m_pVariantCnt); 87 { 88 m_pVariantButtonGroup = new QButtonGroup(m_pVariantCnt); 89 { 90 m_pDynamicalButton = new QRadioButton(m_pVariantCnt); 91 { 92 m_pDynamicalButton->click(); 93 m_pDynamicalButton->setFocus(); 94 } 95 m_pFixedButton = new QRadioButton(m_pVariantCnt); 96 m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0); 97 m_pVariantButtonGroup->addButton(m_pFixedButton, 1); 98 } 99 m_pSplitBox = new QCheckBox(m_pVariantCnt); 100 pVariantCntLayout->addWidget(m_pDynamicalButton); 101 pVariantCntLayout->addWidget(m_pFixedButton); 102 pVariantCntLayout->addWidget(m_pSplitBox); 103 } 104 } 105 pMainLayout->addWidget(m_pDescriptionLabel); 106 pMainLayout->addWidget(m_pDynamicLabel); 107 pMainLayout->addWidget(m_pFixedLabel); 108 pMainLayout->addWidget(m_pSplitLabel); 109 pMainLayout->addWidget(m_pVariantCnt); 110 pMainLayout->addStretch(); 111 } 58 112 59 113 /* Setup connections: */ 60 connect(m_pDynamicalButton, SIGNAL(clicked(bool)), this, SIGNAL(completeChanged())); 61 connect(m_pFixedButton, SIGNAL(clicked(bool)), this, SIGNAL(completeChanged())); 114 connect(m_pVariantButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged())); 62 115 connect(m_pSplitBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged())); 63 116 64 /* Register 'mediumVariant' field: */117 /* Register fields: */ 65 118 registerField("mediumVariant", this, "mediumVariant"); 66 119 } … … 83 136 "virtual machine on removable USB devices or old systems, some of which cannot " 84 137 "handle very large files.")); 85 m_pVariantContainer->setTitle(UIWizardNewVD::tr("Storage details")); 86 87 /* Translate buttons: */ 138 m_pVariantCnt->setTitle(UIWizardNewVD::tr("Storage details")); 88 139 m_pDynamicalButton->setText(UIWizardNewVD::tr("&Dynamically allocated")); 89 140 m_pFixedButton->setText(UIWizardNewVD::tr("&Fixed size")); … … 112 163 bool UIWizardNewVDPageBasic2::isComplete() const 113 164 { 165 /* Make sure medium variant is correct: */ 114 166 return mediumVariant() != (qulonglong)KMediumVariant_Max; 115 167 } 116 168 117 qulonglong UIWizardNewVDPageBasic2::mediumVariant() const118 {119 /* Initial value: */120 qulonglong uMediumVariant = (qulonglong)KMediumVariant_Max;121 122 /* Exclusive options: */123 if (m_pDynamicalButton->isChecked())124 uMediumVariant = (qulonglong)KMediumVariant_Standard;125 else if (m_pFixedButton->isChecked())126 uMediumVariant = (qulonglong)KMediumVariant_Fixed;127 128 /* Additional options: */129 if (m_pSplitBox->isChecked())130 uMediumVariant |= (qulonglong)KMediumVariant_VmdkSplit2G;131 132 /* Return options: */133 return uMediumVariant;134 }135 136 void UIWizardNewVDPageBasic2::setMediumVariant(qulonglong uMediumVariant)137 {138 /* Exclusive options: */139 if (uMediumVariant & (qulonglong)KMediumVariant_Fixed)140 {141 m_pFixedButton->click();142 m_pFixedButton->setFocus();143 }144 else145 {146 m_pDynamicalButton->click();147 m_pDynamicalButton->setFocus();148 }149 150 /* Additional options: */151 m_pSplitBox->setChecked(uMediumVariant & (qulonglong)KMediumVariant_VmdkSplit2G);152 }153 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic2.h
r40870 r41021 24 24 25 25 /* Forward declarations: */ 26 class QGroupBox; 27 class QButtonGroup; 26 28 class QRadioButton; 27 29 class QCheckBox; 28 30 class QIRichTextLabel; 29 class QGroupBox;30 31 31 /* 2nd page of the New Virtual Disk wizard: */ 32 class UIWizardNewVDPageBasic2 : public UIWizardPage 32 /* 2nd page of the New Virtual Disk wizard (base part): */ 33 class UIWizardNewVDPage2 : public UIWizardPageBase 34 { 35 protected: 36 37 /* Constructor: */ 38 UIWizardNewVDPage2(); 39 40 /* Stuff for 'variant' field: */ 41 qulonglong mediumVariant() const; 42 void setMediumVariant(qulonglong uMediumVariant); 43 44 /* Widgets: */ 45 QGroupBox *m_pVariantCnt; 46 QButtonGroup *m_pVariantButtonGroup; 47 QRadioButton *m_pDynamicalButton; 48 QRadioButton *m_pFixedButton; 49 QCheckBox *m_pSplitBox; 50 }; 51 52 /* 2nd page of the New Virtual Disk wizard (basic extension): */ 53 class UIWizardNewVDPageBasic2 : public UIWizardPage, public UIWizardNewVDPage2 33 54 { 34 55 Q_OBJECT; … … 51 72 bool isComplete() const; 52 73 53 /* Stuff for 'variant' field: */54 qulonglong mediumVariant() const;55 void setMediumVariant(qulonglong uMediumVariant);56 57 /* Variables: */58 QRadioButton *m_pDynamicalButton;59 QRadioButton *m_pFixedButton;60 QCheckBox *m_pSplitBox;61 62 74 /* Widgets: */ 63 75 QIRichTextLabel *m_pDescriptionLabel; … … 65 77 QIRichTextLabel *m_pFixedLabel; 66 78 QIRichTextLabel *m_pSplitLabel; 67 QGroupBox *m_pVariantContainer;68 79 }; 69 80 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.cpp
r40870 r41021 40 40 #include "QIToolButton.h" 41 41 #include "QILineEdit.h" 42 #include "iprt/path.h" 43 44 UIWizardNewVDPageBasic3::UIWizardNewVDPageBasic3(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize) 42 43 UIWizardNewVDPage3::UIWizardNewVDPage3(const QString &strDefaultName, const QString &strDefaultPath) 45 44 : m_strDefaultName(strDefaultName.isEmpty() ? QString("NewVirtualDisk1") : strDefaultName) 46 45 , m_strDefaultPath(strDefaultPath) 47 46 , m_uMediumSizeMin(_4M) 48 47 , m_uMediumSizeMax(vboxGlobal().virtualBox().GetSystemProperties().GetInfoVDSize()) 49 , m_iSliderScale(0) 50 { 51 /* Detect how many steps to recognize between adjacent powers of 2 52 * to ensure that the last slider step is exactly that we need: */ 53 int iPower = log2i(m_uMediumSizeMax); 54 qulonglong uTickMB = qulonglong (1) << iPower; 55 if (uTickMB < m_uMediumSizeMax) 56 { 57 qulonglong uTickMBNext = qulonglong (1) << (iPower + 1); 58 qulonglong uGap = uTickMBNext - m_uMediumSizeMax; 59 m_iSliderScale = (int)((uTickMBNext - uTickMB) / uGap); 60 } 61 m_iSliderScale = qMax(m_iSliderScale, 8); 62 63 /* Create widgets: */ 64 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 65 m_pLocationLabel = new QIRichTextLabel(this); 66 m_pLocationCnt = new QGroupBox(this); 67 m_pLocationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 68 QHBoxLayout *pOptionsLayout = new QHBoxLayout(m_pLocationCnt); 69 m_pLocationEditor = new QLineEdit(m_pLocationCnt); 70 m_pLocationSelector = new QIToolButton(m_pLocationCnt); 71 m_pLocationSelector->setAutoRaise(true); 72 m_pLocationSelector->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png")); 73 pOptionsLayout->addWidget(m_pLocationEditor); 74 pOptionsLayout->addWidget(m_pLocationSelector); 75 m_pSizeLabel = new QIRichTextLabel(this); 76 m_pSizeCnt = new QGroupBox(this); 77 m_pSizeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 78 QGridLayout *m_pSizeLayout = new QGridLayout(m_pSizeCnt); 79 m_pSizeSlider = new QSlider(m_pSizeCnt); 80 m_pSizeSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 81 m_pSizeSlider->setOrientation(Qt::Horizontal); 82 m_pSizeSlider->setTickPosition(QSlider::TicksBelow); 83 m_pSizeSlider->setFocusPolicy(Qt::StrongFocus); 84 m_pSizeSlider->setPageStep(m_iSliderScale); 85 m_pSizeSlider->setSingleStep(m_iSliderScale / 8); 86 m_pSizeSlider->setTickInterval(0); 87 m_pSizeSlider->setMinimum(sizeMBToSlider(m_uMediumSizeMin, m_iSliderScale)); 88 m_pSizeSlider->setMaximum(sizeMBToSlider(m_uMediumSizeMax, m_iSliderScale)); 89 m_pSizeEditor = new QILineEdit(m_pSizeCnt); 90 m_pSizeEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); 91 m_pSizeEditor->setFixedWidthByText("88888.88 MB"); 92 m_pSizeEditor->setAlignment(Qt::AlignRight); 93 m_pSizeEditor->setValidator(new QRegExpValidator(QRegExp(vboxGlobal().sizeRegexp()), this)); 94 QLabel *m_pSizeMin = new QLabel(m_pSizeCnt); 95 m_pSizeMin->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); 96 m_pSizeMin->setText(vboxGlobal().formatSize(m_uMediumSizeMin)); 97 QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed); 98 QLabel *m_pSizeMax = new QLabel(m_pSizeCnt); 99 m_pSizeMax->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); 100 m_pSizeMax->setText(vboxGlobal().formatSize(m_uMediumSizeMax)); 101 m_pSizeLayout->addWidget(m_pSizeSlider, 0, 0, 1, 3); 102 m_pSizeLayout->addWidget(m_pSizeEditor, 0, 3); 103 m_pSizeLayout->addWidget(m_pSizeMin, 1, 0); 104 m_pSizeLayout->addItem(m_pSizeSpacer, 1, 1); 105 m_pSizeLayout->addWidget(m_pSizeMax, 1, 2); 106 pMainLayout->addWidget(m_pLocationLabel); 107 pMainLayout->addWidget(m_pLocationCnt); 108 pMainLayout->addWidget(m_pSizeLabel); 109 pMainLayout->addWidget(m_pSizeCnt); 110 pMainLayout->addStretch(); 111 112 /* Setup connections: */ 113 connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltLocationEditorTextChanged(const QString &))); 114 connect(m_pLocationSelector, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked())); 115 connect(m_pSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(sltSizeSliderValueChanged(int))); 116 connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltSizeEditorTextChanged(const QString &))); 117 118 /* Initialize connections: */ 119 setMediumSize(uDefaultSize); 120 121 /* Register 'mediumPath', 'mediumSize' fields: */ 122 registerField("mediumPath", this, "mediumPath"); 123 registerField("mediumSize", this, "mediumSize"); 124 } 125 126 void UIWizardNewVDPageBasic3::sltLocationEditorTextChanged(const QString &strMediumName) 127 { 128 /* Compose new medium path: */ 129 m_strMediumPath = absoluteFilePath(toFileName(strMediumName, m_strDefaultExtension), m_strDefaultPath); 130 /* Notify wizard sub-system about complete status changed: */ 131 emit completeChanged(); 132 } 133 134 void UIWizardNewVDPageBasic3::sltSelectLocationButtonClicked() 48 , m_iSliderScale(calculateSliderScale(m_uMediumSizeMax)) 49 { 50 } 51 52 void UIWizardNewVDPage3::onSelectLocationButtonClicked() 135 53 { 136 54 /* Get current folder and filename: */ 137 QFileInfo fullFilePath(m _strMediumPath);55 QFileInfo fullFilePath(mediumPath()); 138 56 QDir folder = fullFilePath.path(); 139 57 QString strFileName = fullFilePath.fileName(); … … 157 75 158 76 /* Prepare backends list: */ 159 CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();160 77 QVector<QString> fileExtensions; 161 78 QVector<KDeviceType> deviceTypes; 79 CMediumFormat mediumFormat = fieldImp("mediumFormat").value<CMediumFormat>(); 162 80 mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes); 163 81 QStringList validExtensionList; … … 170 88 /* Open corresponding file-dialog: */ 171 89 QString strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName), 172 strBackendsList, this ,173 UIWizardNewVD::tr("Select a file for the new hard disk imagefile"));90 strBackendsList, thisImp(), 91 VBoxGlobal::tr("Choose a virtual hard disk file")); 174 92 175 93 /* If there was something really chosen: */ … … 185 103 } 186 104 187 void UIWizardNewVDPage Basic3::sltSizeSliderValueChanged(int iValue)105 void UIWizardNewVDPage3::onSizeSliderValueChanged(int iValue) 188 106 { 189 107 /* Get full size: */ … … 195 113 m_pSizeEditor->setText(vboxGlobal().formatSize(uMediumSize)); 196 114 m_pSizeEditor->blockSignals(false); 197 /* Notify wizard sub-system about complete status changed: */ 198 emit completeChanged(); 199 } 200 201 void UIWizardNewVDPageBasic3::sltSizeEditorTextChanged(const QString &strValue) 115 } 116 117 void UIWizardNewVDPage3::onSizeEditorTextChanged(const QString &strValue) 202 118 { 203 119 /* Get full size: */ … … 209 125 m_pSizeSlider->setValue(sizeMBToSlider(uMediumSize, m_iSliderScale)); 210 126 m_pSizeSlider->blockSignals(false); 211 /* Notify wizard sub-system about complete status changed: */ 212 emit completeChanged(); 213 } 214 215 void UIWizardNewVDPageBasic3::retranslateUi() 216 { 217 /* Translate page: */ 218 setTitle(UIWizardNewVD::tr("Virtual disk file location and size")); 219 220 /* Translate widgets: */ 221 m_pLocationLabel->setText(UIWizardNewVD::tr("Please type the name of the new virtual disk file into the box below or " 222 "click on the folder icon to select a different folder to create the file in.")); 223 m_pLocationCnt->setTitle(tr("&Location")); 224 m_pSizeLabel->setText(UIWizardNewVD::tr("Select the size of the virtual disk in megabytes. This size will be reported " 225 "to the Guest OS as the maximum size of this virtual disk.")); 226 m_pSizeCnt->setTitle(UIWizardNewVD::tr("&Size")); 227 } 228 229 void UIWizardNewVDPageBasic3::initializePage() 230 { 231 /* Translate page: */ 232 retranslateUi(); 233 234 /* Reset name to default: */ 235 m_pLocationEditor->setText(m_strDefaultName); 236 /* Get virtual-disk extension: */ 237 m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>()); 238 /* Compose path for new virtual-disk: */ 239 m_strMediumPath = absoluteFilePath(toFileName(m_strDefaultName, m_strDefaultExtension), m_strDefaultPath); 240 } 241 242 bool UIWizardNewVDPageBasic3::isComplete() const 243 { 244 /* Check what current name is not empty & current size feats the bounds: */ 245 return !m_pLocationEditor->text().trimmed().isEmpty() && 246 mediumSize() >= m_uMediumSizeMin && mediumSize() <= m_uMediumSizeMax; 247 } 248 249 bool UIWizardNewVDPageBasic3::validatePage() 250 { 251 if (QFileInfo(m_strMediumPath).exists()) 252 { 253 msgCenter().sayCannotOverwriteHardDiskStorage(this, m_strMediumPath); 254 return false; 255 } 256 return true; 257 } 258 259 /* static */ 260 QString UIWizardNewVDPageBasic3::toFileName(const QString &strName, const QString &strExtension) 127 } 128 129 /* static */ 130 QString UIWizardNewVDPage3::toFileName(const QString &strName, const QString &strExtension) 261 131 { 262 132 /* Convert passed name to native separators (it can be full, actually): */ … … 277 147 278 148 /* static */ 279 QString UIWizardNewVDPage Basic3::absoluteFilePath(const QString &strFileName, const QString &strDefaultPath)149 QString UIWizardNewVDPage3::absoluteFilePath(const QString &strFileName, const QString &strDefaultPath) 280 150 { 281 151 /* Wrap file-info around received file name: */ … … 292 162 293 163 /* static */ 294 QString UIWizardNewVDPage Basic3::defaultExtension(const CMediumFormat &mediumFormatRef)164 QString UIWizardNewVDPage3::defaultExtension(const CMediumFormat &mediumFormatRef) 295 165 { 296 166 /* Load extension / device list: */ … … 307 177 308 178 /* static */ 309 int UIWizardNewVDPageBasic3::log2i(qulonglong uValue) 179 int UIWizardNewVDPage3::calculateSliderScale(qulonglong uMaximumMediumSize) 180 { 181 /* Detect how many steps to recognize between adjacent powers of 2 182 * to ensure that the last slider step is exactly that we need: */ 183 int iSliderScale = 0; 184 int iPower = log2i(uMaximumMediumSize); 185 qulonglong uTickMB = (qulonglong)1 << iPower; 186 if (uTickMB < uMaximumMediumSize) 187 { 188 qulonglong uTickMBNext = (qulonglong)1 << (iPower + 1); 189 qulonglong uGap = uTickMBNext - uMaximumMediumSize; 190 iSliderScale = (int)((uTickMBNext - uTickMB) / uGap); 191 } 192 return qMax(iSliderScale, 8); 193 } 194 195 /* static */ 196 int UIWizardNewVDPage3::log2i(qulonglong uValue) 310 197 { 311 198 int iPower = -1; … … 319 206 320 207 /* static */ 321 int UIWizardNewVDPage Basic3::sizeMBToSlider(qulonglong uValue, int iSliderScale)208 int UIWizardNewVDPage3::sizeMBToSlider(qulonglong uValue, int iSliderScale) 322 209 { 323 210 int iPower = log2i(uValue); … … 329 216 330 217 /* static */ 331 qulonglong UIWizardNewVDPage Basic3::sliderToSizeMB(int uValue, int iSliderScale)218 qulonglong UIWizardNewVDPage3::sliderToSizeMB(int uValue, int iSliderScale) 332 219 { 333 220 int iPower = uValue / iSliderScale; … … 338 225 } 339 226 340 void UIWizardNewVDPage Basic3::updateSizeToolTips(qulonglong uSize)227 void UIWizardNewVDPage3::updateSizeToolTips(qulonglong uSize) 341 228 { 342 229 QString strToolTip = UIWizardNewVD::tr("<nobr>%1 (%2 B)</nobr>").arg(vboxGlobal().formatSize(uSize)).arg(uSize); … … 345 232 } 346 233 347 qulonglong UIWizardNewVDPageBasic3::mediumSize() const 348 { 349 /* Return slider value scaled at 'm_iSliderScale': */ 234 QString UIWizardNewVDPage3::mediumPath() const 235 { 236 return absoluteFilePath(toFileName(m_pLocationEditor->text(), m_strDefaultExtension), m_strDefaultPath); 237 } 238 239 qulonglong UIWizardNewVDPage3::mediumSize() const 240 { 350 241 return sliderToSizeMB(m_pSizeSlider->value(), m_iSliderScale); 351 242 } 352 243 353 void UIWizardNewVDPage Basic3::setMediumSize(qulonglong uMediumSize)244 void UIWizardNewVDPage3::setMediumSize(qulonglong uMediumSize) 354 245 { 355 246 /* Block signals: */ … … 365 256 } 366 257 258 UIWizardNewVDPageBasic3::UIWizardNewVDPageBasic3(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize) 259 : UIWizardNewVDPage3(strDefaultName, strDefaultPath) 260 { 261 /* Create widgets: */ 262 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 263 { 264 m_pLocationLabel = new QIRichTextLabel(this); 265 m_pLocationCnt = new QGroupBox(this); 266 { 267 m_pLocationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 268 QHBoxLayout *pLocationCntLayout = new QHBoxLayout(m_pLocationCnt); 269 { 270 m_pLocationEditor = new QLineEdit(m_pLocationCnt); 271 m_pLocationOpenButton = new QIToolButton(m_pLocationCnt); 272 { 273 m_pLocationOpenButton->setAutoRaise(true); 274 m_pLocationOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png")); 275 } 276 pLocationCntLayout->addWidget(m_pLocationEditor); 277 pLocationCntLayout->addWidget(m_pLocationOpenButton); 278 } 279 } 280 m_pSizeLabel = new QIRichTextLabel(this); 281 m_pSizeCnt = new QGroupBox(this); 282 { 283 m_pSizeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 284 QGridLayout *m_pSizeCntLayout = new QGridLayout(m_pSizeCnt); 285 { 286 m_pSizeSlider = new QSlider(m_pSizeCnt); 287 { 288 m_pSizeSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 289 m_pSizeSlider->setOrientation(Qt::Horizontal); 290 m_pSizeSlider->setTickPosition(QSlider::TicksBelow); 291 m_pSizeSlider->setFocusPolicy(Qt::StrongFocus); 292 m_pSizeSlider->setPageStep(m_iSliderScale); 293 m_pSizeSlider->setSingleStep(m_iSliderScale / 8); 294 m_pSizeSlider->setTickInterval(0); 295 m_pSizeSlider->setMinimum(sizeMBToSlider(m_uMediumSizeMin, m_iSliderScale)); 296 m_pSizeSlider->setMaximum(sizeMBToSlider(m_uMediumSizeMax, m_iSliderScale)); 297 } 298 m_pSizeEditor = new QILineEdit(m_pSizeCnt); 299 { 300 m_pSizeEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); 301 m_pSizeEditor->setFixedWidthByText("88888.88 MB"); 302 m_pSizeEditor->setAlignment(Qt::AlignRight); 303 m_pSizeEditor->setValidator(new QRegExpValidator(QRegExp(vboxGlobal().sizeRegexp()), this)); 304 } 305 QLabel *m_pSizeMin = new QLabel(m_pSizeCnt); 306 { 307 m_pSizeMin->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); 308 m_pSizeMin->setText(vboxGlobal().formatSize(m_uMediumSizeMin)); 309 } 310 QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed); 311 QLabel *m_pSizeMax = new QLabel(m_pSizeCnt); 312 { 313 m_pSizeMax->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); 314 m_pSizeMax->setText(vboxGlobal().formatSize(m_uMediumSizeMax)); 315 } 316 m_pSizeCntLayout->addWidget(m_pSizeSlider, 0, 0, 1, 3); 317 m_pSizeCntLayout->addWidget(m_pSizeEditor, 0, 3); 318 m_pSizeCntLayout->addWidget(m_pSizeMin, 1, 0); 319 m_pSizeCntLayout->addItem(m_pSizeSpacer, 1, 1); 320 m_pSizeCntLayout->addWidget(m_pSizeMax, 1, 2); 321 } 322 setMediumSize(uDefaultSize); 323 } 324 pMainLayout->addWidget(m_pLocationLabel); 325 pMainLayout->addWidget(m_pLocationCnt); 326 pMainLayout->addWidget(m_pSizeLabel); 327 pMainLayout->addWidget(m_pSizeCnt); 328 pMainLayout->addStretch(); 329 } 330 331 /* Setup connections: */ 332 connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged())); 333 connect(m_pLocationOpenButton, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked())); 334 connect(m_pSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(sltSizeSliderValueChanged(int))); 335 connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltSizeEditorTextChanged(const QString &))); 336 337 /* Register fields: */ 338 registerField("mediumPath", this, "mediumPath"); 339 registerField("mediumSize", this, "mediumSize"); 340 } 341 342 void UIWizardNewVDPageBasic3::sltSelectLocationButtonClicked() 343 { 344 /* Call to base-class: */ 345 onSelectLocationButtonClicked(); 346 } 347 348 void UIWizardNewVDPageBasic3::sltSizeSliderValueChanged(int iValue) 349 { 350 /* Call to base-class: */ 351 onSizeSliderValueChanged(iValue); 352 353 /* Broadcast complete-change: */ 354 emit completeChanged(); 355 } 356 357 void UIWizardNewVDPageBasic3::sltSizeEditorTextChanged(const QString &strValue) 358 { 359 /* Call to base-class: */ 360 onSizeEditorTextChanged(strValue); 361 362 /* Broadcast complete-change: */ 363 emit completeChanged(); 364 } 365 366 void UIWizardNewVDPageBasic3::retranslateUi() 367 { 368 /* Translate page: */ 369 setTitle(UIWizardNewVD::tr("Virtual disk file location and size")); 370 371 /* Translate widgets: */ 372 m_pLocationLabel->setText(UIWizardNewVD::tr("Please type the name of the new virtual disk file into the box below or " 373 "click on the folder icon to select a different folder to create the file in.")); 374 m_pLocationCnt->setTitle(UIWizardNewVD::tr("&Location")); 375 m_pSizeLabel->setText(UIWizardNewVD::tr("Select the size of the virtual disk in megabytes. This size will be reported " 376 "to the Guest OS as the maximum size of this virtual disk.")); 377 m_pSizeCnt->setTitle(UIWizardNewVD::tr("&Size")); 378 } 379 380 void UIWizardNewVDPageBasic3::initializePage() 381 { 382 /* Translate page: */ 383 retranslateUi(); 384 385 /* Get default extension for new virtual-disk: */ 386 m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>()); 387 /* Set default name as text for location editor: */ 388 m_pLocationEditor->setText(m_strDefaultName); 389 } 390 391 bool UIWizardNewVDPageBasic3::isComplete() const 392 { 393 /* Make sure current name is not empty and current size feats the bounds: */ 394 return !m_pLocationEditor->text().trimmed().isEmpty() && 395 mediumSize() >= m_uMediumSizeMin && mediumSize() <= m_uMediumSizeMax; 396 } 397 398 bool UIWizardNewVDPageBasic3::validatePage() 399 { 400 /* Make sure such virtual-disk doesn't exists already: */ 401 QString strMediumPath(mediumPath()); 402 if (QFileInfo(strMediumPath).exists()) 403 { 404 msgCenter().sayCannotOverwriteHardDiskStorage(this, strMediumPath); 405 return false; 406 } 407 return true; 408 } 409 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.h
r40870 r41021 26 26 /* Forward declarations: */ 27 27 class CMediumFormat; 28 class QIRichTextLabel;29 28 class QGroupBox; 30 29 class QLineEdit; … … 32 31 class QSlider; 33 32 class QILineEdit; 33 class QIRichTextLabel; 34 34 35 /* 3rd page of the New Virtual Disk wizard: */ 36 class UIWizardNewVDPageBasic3 : public UIWizardPage 35 /* 3rd page of the New Virtual Disk wizard (base part): */ 36 class UIWizardNewVDPage3 : public UIWizardPageBase 37 { 38 protected: 39 40 /* Constructor: */ 41 UIWizardNewVDPage3(const QString &strDefaultName, const QString &strDefaultPath); 42 43 /* Handlers: */ 44 void onSelectLocationButtonClicked(); 45 void onSizeSliderValueChanged(int iValue); 46 void onSizeEditorTextChanged(const QString &strValue); 47 48 /* Location-editors stuff: */ 49 static QString toFileName(const QString &strName, const QString &strExtension); 50 static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath); 51 static QString defaultExtension(const CMediumFormat &mediumFormatRef); 52 53 /* Size-editors stuff: */ 54 static int calculateSliderScale(qulonglong uMaximumMediumSize); 55 static int log2i(qulonglong uValue); 56 static int sizeMBToSlider(qulonglong uValue, int iSliderScale); 57 static qulonglong sliderToSizeMB(int uValue, int iSliderScale); 58 void updateSizeToolTips(qulonglong uSize); 59 60 /* Stuff for 'mediumPath' field: */ 61 QString mediumPath() const; 62 63 /* Stuff for 'mediumSize' field: */ 64 qulonglong mediumSize() const; 65 void setMediumSize(qulonglong uMediumSize); 66 67 /* Variables: */ 68 QString m_strDefaultName; 69 QString m_strDefaultPath; 70 QString m_strDefaultExtension; 71 qulonglong m_uMediumSizeMin; 72 qulonglong m_uMediumSizeMax; 73 int m_iSliderScale; 74 75 /* Widgets: */ 76 QGroupBox *m_pLocationCnt; 77 QLineEdit *m_pLocationEditor; 78 QIToolButton *m_pLocationOpenButton; 79 QGroupBox *m_pSizeCnt; 80 QSlider *m_pSizeSlider; 81 QILineEdit *m_pSizeEditor; 82 }; 83 84 /* 3rd page of the New Virtual Disk wizard (basic extension): */ 85 class UIWizardNewVDPageBasic3 : public UIWizardPage, public UIWizardNewVDPage3 37 86 { 38 87 Q_OBJECT; 39 Q_PROPERTY(QString mediumPath READ mediumPath WRITE setMediumPath);88 Q_PROPERTY(QString mediumPath READ mediumPath); 40 89 Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize); 41 90 … … 45 94 UIWizardNewVDPageBasic3(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize); 46 95 96 protected: 97 98 /* Wrapper to access 'this' from base part: */ 99 UIWizardPage* thisImp() { return this; } 100 /* Wrapper to access 'wizard-field' from base part: */ 101 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 102 47 103 private slots: 48 104 49 105 /* Location editors stuff: */ 50 void sltLocationEditorTextChanged(const QString &strMediumName);51 106 void sltSelectLocationButtonClicked(); 52 107 … … 67 122 bool validatePage(); 68 123 69 /* Location-editors stuff: */70 static QString toFileName(const QString &strName, const QString &strExtension);71 static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath);72 static QString defaultExtension(const CMediumFormat &mediumFormatRef);73 74 /* Size-editors stuff: */75 static int log2i(qulonglong uValue);76 static int sizeMBToSlider(qulonglong uValue, int iSliderScale);77 static qulonglong sliderToSizeMB(int uValue, int iSliderScale);78 void updateSizeToolTips(qulonglong uSize);79 80 /* Stuff for 'mediumPath' field: */81 QString mediumPath() const { return m_strMediumPath; }82 void setMediumPath(const QString &strMediumPath) { m_strMediumPath = strMediumPath; }83 QString m_strMediumPath;84 85 /* Stuff for 'mediumSize' field: */86 qulonglong mediumSize() const;87 void setMediumSize(qulonglong uMediumSize);88 89 /* Location-editors variables: */90 QString m_strDefaultName;91 QString m_strDefaultPath;92 QString m_strDefaultExtension;93 94 /* Size-editors variables: */95 qulonglong m_uMediumSizeMin;96 qulonglong m_uMediumSizeMax;97 int m_iSliderScale;98 99 124 /* Widgets: */ 100 125 QIRichTextLabel *m_pLocationLabel; 101 126 QIRichTextLabel *m_pSizeLabel; 102 QGroupBox *m_pLocationCnt;103 QLineEdit *m_pLocationEditor;104 QIToolButton *m_pLocationSelector;105 QGroupBox *m_pSizeCnt;106 QSlider *m_pSizeSlider;107 QILineEdit *m_pSizeEditor;108 127 }; 109 128 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic4.cpp
r40870 r41021 24 24 #include "QIRichTextLabel.h" 25 25 26 UIWizardNewVDPage4::UIWizardNewVDPage4() 27 { 28 } 29 26 30 UIWizardNewVDPageBasic4::UIWizardNewVDPageBasic4() 27 31 { 28 32 /* Create widgets: */ 29 33 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 34 { 30 35 m_pLabel1 = new QIRichTextLabel(this); 31 36 m_pSummaryText = new QIRichTextLabel(this); 32 37 m_pLabel2 = new QIRichTextLabel(this); 33 pMainLayout->addWidget(m_pLabel1); 34 pMainLayout->addWidget(m_pSummaryText); 35 pMainLayout->addWidget(m_pLabel2); 36 pMainLayout->addStretch(); 37 38 /* Register CMedium class: */ 39 qRegisterMetaType<CMedium>(); 40 /* Register 'virtualDisk' field: */ 41 registerField("virtualDisk", this, "virtualDisk"); 38 pMainLayout->addWidget(m_pLabel1); 39 pMainLayout->addWidget(m_pSummaryText); 40 pMainLayout->addWidget(m_pLabel2); 41 pMainLayout->addStretch(); 42 } 42 43 } 43 44 … … 84 85 bool UIWizardNewVDPageBasic4::validatePage() 85 86 { 87 /* Initial result: */ 88 bool fResult = true; 89 90 /* Lock finish button: */ 91 startProcessing(); 92 86 93 /* Try to create virtual-disk: */ 87 startProcessing(); 88 bool fResult = qobject_cast<UIWizardNewVD*>(wizard())->createVirtualDisk(); 94 if (fResult) 95 fResult = qobject_cast<UIWizardNewVD*>(wizard())->createVirtualDisk(); 96 97 /* Unlock finish button: */ 89 98 endProcessing(); 99 100 /* Return result: */ 90 101 return fResult; 91 102 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic4.h
r40870 r41021 22 22 /* Local includes: */ 23 23 #include "UIWizardPage.h" 24 #include "COMDefs.h"25 24 26 25 /* Forward declarations: */ 27 26 class QIRichTextLabel; 28 27 29 /* 4th page of the New Virtual Disk wizard: */ 30 class UIWizardNewVDPageBasic4 : public UIWizardPage 28 /* 4th page of the New Virtual Disk wizard (base part): */ 29 class UIWizardNewVDPage4 : public UIWizardPageBase 30 { 31 protected: 32 33 /* Constructor: */ 34 UIWizardNewVDPage4(); 35 }; 36 37 /* 4th page of the New Virtual Disk wizard (basic extension): */ 38 class UIWizardNewVDPageBasic4 : public UIWizardPage, public UIWizardNewVDPage4 31 39 { 32 40 Q_OBJECT; 33 Q_PROPERTY(CMedium virtualDisk READ virtualDisk WRITE setVirtualDisk);34 41 35 42 public: … … 49 56 bool validatePage(); 50 57 51 /* Stuff for 'virtualDisk' field: */52 CMedium virtualDisk() const { return m_virtualDisk; }53 void setVirtualDisk(const CMedium &virtualDisk) { m_virtualDisk = virtualDisk; }54 CMedium m_virtualDisk;55 56 58 /* Widgets: */ 57 59 QIRichTextLabel *m_pLabel1; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp
r40929 r41021 3 3 * 4 4 * VBox frontends: Qt4 GUI ("VirtualBox"): 5 * UIWizardNewVDPage Basic1class implementation5 * UIWizardNewVDPageExpert class implementation 6 6 */ 7 7 … … 19 19 20 20 /* Global includes: */ 21 #include <QGridLayout> 21 22 #include <QVBoxLayout> 23 #include <QRegExpValidator> 24 #include <QGroupBox> 22 25 #include <QRadioButton> 23 #include <Q GroupBox>26 #include <QCheckBox> 24 27 #include <QButtonGroup> 28 #include <QLineEdit> 29 #include <QSlider> 30 #include <QLabel> 25 31 26 32 /* Local includes: */ 27 #include "UIWizardNewVDPage Basic1.h"33 #include "UIWizardNewVDPageExpert.h" 28 34 #include "UIWizardNewVD.h" 29 35 #include "VBoxGlobal.h" 36 #include "UIMessageCenter.h" 37 #include "UIIconPool.h" 30 38 #include "QIRichTextLabel.h" 31 32 UIWizardNewVDPageBasic1::UIWizardNewVDPageBasic1() 39 #include "QIToolButton.h" 40 #include "QILineEdit.h" 41 42 UIWizardNewVDPageExpert::UIWizardNewVDPageExpert(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize) 43 : UIWizardNewVDPage3(strDefaultName, strDefaultPath) 33 44 { 34 45 /* Create widgets: */ 35 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 36 m_pLabel = new QIRichTextLabel(this); 37 m_pFormatContainer = new QGroupBox(this); 38 m_pFormatContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 39 QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatContainer); 40 pMainLayout->addWidget(m_pLabel); 41 pMainLayout->addWidget(m_pFormatContainer); 42 pMainLayout->addStretch(); 43 44 /* Greate button group: */ 45 m_pButtonGroup = new QButtonGroup(this); 46 47 /* Enumerate supportable formats: */ 48 CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties(); 49 const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats(); 50 /* Search for default (VDI) format first: */ 51 for (int i = 0; i < medFormats.size(); ++i) 46 QGridLayout *pMainLayout = new QGridLayout(this); 52 47 { 53 /* Get iterated medium format: */ 54 const CMediumFormat &medFormat = medFormats[i]; 55 QString strFormatName(medFormat.GetName()); 56 if (strFormatName == "VDI") 48 pMainLayout->setContentsMargins(8, 6, 8, 6); 49 m_pLocationCnt = new QGroupBox(this); 57 50 { 58 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);59 if (pButton)51 m_pLocationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 52 QHBoxLayout *pLocationCntLayout = new QHBoxLayout(m_pLocationCnt); 60 53 { 61 m_formats << medFormat; 62 m_formatNames << strFormatName; 63 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1); 54 m_pLocationEditor = new QLineEdit(m_pLocationCnt); 55 { 56 m_pLocationEditor->setText(m_strDefaultName); 57 } 58 m_pLocationOpenButton = new QIToolButton(m_pLocationCnt); 59 { 60 m_pLocationOpenButton->setAutoRaise(true); 61 m_pLocationOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png")); 62 } 63 pLocationCntLayout->addWidget(m_pLocationEditor); 64 pLocationCntLayout->addWidget(m_pLocationOpenButton); 64 65 } 65 66 } 66 } 67 /* Look for other formats: */ 68 for (int i = 0; i < medFormats.size(); ++i) 69 { 70 /* Get iterated medium format: */ 71 const CMediumFormat &medFormat = medFormats[i]; 72 QString strFormatName(medFormat.GetName()); 73 if (strFormatName != "VDI") 67 m_pSizeCnt = new QGroupBox(this); 74 68 { 75 QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);76 if (pButton)69 m_pSizeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 70 QGridLayout *m_pSizeCntLayout = new QGridLayout(m_pSizeCnt); 77 71 { 78 m_formats << medFormat; 79 m_formatNames << strFormatName; 80 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1); 72 m_pSizeSlider = new QSlider(m_pSizeCnt); 73 { 74 m_pSizeSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 75 m_pSizeSlider->setOrientation(Qt::Horizontal); 76 m_pSizeSlider->setTickPosition(QSlider::TicksBelow); 77 m_pSizeSlider->setFocusPolicy(Qt::StrongFocus); 78 m_pSizeSlider->setPageStep(m_iSliderScale); 79 m_pSizeSlider->setSingleStep(m_iSliderScale / 8); 80 m_pSizeSlider->setTickInterval(0); 81 m_pSizeSlider->setMinimum(sizeMBToSlider(m_uMediumSizeMin, m_iSliderScale)); 82 m_pSizeSlider->setMaximum(sizeMBToSlider(m_uMediumSizeMax, m_iSliderScale)); 83 } 84 m_pSizeEditor = new QILineEdit(m_pSizeCnt); 85 { 86 m_pSizeEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); 87 m_pSizeEditor->setFixedWidthByText("88888.88 MB"); 88 m_pSizeEditor->setAlignment(Qt::AlignRight); 89 m_pSizeEditor->setValidator(new QRegExpValidator(QRegExp(vboxGlobal().sizeRegexp()), this)); 90 } 91 QLabel *m_pSizeMin = new QLabel(m_pSizeCnt); 92 { 93 m_pSizeMin->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); 94 m_pSizeMin->setText(vboxGlobal().formatSize(m_uMediumSizeMin)); 95 } 96 QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed); 97 QLabel *m_pSizeMax = new QLabel(m_pSizeCnt); 98 { 99 m_pSizeMax->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); 100 m_pSizeMax->setText(vboxGlobal().formatSize(m_uMediumSizeMax)); 101 } 102 m_pSizeCntLayout->addWidget(m_pSizeSlider, 0, 0, 1, 3); 103 m_pSizeCntLayout->addWidget(m_pSizeEditor, 0, 3); 104 m_pSizeCntLayout->addWidget(m_pSizeMin, 1, 0); 105 m_pSizeCntLayout->addItem(m_pSizeSpacer, 1, 1); 106 m_pSizeCntLayout->addWidget(m_pSizeMax, 1, 2); 81 107 } 82 108 } 109 QVBoxLayout *pFormatWrappingLayout = new QVBoxLayout; 110 { 111 m_pFormatCnt = new QGroupBox(this); 112 { 113 m_pFormatCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 114 QVBoxLayout *pFormatCntLayout = new QVBoxLayout(m_pFormatCnt); 115 { 116 m_pFormatButtonGroup = new QButtonGroup(m_pFormatCnt); 117 { 118 CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties(); 119 const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats(); 120 for (int i = 0; i < medFormats.size(); ++i) 121 { 122 const CMediumFormat &medFormat = medFormats[i]; 123 QString strFormatName(medFormat.GetName()); 124 if (strFormatName == "VDI") 125 { 126 QRadioButton *pButton = addFormatButton(pFormatCntLayout, medFormat); 127 if (pButton) 128 { 129 m_formats << medFormat; 130 m_formatNames << strFormatName; 131 m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1); 132 } 133 } 134 } 135 for (int i = 0; i < medFormats.size(); ++i) 136 { 137 const CMediumFormat &medFormat = medFormats[i]; 138 QString strFormatName(medFormat.GetName()); 139 if (strFormatName != "VDI") 140 { 141 QRadioButton *pButton = addFormatButton(pFormatCntLayout, medFormat); 142 if (pButton) 143 { 144 m_formats << medFormat; 145 m_formatNames << strFormatName; 146 m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1); 147 } 148 } 149 } 150 m_pFormatButtonGroup->button(0)->click(); 151 m_pFormatButtonGroup->button(0)->setFocus(); 152 } 153 } 154 } 155 QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding); 156 pFormatWrappingLayout->addWidget(m_pFormatCnt); 157 pFormatWrappingLayout->addItem(m_pSizeSpacer); 158 } 159 QVBoxLayout *pVariantWrappingLayout = new QVBoxLayout; 160 { 161 m_pVariantCnt = new QGroupBox(this); 162 { 163 m_pVariantCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 164 QVBoxLayout *pVariantsLayout = new QVBoxLayout(m_pVariantCnt); 165 { 166 m_pVariantButtonGroup = new QButtonGroup(m_pVariantCnt); 167 { 168 m_pDynamicalButton = new QRadioButton(m_pVariantCnt); 169 { 170 m_pDynamicalButton->click(); 171 m_pDynamicalButton->setFocus(); 172 } 173 m_pFixedButton = new QRadioButton(m_pVariantCnt); 174 m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0); 175 m_pVariantButtonGroup->addButton(m_pFixedButton, 1); 176 } 177 m_pSplitBox = new QCheckBox(m_pVariantCnt); 178 pVariantsLayout->addWidget(m_pDynamicalButton); 179 pVariantsLayout->addWidget(m_pFixedButton); 180 pVariantsLayout->addWidget(m_pSplitBox); 181 } 182 } 183 QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding); 184 pVariantWrappingLayout->addWidget(m_pVariantCnt); 185 pVariantWrappingLayout->addItem(m_pSizeSpacer); 186 } 187 pMainLayout->addWidget(m_pLocationCnt, 0, 0, 1, 2); 188 pMainLayout->addWidget(m_pSizeCnt, 1, 0, 1, 2); 189 pMainLayout->addLayout(pFormatWrappingLayout, 2, 0); 190 pMainLayout->addLayout(pVariantWrappingLayout, 2, 1); 191 setMediumSize(uDefaultSize); 192 sltMediumFormatChanged(); 83 193 } 84 194 85 195 /* Setup connections: */ 86 connect(m_pButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(completeChanged())); 87 88 /* Initialize connections: */ 89 m_pButtonGroup->button(0)->click(); 90 m_pButtonGroup->button(0)->setFocus(); 91 92 /* Register CMediumFormat class: */ 196 connect(m_pFormatButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(sltMediumFormatChanged())); 197 connect(m_pVariantButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged())); 198 connect(m_pSplitBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged())); 199 connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged())); 200 connect(m_pLocationOpenButton, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked())); 201 connect(m_pSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(sltSizeSliderValueChanged(int))); 202 connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltSizeEditorTextChanged(const QString &))); 203 204 /* Register classes: */ 93 205 qRegisterMetaType<CMediumFormat>(); 94 /* Register 'mediumFormat' field: */206 /* Register fields: */ 95 207 registerField("mediumFormat", this, "mediumFormat"); 96 } 97 98 void UIWizardNewVDPageBasic1::retranslateUi() 99 { 100 /* Translate page: */ 101 setTitle(UIWizardNewVD::tr("Welcome to the virtual disk creation wizard")); 102 208 registerField("mediumVariant", this, "mediumVariant"); 209 registerField("mediumPath", this, "mediumPath"); 210 registerField("mediumSize", this, "mediumSize"); 211 } 212 213 void UIWizardNewVDPageExpert::sltMediumFormatChanged() 214 { 215 /* Get medium format: */ 216 CMediumFormat mf = mediumFormat(); 217 218 /* Enable/disable widgets: */ 219 ULONG uCapabilities = mf.GetCapabilities(); 220 bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic; 221 bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed; 222 bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G; 223 m_pDynamicalButton->setEnabled(fIsCreateDynamicPossible); 224 m_pFixedButton->setEnabled(fIsCreateFixedPossible); 225 m_pSplitBox->setEnabled(fIsCreateSplitPossible); 226 227 /* Compose virtual-disk extension: */ 228 m_strDefaultExtension = defaultExtension(mf); 229 230 /* Broadcast complete-change: */ 231 completeChanged(); 232 } 233 234 void UIWizardNewVDPageExpert::sltSelectLocationButtonClicked() 235 { 236 /* Call to base-class: */ 237 onSelectLocationButtonClicked(); 238 } 239 240 void UIWizardNewVDPageExpert::sltSizeSliderValueChanged(int iValue) 241 { 242 onSizeSliderValueChanged(iValue); 243 244 emit completeChanged(); 245 } 246 247 void UIWizardNewVDPageExpert::sltSizeEditorTextChanged(const QString &strValue) 248 { 249 onSizeEditorTextChanged(strValue); 250 251 emit completeChanged(); 252 } 253 254 void UIWizardNewVDPageExpert::retranslateUi() 255 { 103 256 /* Translate widgets: */ 104 m_pLabel->setText(UIWizardNewVD::tr("<p>This wizard will help you to create a new virtual disk for your virtual machine.</p>")); 105 m_pLabel->setText(m_pLabel->text() + QString("<p>%1</p>").arg(standardHelpText())); 106 m_pLabel->setText(m_pLabel->text() + UIWizardNewVD::tr("<p>Please choose the type of file that you would like " 107 "to use for the new virtual disk. If you do not need " 108 "to use it with other virtualization software you can " 109 "leave this setting unchanged.</p>")); 110 m_pFormatContainer->setTitle(UIWizardNewVD::tr("File type")); 111 112 /* Translate 'format' buttons: */ 113 QList<QAbstractButton*> buttons = m_pButtonGroup->buttons(); 257 m_pLocationCnt->setTitle(UIWizardNewVD::tr("&Location")); 258 m_pLocationOpenButton->setToolTip(UIWizardNewVD::tr("Choose a virtual hard disk file...")); 259 m_pSizeCnt->setTitle(UIWizardNewVD::tr("&Size")); 260 m_pFormatCnt->setTitle(UIWizardNewVD::tr("File type")); 261 QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons(); 114 262 for (int i = 0; i < buttons.size(); ++i) 115 263 { 116 264 QAbstractButton *pButton = buttons[i]; 117 pButton->setText(UIWizardNewVD::fullFormatName(m_formatNames[m_p ButtonGroup->id(pButton)]));265 pButton->setText(UIWizardNewVD::fullFormatName(m_formatNames[m_pFormatButtonGroup->id(pButton)])); 118 266 } 119 } 120 121 void UIWizardNewVDPageBasic1::initializePage() 267 m_pVariantCnt->setTitle(UIWizardNewVD::tr("Storage details")); 268 m_pDynamicalButton->setText(UIWizardNewVD::tr("&Dynamically allocated")); 269 m_pFixedButton->setText(UIWizardNewVD::tr("&Fixed size")); 270 m_pSplitBox->setText(UIWizardNewVD::tr("&Split into files of less than 2GB")); 271 } 272 273 void UIWizardNewVDPageExpert::initializePage() 122 274 { 123 275 /* Translate page: */ … … 125 277 } 126 278 127 bool UIWizardNewVDPageBasic1::isComplete() const 128 { 129 return !mediumFormat().isNull(); 130 } 131 132 int UIWizardNewVDPageBasic1::nextId() const 133 { 134 CMediumFormat medFormat = mediumFormat(); 135 ULONG uCapabilities = medFormat.GetCapabilities(); 136 int cTest = 0; 137 if (uCapabilities & KMediumFormatCapabilities_CreateDynamic) 138 ++cTest; 139 if (uCapabilities & KMediumFormatCapabilities_CreateFixed) 140 ++cTest; 141 if (uCapabilities & KMediumFormatCapabilities_CreateSplit2G) 142 ++cTest; 143 if (cTest > 1) 144 return UIWizardNewVD::Page2; 145 return UIWizardNewVD::Page3; 146 } 147 148 QRadioButton* UIWizardNewVDPageBasic1::addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat medFormat) 149 { 150 /* Check that medium format supports creation: */ 151 ULONG uFormatCapabilities = medFormat.GetCapabilities(); 152 if (!(uFormatCapabilities & MediumFormatCapabilities_CreateFixed || 153 uFormatCapabilities & MediumFormatCapabilities_CreateDynamic)) 154 return 0; 155 156 /* Check that medium format supports creation of virtual hard-disks: */ 157 QVector<QString> fileExtensions; 158 QVector<KDeviceType> deviceTypes; 159 medFormat.DescribeFileExtensions(fileExtensions, deviceTypes); 160 if (!deviceTypes.contains(KDeviceType_HardDisk)) 161 return 0; 162 163 /* Create/add corresponding radio-button: */ 164 QRadioButton *pFormatButton = new QRadioButton(m_pFormatContainer); 165 pFormatsLayout->addWidget(pFormatButton); 166 return pFormatButton; 167 } 168 169 CMediumFormat UIWizardNewVDPageBasic1::mediumFormat() const 170 { 171 return m_pButtonGroup->checkedButton() ? m_formats[m_pButtonGroup->checkedId()] : CMediumFormat(); 172 } 173 174 void UIWizardNewVDPageBasic1::setMediumFormat(const CMediumFormat &mediumFormat) 175 { 176 int iPosition = m_formats.indexOf(mediumFormat); 177 if (iPosition >= 0) 279 bool UIWizardNewVDPageExpert::isComplete() const 280 { 281 /* Make sure medium format/variant is correct, 282 * current name is not empty and current size feats the bounds: */ 283 return !mediumFormat().isNull() && 284 mediumVariant() != (qulonglong)KMediumVariant_Max && 285 !m_pLocationEditor->text().trimmed().isEmpty() && 286 mediumSize() >= m_uMediumSizeMin && mediumSize() <= m_uMediumSizeMax; 287 } 288 289 bool UIWizardNewVDPageExpert::validatePage() 290 { 291 /* Initial result: */ 292 bool fResult = true; 293 294 /* Lock finish button: */ 295 startProcessing(); 296 297 /* Make sure that virtual-disk doesn't exists: */ 298 QString strMediumPath(mediumPath()); 299 if (fResult && QFileInfo(strMediumPath).exists()) 178 300 { 179 m _pButtonGroup->button(iPosition)->click();180 m_pButtonGroup->button(iPosition)->setFocus();301 msgCenter().sayCannotOverwriteHardDiskStorage(this, strMediumPath); 302 fResult = false; 181 303 } 182 } 183 304 305 /* Try to create virtual-disk: */ 306 if (fResult) 307 fResult = qobject_cast<UIWizardNewVD*>(wizard())->createVirtualDisk(); 308 309 /* Unlock finish button: */ 310 endProcessing(); 311 312 /* Return result: */ 313 return fResult; 314 } 315 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.h
r40929 r41021 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * UIWizardNewVDPage Basic1class declaration4 * UIWizardNewVDPageExpert class declaration 5 5 */ 6 6 … … 17 17 */ 18 18 19 #ifndef __UIWizardNewVDPage Basic1_h__20 #define __UIWizardNewVDPage Basic1_h__19 #ifndef __UIWizardNewVDPageExpert_h__ 20 #define __UIWizardNewVDPageExpert_h__ 21 21 22 22 /* Local includes: */ 23 #include "UIWizardPage.h" 24 #include "COMDefs.h" 23 #include "UIWizardNewVDPageBasic1.h" 24 #include "UIWizardNewVDPageBasic2.h" 25 #include "UIWizardNewVDPageBasic3.h" 26 #include "UIWizardNewVDPageBasic4.h" 25 27 26 /* Forward declarations: */ 27 class QVBoxLayout; 28 class QRadioButton; 29 class QIRichTextLabel; 30 class QGroupBox; 31 class QButtonGroup; 32 33 /* 1st page of the New Virtual Disk wizard: */ 34 class UIWizardNewVDPageBasic1 : public UIWizardPage 28 /* Expert page of the New Virtual Disk wizard: */ 29 class UIWizardNewVDPageExpert : public UIWizardPage, 30 public UIWizardNewVDPage1, 31 public UIWizardNewVDPage2, 32 public UIWizardNewVDPage3, 33 public UIWizardNewVDPage4 35 34 { 36 35 Q_OBJECT; 37 36 Q_PROPERTY(CMediumFormat mediumFormat READ mediumFormat WRITE setMediumFormat); 37 Q_PROPERTY(qulonglong mediumVariant READ mediumVariant WRITE setMediumVariant); 38 Q_PROPERTY(QString mediumPath READ mediumPath); 39 Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize); 38 40 39 41 public: 40 42 41 43 /* Constructor: */ 42 UIWizardNewVDPageBasic1(); 44 UIWizardNewVDPageExpert(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize); 45 46 protected: 47 48 /* Wrapper to access 'this' from base part: */ 49 UIWizardPage* thisImp() { return this; } 50 /* Wrapper to access 'wizard-field' from base part: */ 51 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 52 53 private slots: 54 55 /* Medium format stuff: */ 56 void sltMediumFormatChanged(); 57 58 /* Location editors stuff: */ 59 void sltSelectLocationButtonClicked(); 60 /* Size editors stuff: */ 61 void sltSizeSliderValueChanged(int iValue); 62 void sltSizeEditorTextChanged(const QString &strValue); 43 63 44 64 private: … … 52 72 /* Validation stuff: */ 53 73 bool isComplete() const; 54 55 /* Navigation stuff: */ 56 int nextId() const; 57 58 /* Helping stuff: */ 59 QRadioButton* addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mediumFormat); 60 61 /* Stuff for 'mediumFormat' field: */ 62 CMediumFormat mediumFormat() const; 63 void setMediumFormat(const CMediumFormat &mediumFormat); 64 65 /* Variables: */ 66 QButtonGroup *m_pButtonGroup; 67 QList<CMediumFormat> m_formats; 68 QStringList m_formatNames; 69 70 /* Widgets: */ 71 QIRichTextLabel *m_pLabel; 72 QGroupBox *m_pFormatContainer; 74 bool validatePage(); 73 75 }; 74 76 75 #endif // __UIWizardNewVDPage Basic1_h__77 #endif // __UIWizardNewVDPageExpert_h__ 76 78 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r40870 r41021 25 25 #include "UIWizardNewVMPageBasic4.h" 26 26 #include "UIWizardNewVMPageBasic5.h" 27 #include "UIWizardNewVMPageExpert.h" 27 28 #include "VBoxDefs.h" 28 29 #include "VBoxGlobal.h" … … 33 34 34 35 UIWizardNewVM::UIWizardNewVM(QWidget *pParent) 35 : UIWizard(pParent )36 : UIWizard(pParent, UIWizardType_NewVM) 36 37 , m_iIDECount(0) 37 38 , m_iSATACount(0) … … 40 41 , m_iSASCount(0) 41 42 { 42 /* Create & add pages: */43 setPage(Page1, new UIWizardNewVMPageBasic1);44 setPage(Page2, new UIWizardNewVMPageBasic2);45 setPage(Page3, new UIWizardNewVMPageBasic3);46 setPage(Page4, new UIWizardNewVMPageBasic4);47 setPage(Page5, new UIWizardNewVMPageBasic5);48 49 /* Translate wizard: */50 retranslateUi();51 52 /* Translate wizard pages: */53 retranslateAllPages();54 55 43 #ifndef Q_WS_MAC 56 44 /* Assign watermark: */ … … 60 48 assignBackground(":/vmw_new_welcome_bg.png"); 61 49 #endif /* Q_WS_MAC */ 62 63 /* Resize wizard to 'golden ratio': */64 resizeToGoldenRatio(UIWizardType_NewVM);65 50 } 66 51 … … 273 258 void UIWizardNewVM::retranslateUi() 274 259 { 260 /* Call to base-class: */ 261 UIWizard::retranslateUi(); 262 275 263 /* Translate wizard: */ 276 264 setWindowTitle(tr("Create New Virtual Machine")); 277 265 setButtonText(QWizard::FinishButton, tr("Create")); 266 } 267 268 void UIWizardNewVM::prepare() 269 { 270 /* Create corresponding pages: */ 271 switch (mode()) 272 { 273 case UIWizardMode_Basic: 274 { 275 setPage(Page1, new UIWizardNewVMPageBasic1); 276 setPage(Page2, new UIWizardNewVMPageBasic2); 277 setPage(Page3, new UIWizardNewVMPageBasic3); 278 setPage(Page4, new UIWizardNewVMPageBasic4); 279 setPage(Page5, new UIWizardNewVMPageBasic5); 280 break; 281 } 282 case UIWizardMode_Expert: 283 { 284 setPage(PageExpert, new UIWizardNewVMPageExpert); 285 break; 286 } 287 } 288 /* Call to base-class: */ 289 UIWizard::prepare(); 278 290 } 279 291 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h
r40870 r41021 41 41 }; 42 42 43 /* Page IDs: */ 44 enum 45 { 46 PageExpert 47 }; 48 43 49 /* Constructor: */ 44 50 UIWizardNewVM(QWidget *pParent); … … 51 57 /* Who will be able to create virtual-machine: */ 52 58 friend class UIWizardNewVMPageBasic5; 59 friend class UIWizardNewVMPageExpert; 53 60 54 61 private: … … 56 63 /* Translation stuff: */ 57 64 void retranslateUi(); 65 66 /* Pages related stuff: */ 67 void prepare(); 58 68 59 69 /* Helping stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp
r40870 r41021 27 27 #include "QIRichTextLabel.h" 28 28 29 UIWizardNewVMPage1::UIWizardNewVMPage1() 30 { 31 } 32 29 33 UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1() 30 34 { 31 35 /* Create widgets: */ 32 36 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 37 { 33 38 m_pLabel1 = new QIRichTextLabel(this); 39 { 34 40 /* Register 'message-box warning-icon' image in m_pLabel1 as 'image': */ 35 41 QSize wSize(64, 64); … … 39 45 QImage wImage = wPixmap.toImage(); 40 46 m_pLabel1->registerImage(wImage, "image"); 47 } 41 48 m_pLabel2 = new QIRichTextLabel(this); 42 pMainLayout->addWidget(m_pLabel1); 43 pMainLayout->addWidget(m_pLabel2); 44 pMainLayout->addStretch(); 49 pMainLayout->addWidget(m_pLabel1); 50 pMainLayout->addWidget(m_pLabel2); 51 pMainLayout->addStretch(); 52 } 45 53 } 46 54 … … 48 56 { 49 57 /* Translate page: */ 50 setTitle(UIWizardNewVM::tr("Welcome to the New Virtual Machine Wizard!"));58 setTitle(UIWizardNewVM::tr("Welcome to the New Virtual Machine wizard!")); 51 59 52 60 /* Translate widgets: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h
r40870 r41021 22 22 /* Local includes: */ 23 23 #include "UIWizardPage.h" 24 #include "COMDefs.h"25 #include "QIWithRetranslateUI.h"26 24 27 25 /* Forward declarations: */ 28 26 class QIRichTextLabel; 29 27 30 /* 1st page of the New Virtual Machine wizard: */ 31 class UIWizardNewVMPageBasic1 : public UIWizardPage 28 /* 1st page of the New Virtual Machine wizard (base part): */ 29 class UIWizardNewVMPage1 : public UIWizardPageBase 30 { 31 protected: 32 33 /* Constructor: */ 34 UIWizardNewVMPage1(); 35 }; 36 37 /* 1st page of the New Virtual Machine wizard (basic extension): */ 38 class UIWizardNewVMPageBasic1 : public UIWizardPage, public UIWizardNewVMPage1 32 39 { 33 40 Q_OBJECT; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.cpp
r40870 r41021 29 29 #include "UIWizardNewVM.h" 30 30 #include "UIMessageCenter.h" 31 #include "VBoxOSTypeSelectorWidget.h" 31 32 #include "QIRichTextLabel.h" 32 #include "VBoxOSTypeSelectorWidget.h"33 33 34 34 /* Defines some patterns to guess the right OS type. Should be in sync with … … 138 138 }; 139 139 140 UIWizardNewVMPageBasic2::UIWizardNewVMPageBasic2() 141 { 142 /* Create widgets: */ 143 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 144 m_pLabel = new QIRichTextLabel(this); 145 m_pNameEditorCnt = new QGroupBox(this); 146 m_pNameEditorCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 147 QHBoxLayout *pNameEditorLayout = new QHBoxLayout(m_pNameEditorCnt); 148 m_pNameEditor = new QLineEdit(m_pNameEditorCnt); 149 pNameEditorLayout->addWidget(m_pNameEditor); 150 m_pTypeSelectorCnt = new QGroupBox(this); 151 m_pTypeSelectorCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 152 QHBoxLayout *pTypeSelectorLayout = new QHBoxLayout(m_pTypeSelectorCnt); 153 m_pTypeSelector = new VBoxOSTypeSelectorWidget(m_pTypeSelectorCnt); 154 m_pTypeSelector->activateLayout(); 155 pTypeSelectorLayout->addWidget(m_pTypeSelector); 156 pMainLayout->addWidget(m_pLabel); 157 pMainLayout->addWidget(m_pNameEditorCnt); 158 pMainLayout->addWidget(m_pTypeSelectorCnt); 159 pMainLayout->addStretch(); 160 161 /* Setup connections: */ 162 connect(m_pNameEditor, SIGNAL(textChanged(const QString&)), this, SLOT(sltNameChanged(const QString&))); 163 connect(m_pTypeSelector, SIGNAL(osTypeChanged()), this, SLOT(sltOsTypeChanged())); 164 165 /* Register fields: */ 166 registerField("name*", m_pNameEditor); 167 registerField("type", m_pTypeSelector, "type", SIGNAL(osTypeChanged())); 168 registerField("machineFolder", this, "machineFolder"); 169 registerField("machineBaseName", this, "machineBaseName"); 170 } 171 172 void UIWizardNewVMPageBasic2::sltNameChanged(const QString &strNewName) 140 UIWizardNewVMPage2::UIWizardNewVMPage2() 141 { 142 } 143 144 void UIWizardNewVMPage2::onNameChanged(const QString &strNewName) 173 145 { 174 146 /* Search for a matching OS type based on the string the user typed already. */ 175 for (size_t i =0; i < RT_ELEMENTS(gs_OSTypePattern); ++i)147 for (size_t i = 0; i < RT_ELEMENTS(gs_OSTypePattern); ++i) 176 148 if (strNewName.contains(gs_OSTypePattern[i].pattern)) 177 149 { … … 183 155 } 184 156 185 void UIWizardNewVMPage Basic2::sltOsTypeChanged()157 void UIWizardNewVMPage2::onOsTypeChanged() 186 158 { 187 159 /* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore. 188 160 * So simply disconnect the text-edit signal. */ 189 disconnect(m_pNameEditor, SIGNAL(textChanged(const QString&)), this, SLOT(sltNameChanged(const QString&))); 190 } 191 192 void UIWizardNewVMPageBasic2::retranslateUi() 193 { 194 /* Translate page: */ 195 setTitle(UIWizardNewVM::tr("VM Name and OS Type")); 196 197 /* Translate widgets: */ 198 m_pLabel->setText(UIWizardNewVM::tr("<p>Enter a name for the new virtual machine and select the type of the guest operating system " 199 "you plan to install onto the virtual machine.</p><p>The name of the virtual machine usually " 200 "indicates its software and hardware configuration. It will be used by all VirtualBox components " 201 "to identify your virtual machine.</p>")); 202 m_pNameEditorCnt->setTitle(UIWizardNewVM::tr("N&ame")); 203 m_pTypeSelectorCnt->setTitle(UIWizardNewVM::tr("OS &Type")); 204 } 205 206 void UIWizardNewVMPageBasic2::initializePage() 207 { 208 /* Translate page: */ 209 retranslateUi(); 210 211 /* 'Name' field should have focus initially: */ 212 m_pNameEditor->setFocus(); 213 } 214 215 void UIWizardNewVMPageBasic2::cleanupPage() 216 { 217 /* Cleanup: */ 218 cleanupMachineFolder(); 219 /* Call for base-class: */ 220 UIWizardPage::cleanupPage(); 221 } 222 223 bool UIWizardNewVMPageBasic2::validatePage() 224 { 225 return createMachineFolder(); 226 } 227 228 bool UIWizardNewVMPageBasic2::machineFolderCreated() 161 m_pNameEditor->disconnect(thisImp()); 162 } 163 164 bool UIWizardNewVMPage2::machineFolderCreated() 229 165 { 230 166 return !m_strMachineFolder.isEmpty(); 231 167 } 232 168 233 bool UIWizardNewVMPage Basic2::createMachineFolder()169 bool UIWizardNewVMPage2::createMachineFolder() 234 170 { 235 171 /* Cleanup previosly created folder if any: */ 236 172 if (machineFolderCreated() && !cleanupMachineFolder()) 237 173 { 238 msgCenter().warnAboutCannotRemoveMachineFolder(this , m_strMachineFolder);174 msgCenter().warnAboutCannotRemoveMachineFolder(thisImp(), m_strMachineFolder); 239 175 return false; 240 176 } … … 254 190 if (QDir(strMachineFolder).exists()) 255 191 { 256 msgCenter().warnAboutCannotRewriteMachineFolder(this , strMachineFolder);192 msgCenter().warnAboutCannotRewriteMachineFolder(thisImp(), strMachineFolder); 257 193 return false; 258 194 } … … 262 198 if (!fMachineFolderCreated) 263 199 { 264 msgCenter().warnAboutCannotCreateMachineFolder(this , strMachineFolder);200 msgCenter().warnAboutCannotCreateMachineFolder(thisImp(), strMachineFolder); 265 201 return false; 266 202 } … … 272 208 } 273 209 274 bool UIWizardNewVMPage Basic2::cleanupMachineFolder()210 bool UIWizardNewVMPage2::cleanupMachineFolder() 275 211 { 276 212 /* Make sure folder was previosly created: */ … … 286 222 } 287 223 288 QString UIWizardNewVMPageBasic2::machineFolder() const 289 { 290 return m_strMachineFolder; 291 } 292 293 void UIWizardNewVMPageBasic2::setMachineFolder(const QString &strMachineFolder) 294 { 295 m_strMachineFolder = strMachineFolder; 296 } 297 298 QString UIWizardNewVMPageBasic2::machineBaseName() const 299 { 300 return m_strMachineBaseName; 301 } 302 303 void UIWizardNewVMPageBasic2::setMachineBaseName(const QString &strMachineBaseName) 304 { 305 m_strMachineBaseName = strMachineBaseName; 306 } 307 224 UIWizardNewVMPageBasic2::UIWizardNewVMPageBasic2() 225 { 226 /* Create widgets: */ 227 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 228 { 229 m_pLabel = new QIRichTextLabel(this); 230 m_pNameCnt = new QGroupBox(this); 231 { 232 m_pNameCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 233 QHBoxLayout *pNameCntLayout = new QHBoxLayout(m_pNameCnt); 234 { 235 m_pNameEditor = new QLineEdit(m_pNameCnt); 236 pNameCntLayout->addWidget(m_pNameEditor); 237 } 238 } 239 m_pTypeCnt = new QGroupBox(this); 240 { 241 m_pTypeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 242 QHBoxLayout *pTypeSelectorLayout = new QHBoxLayout(m_pTypeCnt); 243 { 244 m_pTypeSelector = new VBoxOSTypeSelectorWidget(m_pTypeCnt); 245 { 246 m_pTypeSelector->activateLayout(); 247 } 248 pTypeSelectorLayout->addWidget(m_pTypeSelector); 249 } 250 } 251 pMainLayout->addWidget(m_pLabel); 252 pMainLayout->addWidget(m_pNameCnt); 253 pMainLayout->addWidget(m_pTypeCnt); 254 pMainLayout->addStretch(); 255 } 256 257 /* Setup connections: */ 258 connect(m_pNameEditor, SIGNAL(textChanged(const QString&)), this, SLOT(sltNameChanged(const QString&))); 259 connect(m_pTypeSelector, SIGNAL(osTypeChanged()), this, SLOT(sltOsTypeChanged())); 260 261 /* Register fields: */ 262 registerField("name*", m_pNameEditor); 263 registerField("type", m_pTypeSelector, "type", SIGNAL(osTypeChanged())); 264 registerField("machineFolder", this, "machineFolder"); 265 registerField("machineBaseName", this, "machineBaseName"); 266 } 267 268 void UIWizardNewVMPageBasic2::sltNameChanged(const QString &strNewName) 269 { 270 /* Call to base-class: */ 271 onNameChanged(strNewName); 272 } 273 274 void UIWizardNewVMPageBasic2::sltOsTypeChanged() 275 { 276 /* Call to base-class: */ 277 onOsTypeChanged(); 278 } 279 280 void UIWizardNewVMPageBasic2::retranslateUi() 281 { 282 /* Translate page: */ 283 setTitle(UIWizardNewVM::tr("VM Name and OS Type")); 284 285 /* Translate widgets: */ 286 m_pLabel->setText(UIWizardNewVM::tr("<p>Enter a name for the new virtual machine and select the type of the guest operating system " 287 "you plan to install onto the virtual machine.</p><p>The name of the virtual machine usually " 288 "indicates its software and hardware configuration. It will be used by all VirtualBox components " 289 "to identify your virtual machine.</p>")); 290 m_pNameCnt->setTitle(UIWizardNewVM::tr("&Name")); 291 m_pTypeCnt->setTitle(UIWizardNewVM::tr("OS &Type")); 292 } 293 294 void UIWizardNewVMPageBasic2::initializePage() 295 { 296 /* Translate page: */ 297 retranslateUi(); 298 299 /* 'Name' field should have focus initially: */ 300 m_pNameEditor->setFocus(); 301 } 302 303 void UIWizardNewVMPageBasic2::cleanupPage() 304 { 305 /* Cleanup: */ 306 cleanupMachineFolder(); 307 /* Call to base-class: */ 308 UIWizardPage::cleanupPage(); 309 } 310 311 bool UIWizardNewVMPageBasic2::validatePage() 312 { 313 /* Try to create machine folder: */ 314 return createMachineFolder(); 315 } 316 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.h
r40870 r41021 24 24 25 25 /* Forward declarations: */ 26 class QIRichTextLabel;27 26 class QGroupBox; 28 27 class QLineEdit; 29 28 class VBoxOSTypeSelectorWidget; 29 class QIRichTextLabel; 30 30 31 /* 2nd page of the New Virtual Machine wizard: */ 32 class UIWizardNewVMPageBasic2 : public UIWizardPage 31 /* 2nd page of the New Virtual Machine wizard (base part): */ 32 class UIWizardNewVMPage2 : public UIWizardPageBase 33 { 34 protected: 35 36 /* Constructor: */ 37 UIWizardNewVMPage2(); 38 39 /* Handlers: */ 40 void onNameChanged(const QString &strNewName); 41 void onOsTypeChanged(); 42 43 /* Helping stuff: */ 44 bool machineFolderCreated(); 45 bool createMachineFolder(); 46 bool cleanupMachineFolder(); 47 48 /* Stuff for 'machineFolder' field: */ 49 QString machineFolder() const { return m_strMachineFolder; } 50 void setMachineFolder(const QString &strMachineFolder) { m_strMachineFolder = strMachineFolder; } 51 52 /* Stuff for 'machineBaseName' field: */ 53 QString machineBaseName() const { return m_strMachineBaseName; } 54 void setMachineBaseName(const QString &strMachineBaseName) { m_strMachineBaseName = strMachineBaseName; } 55 56 /* Variables: */ 57 QString m_strMachineFolder; 58 QString m_strMachineBaseName; 59 60 /* Widgets: */ 61 QGroupBox *m_pNameCnt; 62 QLineEdit *m_pNameEditor; 63 QGroupBox *m_pTypeCnt; 64 VBoxOSTypeSelectorWidget *m_pTypeSelector; 65 }; 66 67 /* 2nd page of the New Virtual Machine wizard (basic extension): */ 68 class UIWizardNewVMPageBasic2 : public UIWizardPage, public UIWizardNewVMPage2 33 69 { 34 70 Q_OBJECT; … … 40 76 /* Constructor: */ 41 77 UIWizardNewVMPageBasic2(); 78 79 protected: 80 81 /* Wrapper to access 'this' from base part: */ 82 UIWizardPage* thisImp() { return this; } 42 83 43 84 private slots: … … 59 100 bool validatePage(); 60 101 61 /* Helping stuff: */62 bool machineFolderCreated();63 bool createMachineFolder();64 bool cleanupMachineFolder();65 66 /* Stuff for 'machineFolder' field: */67 QString machineFolder() const;68 void setMachineFolder(const QString &strMachineFolder);69 QString m_strMachineFolder;70 71 /* Stuff for 'machineBaseName' field: */72 QString machineBaseName() const;73 void setMachineBaseName(const QString &strMachineBaseName);74 QString m_strMachineBaseName;75 76 102 /* Widgets: */ 77 103 QIRichTextLabel *m_pLabel; 78 QGroupBox *m_pNameEditorCnt;79 QLineEdit *m_pNameEditor;80 QGroupBox *m_pTypeSelectorCnt;81 VBoxOSTypeSelectorWidget *m_pTypeSelector;82 104 }; 83 105 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic3.cpp
r40870 r41021 31 31 #include "COMDefs.h" 32 32 #include "VBoxGlobal.h" 33 #include "QIRichTextLabel.h"34 33 #include "VBoxGuestRAMSlider.h" 35 34 #include "QILineEdit.h" 35 #include "QIRichTextLabel.h" 36 37 UIWizardNewVMPage3::UIWizardNewVMPage3() 38 { 39 } 40 41 void UIWizardNewVMPage3::onRamSliderValueChanged(int iValue) 42 { 43 /* Update 'ram' field editor connected to slider: */ 44 m_pRamEditor->blockSignals(true); 45 m_pRamEditor->setText(QString::number(iValue)); 46 m_pRamEditor->blockSignals(false); 47 } 48 49 void UIWizardNewVMPage3::onRamEditorTextChanged(const QString &strText) 50 { 51 /* Update 'ram' field slider connected to editor: */ 52 m_pRamSlider->blockSignals(true); 53 m_pRamSlider->setValue(strText.toInt()); 54 m_pRamSlider->blockSignals(false); 55 } 36 56 37 57 UIWizardNewVMPageBasic3::UIWizardNewVMPageBasic3() … … 39 59 /* Create widget: */ 40 60 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 61 { 41 62 m_pLabel1 = new QIRichTextLabel(this); 42 63 m_pLabel2 = new QIRichTextLabel(this); 43 64 m_pMemoryCnt = new QGroupBox(this); 65 { 44 66 m_pMemoryCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 45 QGridLayout *pMemoryLayout = new QGridLayout(m_pMemoryCnt); 67 QGridLayout *pMemoryCntLayout = new QGridLayout(m_pMemoryCnt); 68 { 46 69 m_pRamSlider = new VBoxGuestRAMSlider(m_pMemoryCnt); 70 { 47 71 m_pRamSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 48 72 m_pRamSlider->setOrientation(Qt::Horizontal); 49 73 m_pRamSlider->setTickPosition(QSlider::TicksBelow); 74 } 50 75 m_pRamEditor = new QILineEdit(m_pMemoryCnt); 76 { 51 77 m_pRamEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 52 78 m_pRamEditor->setFixedWidthByText("88888"); 53 79 m_pRamEditor->setAlignment(Qt::AlignRight); 54 80 m_pRamEditor->setValidator(new QIntValidator(m_pRamSlider->minRAM(), m_pRamSlider->maxRAM(), this)); 81 } 55 82 m_pRamUnits = new QLabel(m_pMemoryCnt); 83 { 56 84 m_pRamUnits->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 85 } 57 86 m_pRamMin = new QLabel(m_pMemoryCnt); 87 { 58 88 m_pRamMin->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 89 } 59 90 QSpacerItem *m_pRamSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding); 60 91 m_pRamMax = new QLabel(m_pMemoryCnt); 92 { 61 93 m_pRamMax->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 62 pMemoryLayout->addWidget(m_pRamSlider, 0, 0, 1, 3); 63 pMemoryLayout->addWidget(m_pRamEditor, 0, 3); 64 pMemoryLayout->addWidget(m_pRamUnits, 0, 4); 65 pMemoryLayout->addWidget(m_pRamMin, 1, 0); 66 pMemoryLayout->addItem(m_pRamSpacer, 1, 1); 67 pMemoryLayout->addWidget(m_pRamMax, 1, 2); 68 pMainLayout->addWidget(m_pLabel1); 69 pMainLayout->addWidget(m_pLabel2); 70 pMainLayout->addWidget(m_pMemoryCnt); 71 pMainLayout->addStretch(); 94 } 95 pMemoryCntLayout->addWidget(m_pRamSlider, 0, 0, 1, 3); 96 pMemoryCntLayout->addWidget(m_pRamEditor, 0, 3); 97 pMemoryCntLayout->addWidget(m_pRamUnits, 0, 4); 98 pMemoryCntLayout->addWidget(m_pRamMin, 1, 0); 99 pMemoryCntLayout->addItem(m_pRamSpacer, 1, 1); 100 pMemoryCntLayout->addWidget(m_pRamMax, 1, 2); 101 } 102 } 103 pMainLayout->addWidget(m_pLabel1); 104 pMainLayout->addWidget(m_pLabel2); 105 pMainLayout->addWidget(m_pMemoryCnt); 106 pMainLayout->addStretch(); 107 } 72 108 73 109 /* Setup connections: */ 74 connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT( ramSliderValueChanged(int)));75 connect(m_pRamEditor, SIGNAL(textChanged(const QString&)), this, SLOT( ramEditorTextChanged(const QString&)));110 connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(sltRamSliderValueChanged(int))); 111 connect(m_pRamEditor, SIGNAL(textChanged(const QString&)), this, SLOT(sltRamEditorTextChanged(const QString&))); 76 112 77 /* Initialize connections: */ 78 ramSliderValueChanged(m_pRamSlider->value()); 79 80 /* Register field: */ 81 registerField("ram*", m_pRamSlider, "value", SIGNAL(valueChanged(int))); 113 /* Register fields: */ 114 registerField("ram", m_pRamSlider, "value", SIGNAL(valueChanged(int))); 82 115 } 83 116 84 void UIWizardNewVMPageBasic3:: ramSliderValueChanged(int iValue)117 void UIWizardNewVMPageBasic3::sltRamSliderValueChanged(int iValue) 85 118 { 86 /* Update 'ram' field editor connected to slider: */ 87 m_pRamEditor->setText(QString::number(iValue)); 119 /* Call to base-class: */ 120 onRamSliderValueChanged(iValue); 121 122 /* Broadcast complete-change: */ 123 emit completeChanged(); 88 124 } 89 125 90 void UIWizardNewVMPageBasic3:: ramEditorTextChanged(const QString &strText)126 void UIWizardNewVMPageBasic3::sltRamEditorTextChanged(const QString &strText) 91 127 { 92 /* Update 'ram' field slider connected to editor: */ 93 m_pRamSlider->setValue(strText.toInt()); 128 /* Call to base-class: */ 129 onRamEditorTextChanged(strText); 130 131 /* Broadcast complete-change: */ 132 emit completeChanged(); 94 133 } 95 134 … … 117 156 /* Get recommended 'ram' field value: */ 118 157 CGuestOSType type = field("type").value<CGuestOSType>(); 119 ramSliderValueChanged(type.GetRecommendedRAM()); 158 m_pRamSlider->setValue(type.GetRecommendedRAM()); 159 m_pRamEditor->setText(QString::number(type.GetRecommendedRAM())); 120 160 121 161 /* 'Ram' field should have focus initially: */ … … 125 165 bool UIWizardNewVMPageBasic3::isComplete() const 126 166 { 127 /* Check what 'ram' field valuefeats the bounds: */167 /* Make sure 'ram' field feats the bounds: */ 128 168 return m_pRamSlider->value() >= qMax(1, (int)m_pRamSlider->minRAM()) && 129 169 m_pRamSlider->value() <= (int)m_pRamSlider->maxRAM(); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic3.h
r40870 r41021 24 24 25 25 /* Forward declarations: */ 26 class QIRichTextLabel;27 26 class QGroupBox; 28 27 class VBoxGuestRAMSlider; 29 28 class QILineEdit; 30 29 class QLabel; 30 class QIRichTextLabel; 31 31 32 /* 3rd page of the New Virtual Machine wizard: */ 33 class UIWizardNewVMPageBasic3 : public UIWizardPage 32 /* 3rd page of the New Virtual Machine wizard (base part): */ 33 class UIWizardNewVMPage3 : public UIWizardPageBase 34 { 35 protected: 36 37 /* Constructor: */ 38 UIWizardNewVMPage3(); 39 40 /* Handlers: */ 41 void onRamSliderValueChanged(int iValue); 42 void onRamEditorTextChanged(const QString &strText); 43 44 /* Widgets: */ 45 QGroupBox *m_pMemoryCnt; 46 VBoxGuestRAMSlider *m_pRamSlider; 47 QILineEdit *m_pRamEditor; 48 QLabel *m_pRamMin; 49 QLabel *m_pRamMax; 50 QLabel *m_pRamUnits; 51 }; 52 53 /* 3rd page of the New Virtual Machine wizard (basic extension): */ 54 class UIWizardNewVMPageBasic3 : public UIWizardPage, public UIWizardNewVMPage3 34 55 { 35 56 Q_OBJECT; … … 43 64 44 65 /* Handlers: */ 45 void ramSliderValueChanged(int iValue);46 void ramEditorTextChanged(const QString &strText);66 void sltRamSliderValueChanged(int iValue); 67 void sltRamEditorTextChanged(const QString &strText); 47 68 48 69 private: … … 60 81 QIRichTextLabel *m_pLabel1; 61 82 QIRichTextLabel *m_pLabel2; 62 QGroupBox *m_pMemoryCnt;63 VBoxGuestRAMSlider *m_pRamSlider;64 QILineEdit *m_pRamEditor;65 QLabel *m_pRamMin;66 QLabel *m_pRamMax;67 QLabel *m_pRamUnits;68 83 }; 69 84 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic4.cpp
r40870 r41021 28 28 #include "UIWizardNewVMPageBasic4.h" 29 29 #include "UIWizardNewVM.h" 30 #include "VBoxDefs.h" 31 #include "UIMessageCenter.h" 30 32 #include "UIIconPool.h" 31 #include "UIMessageCenter.h"32 #include "VBoxDefs.h"33 #include "QIRichTextLabel.h"34 33 #include "VBoxMediaComboBox.h" 35 34 #include "QIToolButton.h" 36 35 #include "UIWizardNewVD.h" 36 #include "QIRichTextLabel.h" 37 38 UIWizardNewVMPage4::UIWizardNewVMPage4() 39 { 40 } 41 42 void UIWizardNewVMPage4::updateVirtualDiskSource() 43 { 44 /* Enable/disable controls: */ 45 m_pDiskCreate->setEnabled(m_pDiskCnt->isChecked()); 46 m_pDiskPresent->setEnabled(m_pDiskCnt->isChecked()); 47 m_pDiskSelector->setEnabled(m_pDiskPresent->isEnabled() && m_pDiskPresent->isChecked()); 48 m_pVMMButton->setEnabled(m_pDiskPresent->isEnabled() && m_pDiskPresent->isChecked()); 49 50 /* Fetch filed values: */ 51 if (m_pDiskCnt->isChecked() && m_pDiskPresent->isChecked()) 52 { 53 m_strVirtualDiskId = m_pDiskSelector->id(); 54 m_strVirtualDiskName = m_pDiskSelector->currentText(); 55 m_strVirtualDiskLocation = m_pDiskSelector->location(); 56 } 57 else 58 { 59 m_strVirtualDiskId = QString(); 60 m_strVirtualDiskName = QString(); 61 m_strVirtualDiskLocation = QString(); 62 } 63 } 64 65 void UIWizardNewVMPage4::getWithFileOpenDialog() 66 { 67 /* Get opened medium id: */ 68 QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(VBoxDefs::MediumType_HardDisk, thisImp()); 69 if (!strMediumId.isNull()) 70 { 71 /* Update medium-combo if necessary: */ 72 m_pDiskSelector->setCurrentItem(strMediumId); 73 /* Update hard disk source: */ 74 updateVirtualDiskSource(); 75 /* Focus on hard disk combo: */ 76 m_pDiskSelector->setFocus(); 77 } 78 } 79 80 bool UIWizardNewVMPage4::getWithNewVirtualDiskWizard() 81 { 82 /* Create New Virtual Disk wizard: */ 83 UIWizardNewVD dlg(thisImp(), 84 fieldImp("machineBaseName").toString(), 85 fieldImp("machineFolder").toString(), 86 fieldImp("type").value<CGuestOSType>().GetRecommendedHDD()); 87 if (dlg.exec() == QDialog::Accepted) 88 { 89 m_virtualDisk = dlg.virtualDisk(); 90 m_pDiskSelector->setCurrentItem(m_virtualDisk.GetId()); 91 m_pDiskPresent->click(); 92 return true; 93 } 94 return false; 95 } 96 97 void UIWizardNewVMPage4::ensureNewVirtualDiskDeleted() 98 { 99 /* Make sure virtual-disk exists: */ 100 if (m_virtualDisk.isNull()) 101 return; 102 103 /* Remember virtual-disk ID: */ 104 QString strId = m_virtualDisk.GetId(); 105 106 /* 1st step: start delete-storage progress: */ 107 CProgress progress = m_virtualDisk.DeleteStorage(); 108 /* Get initial state: */ 109 bool fSuccess = m_virtualDisk.isOk(); 110 111 /* 2nd step: show delete-storage progress: */ 112 if (fSuccess) 113 { 114 msgCenter().showModalProgressDialog(progress, thisImp()->windowTitle(), ":/progress_media_delete_90px.png", thisImp(), true); 115 fSuccess = progress.isOk() && progress.GetResultCode() == S_OK; 116 } 117 118 /* 3rd step: notify GUI about virtual-disk was deleted or show error if any: */ 119 if (fSuccess) 120 vboxGlobal().removeMedium(VBoxDefs::MediumType_HardDisk, strId); 121 else 122 msgCenter().cannotDeleteHardDiskStorage(thisImp(), m_virtualDisk, progress); 123 124 /* Detach virtual-disk finally: */ 125 m_virtualDisk.detach(); 126 } 37 127 38 128 UIWizardNewVMPageBasic4::UIWizardNewVMPageBasic4() … … 40 130 /* Create widgets: */ 41 131 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 132 { 42 133 m_pLabel1 = new QIRichTextLabel(this); 43 134 m_pLabel2 = new QIRichTextLabel(this); 44 m_pBootHDCnt = new QGroupBox(this); 45 m_pBootHDCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 46 m_pBootHDCnt->setCheckable(true); 47 QGridLayout *pDiskLayout = new QGridLayout(m_pBootHDCnt); 48 m_pDiskCreate = new QRadioButton(m_pBootHDCnt); 49 m_pDiskPresent = new QRadioButton(m_pBootHDCnt); 135 m_pDiskCnt = new QGroupBox(this); 136 { 137 m_pDiskCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 138 m_pDiskCnt->setCheckable(true); 139 QGridLayout *pDiskLayout = new QGridLayout(m_pDiskCnt); 140 { 141 m_pDiskCreate = new QRadioButton(m_pDiskCnt); 142 m_pDiskPresent = new QRadioButton(m_pDiskCnt); 50 143 QStyleOptionButton options; 51 144 options.initFrom(m_pDiskCreate); 52 int wid = m_pDiskCreate->style()->subElementRect(QStyle::SE_RadioButtonIndicator, &options, m_pDiskCreate).width() + 53 m_pDiskCreate->style()->pixelMetric(QStyle::PM_RadioButtonLabelSpacing, &options, m_pDiskCreate) - 54 pDiskLayout->spacing() - 1; 55 QSpacerItem *pSpacer = new QSpacerItem(wid, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); 56 m_pDiskSelector = new VBoxMediaComboBox(m_pBootHDCnt); 145 int iWidth = m_pDiskCreate->style()->subElementRect(QStyle::SE_RadioButtonIndicator, &options, m_pDiskCreate).width() + 146 m_pDiskCreate->style()->pixelMetric(QStyle::PM_RadioButtonLabelSpacing, &options, m_pDiskCreate) - 147 pDiskLayout->spacing() - 1; 148 QSpacerItem *pSpacer = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); 149 m_pDiskSelector = new VBoxMediaComboBox(m_pDiskCnt); 150 { 57 151 m_pDiskSelector->setType(VBoxDefs::MediumType_HardDisk); 58 152 m_pDiskSelector->repopulate(); 59 m_pVMMButton = new QIToolButton(m_pBootHDCnt); 153 } 154 m_pVMMButton = new QIToolButton(m_pDiskCnt); 155 { 60 156 m_pVMMButton->setAutoRaise(true); 61 157 m_pVMMButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png")); 62 pDiskLayout->addWidget(m_pDiskCreate, 0, 0, 1, 3); 63 pDiskLayout->addWidget(m_pDiskPresent, 1, 0, 1, 3); 64 pDiskLayout->addItem(pSpacer, 2, 0); 65 pDiskLayout->addWidget(m_pDiskSelector, 2, 1); 66 pDiskLayout->addWidget(m_pVMMButton, 2, 2); 67 pMainLayout->addWidget(m_pLabel1); 68 pMainLayout->addWidget(m_pLabel2); 69 pMainLayout->addWidget(m_pBootHDCnt); 70 pMainLayout->addStretch(); 158 } 159 pDiskLayout->addWidget(m_pDiskCreate, 0, 0, 1, 3); 160 pDiskLayout->addWidget(m_pDiskPresent, 1, 0, 1, 3); 161 pDiskLayout->addItem(pSpacer, 2, 0); 162 pDiskLayout->addWidget(m_pDiskSelector, 2, 1); 163 pDiskLayout->addWidget(m_pVMMButton, 2, 2); 164 } 165 } 166 pMainLayout->addWidget(m_pLabel1); 167 pMainLayout->addWidget(m_pLabel2); 168 pMainLayout->addWidget(m_pDiskCnt); 169 pMainLayout->addStretch(); 170 updateVirtualDiskSource(); 171 } 71 172 72 173 /* Setup connections: */ 73 connect(m_pBootHDCnt, SIGNAL(toggled(bool)), this, SLOT(virtualDiskSourceChanged())); 74 connect(m_pDiskCreate, SIGNAL(toggled(bool)), this, SLOT(virtualDiskSourceChanged())); 75 connect(m_pDiskPresent, SIGNAL(toggled(bool)), this, SLOT(virtualDiskSourceChanged())); 76 connect(m_pDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualDiskSourceChanged())); 77 connect(m_pVMMButton, SIGNAL(clicked()), this, SLOT(getWithFileOpenDialog())); 78 79 /* Initialise connections: */ 80 virtualDiskSourceChanged(); 81 82 /* Register CMedium class: */ 174 connect(m_pDiskCnt, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged())); 175 connect(m_pDiskCreate, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged())); 176 connect(m_pDiskPresent, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged())); 177 connect(m_pDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(sltVirtualDiskSourceChanged())); 178 connect(m_pVMMButton, SIGNAL(clicked()), this, SLOT(sltGetWithFileOpenDialog())); 179 180 /* Register classes: */ 83 181 qRegisterMetaType<CMedium>(); 84 182 /* Register fields: */ … … 89 187 } 90 188 91 void UIWizardNewVMPageBasic4::ensureNewVirtualDiskDeleted() 92 { 93 if (m_virtualDisk.isNull()) 94 return; 95 96 QString strId = m_virtualDisk.GetId(); 97 98 bool fSuccess = false; 99 100 CProgress progress = m_virtualDisk.DeleteStorage(); 101 if (m_virtualDisk.isOk()) 102 { 103 msgCenter().showModalProgressDialog(progress, windowTitle(), ":/progress_media_delete_90px.png", this, true); 104 if (progress.isOk() && progress.GetResultCode() == S_OK) 105 fSuccess = true; 106 } 107 108 if (fSuccess) 109 vboxGlobal().removeMedium(VBoxDefs::MediumType_HardDisk, strId); 110 else 111 msgCenter().cannotDeleteHardDiskStorage(this, m_virtualDisk, progress); 112 113 m_virtualDisk.detach(); 114 } 115 116 void UIWizardNewVMPageBasic4::virtualDiskSourceChanged() 117 { 118 m_pDiskCreate->setEnabled(m_pBootHDCnt->isChecked()); 119 m_pDiskPresent->setEnabled(m_pBootHDCnt->isChecked()); 120 m_pDiskSelector->setEnabled(m_pDiskPresent->isEnabled() && m_pDiskPresent->isChecked()); 121 m_pVMMButton->setEnabled(m_pDiskPresent->isEnabled() && m_pDiskPresent->isChecked()); 122 123 if (m_pBootHDCnt->isChecked() && m_pDiskPresent->isChecked()) 124 { 125 m_strVirtualDiskId = m_pDiskSelector->id(); 126 m_strVirtualDiskName = m_pDiskSelector->currentText(); 127 m_strVirtualDiskLocation = m_pDiskSelector->location(); 128 } 129 else 130 { 131 m_strVirtualDiskId.clear(); 132 m_strVirtualDiskName.clear(); 133 m_strVirtualDiskLocation.clear(); 134 } 135 189 void UIWizardNewVMPageBasic4::sltVirtualDiskSourceChanged() 190 { 191 /* Call to base-class: */ 192 updateVirtualDiskSource(); 193 194 /* Broadcast complete-change: */ 136 195 emit completeChanged(); 137 196 } 138 197 139 void UIWizardNewVMPageBasic4::getWithFileOpenDialog() 140 { 141 /* Get opened vboxMedium id: */ 142 QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(VBoxDefs::MediumType_HardDisk, this); 143 if (!strMediumId.isNull()) 144 { 145 /* Update medium-combo if necessary: */ 146 m_pDiskSelector->setCurrentItem(strMediumId); 147 /* Update hard disk source: */ 148 virtualDiskSourceChanged(); 149 /* Focus on hard disk combo: */ 150 m_pDiskSelector->setFocus(); 151 } 198 void UIWizardNewVMPageBasic4::sltGetWithFileOpenDialog() 199 { 200 /* Call to base-class: */ 201 getWithFileOpenDialog(); 152 202 } 153 203 … … 159 209 /* Translate widgets: */ 160 210 m_pLabel1->setText(UIWizardNewVM::tr("<p>If you wish you can now add a start-up disk to the new machine. " 161 "You can either create a new virtual disk or select one from the list "162 "or from another location using the folder icon.</p>"163 "<p>If you need a more complex virtual disk setup you can skip this step "164 "and make the changes to the machine settings once the machine is created.</p>"));211 "You can either create a new virtual disk or select one from the list " 212 "or from another location using the folder icon.</p>" 213 "<p>If you need a more complex virtual disk setup you can skip this step " 214 "and make the changes to the machine settings once the machine is created.</p>")); 165 215 QString strRecommendedHDD = field("type").value<CGuestOSType>().isNull() ? QString() : 166 216 VBoxGlobal::formatSize(field("type").value<CGuestOSType>().GetRecommendedHDD()); 167 217 m_pLabel2->setText(UIWizardNewVM::tr("The recommended size of the start-up disk is <b>%1</b>.").arg(strRecommendedHDD)); 168 m_p BootHDCnt->setTitle(UIWizardNewVM::tr("Start-up &Disk"));218 m_pDiskCnt->setTitle(UIWizardNewVM::tr("Start-up &Disk")); 169 219 m_pDiskCreate->setText(UIWizardNewVM::tr("&Create new hard disk")); 170 220 m_pDiskPresent->setText(UIWizardNewVM::tr("&Use existing hard disk")); … … 178 228 179 229 /* Prepare initial choice: */ 180 m_p BootHDCnt->setChecked(true);230 m_pDiskCnt->setChecked(true); 181 231 m_pDiskSelector->setCurrentIndex(0); 182 232 m_pDiskCreate->setChecked(true); … … 188 238 void UIWizardNewVMPageBasic4::cleanupPage() 189 239 { 190 /* C lean medium if present*/240 /* Call to base-class: */ 191 241 ensureNewVirtualDiskDeleted(); 192 /* Clean fields of that page */193 242 UIWizardPage::cleanupPage(); 194 243 } … … 196 245 bool UIWizardNewVMPageBasic4::isComplete() const 197 246 { 198 /* Check what virtualDiskfeats the rules: */199 return !m_p BootHDCnt->isChecked() ||247 /* Make sure 'virtualDisk' field feats the rules: */ 248 return !m_pDiskCnt->isChecked() || 200 249 !m_pDiskPresent->isChecked() || 201 250 !vboxGlobal().findMedium(m_pDiskSelector->id()).isNull(); … … 204 253 bool UIWizardNewVMPageBasic4::validatePage() 205 254 { 255 /* Initial result: */ 256 bool fResult = true; 257 206 258 /* Ensure unused virtual-disk is deleted: */ 207 if (!m_p BootHDCnt->isChecked() || m_pDiskCreate->isChecked() || (!m_virtualDisk.isNull() && m_strVirtualDiskId != m_virtualDisk.GetId()))259 if (!m_pDiskCnt->isChecked() || m_pDiskCreate->isChecked() || (!m_virtualDisk.isNull() && m_strVirtualDiskId != m_virtualDisk.GetId())) 208 260 ensureNewVirtualDiskDeleted(); 209 261 210 /* Ask user about disk-less machine: */ 211 if (!m_pBootHDCnt->isChecked() && !msgCenter().confirmHardDisklessMachine(this)) 212 return false; 213 214 /* Show the New Virtual Disk wizard: */ 215 if (m_pBootHDCnt->isChecked() && m_pDiskCreate->isChecked() && !getWithNewVirtualDiskWizard()) 216 return false; 217 218 return true; 219 } 220 221 bool UIWizardNewVMPageBasic4::getWithNewVirtualDiskWizard() 222 { 223 UIWizardNewVD dlg(this, field("machineBaseName").toString(), field("machineFolder").toString(), field("type").value<CGuestOSType>().GetRecommendedHDD()); 224 if (dlg.exec() == QDialog::Accepted) 225 { 226 m_virtualDisk = dlg.virtualDisk(); 227 m_pDiskSelector->setCurrentItem(m_virtualDisk.GetId()); 228 m_pDiskPresent->click(); 229 return true; 230 } 231 return false; 232 } 233 234 CMedium UIWizardNewVMPageBasic4::virtualDisk() const 235 { 236 return m_virtualDisk; 237 } 238 239 void UIWizardNewVMPageBasic4::setVirtualDisk(const CMedium &virtualDisk) 240 { 241 m_virtualDisk = virtualDisk; 242 } 243 244 QString UIWizardNewVMPageBasic4::virtualDiskId() const 245 { 246 return m_strVirtualDiskId; 247 } 248 249 void UIWizardNewVMPageBasic4::setVirtualDiskId(const QString &strVirtualDiskId) 250 { 251 m_strVirtualDiskId = strVirtualDiskId; 252 } 253 254 QString UIWizardNewVMPageBasic4::virtualDiskName() const 255 { 256 return m_strVirtualDiskName; 257 } 258 259 void UIWizardNewVMPageBasic4::setVirtualDiskName(const QString &strVirtualDiskName) 260 { 261 m_strVirtualDiskName = strVirtualDiskName; 262 } 263 264 QString UIWizardNewVMPageBasic4::virtualDiskLocation() const 265 { 266 return m_strVirtualDiskLocation; 267 } 268 269 void UIWizardNewVMPageBasic4::setVirtualDiskLocation(const QString &strVirtualDiskLocation) 270 { 271 m_strVirtualDiskLocation = strVirtualDiskLocation; 272 } 273 262 if (!m_pDiskCnt->isChecked()) 263 { 264 /* Ask user about disk-less machine: */ 265 fResult = msgCenter().confirmHardDisklessMachine(this); 266 } 267 else if (m_pDiskCreate->isChecked()) 268 { 269 /* Show the New Virtual Disk wizard: */ 270 fResult = getWithNewVirtualDiskWizard(); 271 } 272 273 /* Return result: */ 274 return fResult; 275 } 276 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic4.h
r40870 r41021 20 20 #define __UIWizardNewVMPageBasic4_h__ 21 21 22 /* Global includes: */ 23 #include <QVariant> 24 22 25 /* Local includes: */ 23 26 #include "UIWizardPage.h" … … 25 28 26 29 /* Forward declarations: */ 27 class QIRichTextLabel;28 30 class QGroupBox; 29 31 class QRadioButton; 30 32 class VBoxMediaComboBox; 31 33 class QIToolButton; 34 class QIRichTextLabel; 32 35 33 /* 4th page of the New Virtual Machine wizard: */ 34 class UIWizardNewVMPageBasic4 : public UIWizardPage 36 /* 4th page of the New Virtual Machine wizard (base part): */ 37 class UIWizardNewVMPage4 : public UIWizardPageBase 38 { 39 protected: 40 41 /* Constructor: */ 42 UIWizardNewVMPage4(); 43 44 /* Handlers: */ 45 void updateVirtualDiskSource(); 46 void getWithFileOpenDialog(); 47 bool getWithNewVirtualDiskWizard(); 48 49 /* Stuff for 'virtualDisk' field: */ 50 CMedium virtualDisk() const { return m_virtualDisk; } 51 void setVirtualDisk(const CMedium &virtualDisk) { m_virtualDisk = virtualDisk; } 52 53 /* Stuff for 'virtualDiskId' field: */ 54 QString virtualDiskId() const { return m_strVirtualDiskId; } 55 void setVirtualDiskId(const QString &strVirtualDiskId) { m_strVirtualDiskId = strVirtualDiskId; } 56 57 /* Stuff for 'virtualDiskName' field: */ 58 QString virtualDiskName() const { return m_strVirtualDiskName; } 59 void setVirtualDiskName(const QString &strVirtualDiskName) { m_strVirtualDiskName = strVirtualDiskName; } 60 61 /* Stuff for 'virtualDiskLocation' field: */ 62 QString virtualDiskLocation() const { return m_strVirtualDiskLocation; } 63 void setVirtualDiskLocation(const QString &strVirtualDiskLocation) { m_strVirtualDiskLocation = strVirtualDiskLocation; } 64 65 /* Helpers: */ 66 void ensureNewVirtualDiskDeleted(); 67 68 /* Variables: */ 69 CMedium m_virtualDisk; 70 QString m_strVirtualDiskId; 71 QString m_strVirtualDiskName; 72 QString m_strVirtualDiskLocation; 73 74 /* Widgets: */ 75 QGroupBox *m_pDiskCnt; 76 QRadioButton *m_pDiskCreate; 77 QRadioButton *m_pDiskPresent; 78 VBoxMediaComboBox *m_pDiskSelector; 79 QIToolButton *m_pVMMButton; 80 }; 81 82 /* 4th page of the New Virtual Machine wizard (basic extension): */ 83 class UIWizardNewVMPageBasic4 : public UIWizardPage, public UIWizardNewVMPage4 35 84 { 36 85 Q_OBJECT; … … 45 94 UIWizardNewVMPageBasic4(); 46 95 96 protected: 97 98 /* Wrapper to access 'this' from base part: */ 99 UIWizardPage* thisImp() { return this; } 100 /* Wrapper to access 'wizard-field' from base part: */ 101 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 102 47 103 private slots: 48 104 49 105 /* Handlers: */ 50 void ensureNewVirtualDiskDeleted(); 51 void virtualDiskSourceChanged(); 52 void getWithFileOpenDialog(); 106 void sltVirtualDiskSourceChanged(); 107 void sltGetWithFileOpenDialog(); 53 108 54 109 private: … … 65 120 bool validatePage(); 66 121 67 /* Helpers: */68 bool getWithNewVirtualDiskWizard();69 70 /* Stuff for 'virtualDisk' field: */71 CMedium virtualDisk() const;72 void setVirtualDisk(const CMedium &virtualDisk);73 CMedium m_virtualDisk;74 75 /* Stuff for 'virtualDiskId' field: */76 QString virtualDiskId() const;77 void setVirtualDiskId(const QString &strVirtualDiskId);78 QString m_strVirtualDiskId;79 80 /* Stuff for 'virtualDiskName' field: */81 QString virtualDiskName() const;82 void setVirtualDiskName(const QString &strVirtualDiskName);83 QString m_strVirtualDiskName;84 85 /* Stuff for 'virtualDiskLocation' field: */86 QString virtualDiskLocation() const;87 void setVirtualDiskLocation(const QString &strVirtualDiskLocation);88 QString m_strVirtualDiskLocation;89 90 122 /* Widgets: */ 91 123 QIRichTextLabel *m_pLabel1; 92 124 QIRichTextLabel *m_pLabel2; 93 QGroupBox *m_pBootHDCnt;94 QRadioButton *m_pDiskCreate;95 QRadioButton *m_pDiskPresent;96 VBoxMediaComboBox *m_pDiskSelector;97 QIToolButton *m_pVMMButton;98 125 }; 99 126 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic5.cpp
r40870 r41021 27 27 #include "QIRichTextLabel.h" 28 28 29 UIWizardNewVMPage5::UIWizardNewVMPage5() 30 { 31 } 32 29 33 UIWizardNewVMPageBasic5::UIWizardNewVMPageBasic5() 30 34 { 31 35 /* Create widget: */ 32 36 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 33 m_pPage5Text1 = new QIRichTextLabel(this); 34 m_pSummaryText = new QIRichTextLabel(this); 35 m_pPage5Text2 = new QIRichTextLabel(this); 36 pMainLayout->addWidget(m_pPage5Text1); 37 pMainLayout->addWidget(m_pSummaryText); 38 pMainLayout->addWidget(m_pPage5Text2); 39 pMainLayout->addStretch(); 37 { 38 m_pLabel1 = new QIRichTextLabel(this); 39 m_pSummary = new QIRichTextLabel(this); 40 m_pLabel2 = new QIRichTextLabel(this); 41 pMainLayout->addWidget(m_pLabel1); 42 pMainLayout->addWidget(m_pSummary); 43 pMainLayout->addWidget(m_pLabel2); 44 pMainLayout->addStretch(); 45 } 40 46 } 41 47 … … 46 52 47 53 /* Translate widgets: */ 48 m_p Page5Text1->setText(UIWizardNewVM::tr("<p>You are going to create a new virtual machine with the following parameters:</p>"));49 m_p Page5Text2->setText(UIWizardNewVM::tr("<p>If the above is correct press the <b>%1</b> button. Once "50 "you press it, a new virtual machine will be created. </p><p>Note "51 "that you can alter these and all other setting of the created "52 "virtual machine at any time using the <b>Settings</b> dialog "53 "accessible through the menu of the main window.</p>")54 .arg(VBoxGlobal::replaceHtmlEntities(VBoxGlobal::removeAccelMark(wizard()->buttonText(QWizard::FinishButton)))));54 m_pLabel1->setText(UIWizardNewVM::tr("<p>You are going to create a new virtual machine with the following parameters:</p>")); 55 m_pLabel2->setText(UIWizardNewVM::tr("<p>If the above is correct press the <b>%1</b> button. Once " 56 "you press it, a new virtual machine will be created. </p><p>Note " 57 "that you can alter these and all other setting of the created " 58 "virtual machine at any time using the <b>Settings</b> dialog " 59 "accessible through the menu of the main window.</p>") 60 .arg(VBoxGlobal::replaceHtmlEntities(VBoxGlobal::removeAccelMark(wizard()->buttonText(QWizard::FinishButton))))); 55 61 56 62 /* Compose common summary: */ … … 74 80 .arg(UIWizardNewVM::tr("Start-up Disk", "summary"), field("virtualDiskName").toString()); 75 81 } 76 m_pSummary Text->setText("<table cellspacing=0 cellpadding=0>" + strSummary + "</table>");82 m_pSummary->setText("<table cellspacing=0 cellpadding=0>" + strSummary + "</table>"); 77 83 } 78 84 … … 83 89 84 90 /* Summary should have focus initially: */ 85 m_pSummary Text->setFocus();91 m_pSummary->setFocus(); 86 92 } 87 93 88 94 bool UIWizardNewVMPageBasic5::validatePage() 89 95 { 96 /* Initial result: */ 97 bool fResult = true; 98 99 /* Lock finish button: */ 100 startProcessing(); 101 90 102 /* Try to create VM: */ 91 startProcessing(); 92 bool fResult = qobject_cast<UIWizardNewVM*>(wizard())->createVM(); 103 if (fResult) 104 fResult = qobject_cast<UIWizardNewVM*>(wizard())->createVM(); 105 106 /* Unlock finish button: */ 93 107 endProcessing(); 108 109 /* Return result: */ 94 110 return fResult; 95 111 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic5.h
r40870 r41021 26 26 class QIRichTextLabel; 27 27 28 /* 5th page of the New Virtual Machine wizard: */ 29 class UIWizardNewVMPageBasic5 : public UIWizardPage 28 /* 5th page of the New Virtual Machine wizard (base part): */ 29 class UIWizardNewVMPage5 : public UIWizardPageBase 30 { 31 protected: 32 33 /* Constructor: */ 34 UIWizardNewVMPage5(); 35 }; 36 37 /* 5th page of the New Virtual Machine wizard (basic extension): */ 38 class UIWizardNewVMPageBasic5 : public UIWizardPage, public UIWizardNewVMPage5 30 39 { 31 40 Q_OBJECT; … … 36 45 UIWizardNewVMPageBasic5(); 37 46 38 pr otected:47 private: 39 48 40 49 /* Translate stuff: */ … … 47 56 bool validatePage(); 48 57 49 private:50 51 58 /* Widgets: */ 52 QIRichTextLabel *m_p Page5Text1;53 QIRichTextLabel *m_pSummary Text;54 QIRichTextLabel *m_p Page5Text2;59 QIRichTextLabel *m_pLabel1; 60 QIRichTextLabel *m_pSummary; 61 QIRichTextLabel *m_pLabel2; 55 62 }; 56 63 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp
r40929 r41021 3 3 * 4 4 * VBox frontends: Qt4 GUI ("VirtualBox"): 5 * UIWizardNewVMPage Basic1class implementation5 * UIWizardNewVMPageExpert class implementation 6 6 */ 7 7 … … 20 20 /* Global includes: */ 21 21 #include <QVBoxLayout> 22 #include <QHBoxLayout> 23 #include <QGroupBox> 24 #include <QGridLayout> 25 #include <QSpacerItem> 26 #include <QLineEdit> 27 #include <QLabel> 28 #include <QRadioButton> 22 29 23 30 /* Local includes: */ 24 #include "UIWizardNewVMPage Basic1.h"31 #include "UIWizardNewVMPageExpert.h" 25 32 #include "UIWizardNewVM.h" 26 33 #include "UIIconPool.h" 27 #include "QIRichTextLabel.h" 28 29 UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1() 34 #include "UIMessageCenter.h" 35 #include "VBoxOSTypeSelectorWidget.h" 36 #include "VBoxGuestRAMSlider.h" 37 #include "VBoxMediaComboBox.h" 38 #include "QILineEdit.h" 39 #include "QIToolButton.h" 40 41 UIWizardNewVMPageExpert::UIWizardNewVMPageExpert() 30 42 { 31 43 /* Create widgets: */ 32 44 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 33 m_pLabel1 = new QIRichTextLabel(this); 34 /* Register 'message-box warning-icon' image in m_pLabel1 as 'image': */ 35 QSize wSize(64, 64); 36 QPixmap wPixmap = UIIconPool::defaultIcon(UIIconPool::MessageBoxWarningIcon).pixmap(wSize); 37 if (wPixmap.width() != wSize.width()) 38 wPixmap = wPixmap.scaled(wSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); 39 QImage wImage = wPixmap.toImage(); 40 m_pLabel1->registerImage(wImage, "image"); 41 m_pLabel2 = new QIRichTextLabel(this); 42 pMainLayout->addWidget(m_pLabel1); 43 pMainLayout->addWidget(m_pLabel2); 44 pMainLayout->addStretch(); 45 } 46 47 void UIWizardNewVMPageBasic1::retranslateUi() 48 { 49 /* Translate page: */ 50 setTitle(UIWizardNewVM::tr("Welcome to the New Virtual Machine Wizard!")); 51 45 { 46 pMainLayout->setContentsMargins(8, 6, 8, 6); 47 m_pNameCnt = new QGroupBox(this); 48 { 49 m_pNameCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 50 QHBoxLayout *pNameCntLayout = new QHBoxLayout(m_pNameCnt); 51 { 52 m_pNameEditor = new QLineEdit(m_pNameCnt); 53 pNameCntLayout->addWidget(m_pNameEditor); 54 } 55 } 56 m_pTypeCnt = new QGroupBox(this); 57 { 58 m_pTypeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 59 QHBoxLayout *pTypeCntLayout = new QHBoxLayout(m_pTypeCnt); 60 { 61 m_pTypeSelector = new VBoxOSTypeSelectorWidget(m_pTypeCnt); 62 { 63 m_pTypeSelector->activateLayout(); 64 } 65 pTypeCntLayout->addWidget(m_pTypeSelector); 66 } 67 } 68 m_pMemoryCnt = new QGroupBox(this); 69 { 70 m_pMemoryCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 71 QGridLayout *pMemoryCntLayout = new QGridLayout(m_pMemoryCnt); 72 { 73 m_pRamSlider = new VBoxGuestRAMSlider(m_pMemoryCnt); 74 { 75 m_pRamSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 76 m_pRamSlider->setOrientation(Qt::Horizontal); 77 m_pRamSlider->setTickPosition(QSlider::TicksBelow); 78 m_pRamSlider->setValue(m_pTypeSelector->type().GetRecommendedRAM()); 79 } 80 m_pRamEditor = new QILineEdit(m_pMemoryCnt); 81 { 82 m_pRamEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 83 m_pRamEditor->setFixedWidthByText("88888"); 84 m_pRamEditor->setAlignment(Qt::AlignRight); 85 m_pRamEditor->setValidator(new QIntValidator(m_pRamSlider->minRAM(), m_pRamSlider->maxRAM(), this)); 86 m_pRamEditor->setText(QString::number(m_pTypeSelector->type().GetRecommendedRAM())); 87 } 88 m_pRamUnits = new QLabel(m_pMemoryCnt); 89 { 90 m_pRamUnits->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 91 } 92 m_pRamMin = new QLabel(m_pMemoryCnt); 93 { 94 m_pRamMin->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 95 } 96 QSpacerItem *m_pRamSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding); 97 m_pRamMax = new QLabel(m_pMemoryCnt); 98 { 99 m_pRamMax->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 100 } 101 pMemoryCntLayout->addWidget(m_pRamSlider, 0, 0, 1, 3); 102 pMemoryCntLayout->addWidget(m_pRamEditor, 0, 3); 103 pMemoryCntLayout->addWidget(m_pRamUnits, 0, 4); 104 pMemoryCntLayout->addWidget(m_pRamMin, 1, 0); 105 pMemoryCntLayout->addItem(m_pRamSpacer, 1, 1); 106 pMemoryCntLayout->addWidget(m_pRamMax, 1, 2); 107 } 108 } 109 m_pDiskCnt = new QGroupBox(this); 110 { 111 m_pDiskCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 112 m_pDiskCnt->setCheckable(true); 113 m_pDiskCnt->setChecked(true); 114 QGridLayout *pDiskCntLayout = new QGridLayout(m_pDiskCnt); 115 { 116 m_pDiskCreate = new QRadioButton(m_pDiskCnt); 117 { 118 m_pDiskCreate->setChecked(true); 119 } 120 m_pDiskPresent = new QRadioButton(m_pDiskCnt); 121 QStyleOptionButton options; 122 options.initFrom(m_pDiskCreate); 123 int iWidth = m_pDiskCreate->style()->subElementRect(QStyle::SE_RadioButtonIndicator, &options, m_pDiskCreate).width() + 124 m_pDiskCreate->style()->pixelMetric(QStyle::PM_RadioButtonLabelSpacing, &options, m_pDiskCreate) - 125 pDiskCntLayout->spacing() - 1; 126 QSpacerItem *pSpacer = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); 127 m_pDiskSelector = new VBoxMediaComboBox(m_pDiskCnt); 128 { 129 m_pDiskSelector->setType(VBoxDefs::MediumType_HardDisk); 130 m_pDiskSelector->repopulate(); 131 } 132 m_pVMMButton = new QIToolButton(m_pDiskCnt); 133 { 134 m_pVMMButton->setAutoRaise(true); 135 m_pVMMButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png")); 136 } 137 pDiskCntLayout->addWidget(m_pDiskCreate, 0, 0, 1, 3); 138 pDiskCntLayout->addWidget(m_pDiskPresent, 1, 0, 1, 3); 139 pDiskCntLayout->addItem(pSpacer, 2, 0); 140 pDiskCntLayout->addWidget(m_pDiskSelector, 2, 1); 141 pDiskCntLayout->addWidget(m_pVMMButton, 2, 2); 142 } 143 } 144 pMainLayout->addWidget(m_pNameCnt); 145 pMainLayout->addWidget(m_pTypeCnt); 146 pMainLayout->addWidget(m_pMemoryCnt); 147 pMainLayout->addWidget(m_pDiskCnt); 148 pMainLayout->addStretch(); 149 updateVirtualDiskSource(); 150 } 151 152 /* Setup connections: */ 153 connect(m_pNameEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltNameChanged(const QString &))); 154 connect(m_pTypeSelector, SIGNAL(osTypeChanged()), this, SLOT(sltOsTypeChanged())); 155 connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(sltRamSliderValueChanged(int))); 156 connect(m_pRamEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltRamEditorTextChanged(const QString &))); 157 connect(m_pDiskCnt, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged())); 158 connect(m_pDiskCreate, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged())); 159 connect(m_pDiskPresent, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged())); 160 connect(m_pDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(sltVirtualDiskSourceChanged())); 161 connect(m_pVMMButton, SIGNAL(clicked()), this, SLOT(sltGetWithFileOpenDialog())); 162 163 /* Register classes: */ 164 qRegisterMetaType<CMedium>(); 165 /* Register fields: */ 166 registerField("name*", m_pNameEditor); 167 registerField("type", m_pTypeSelector, "type", SIGNAL(osTypeChanged())); 168 registerField("machineFolder", this, "machineFolder"); 169 registerField("machineBaseName", this, "machineBaseName"); 170 registerField("ram", m_pRamSlider, "value", SIGNAL(valueChanged(int))); 171 registerField("virtualDisk", this, "virtualDisk"); 172 registerField("virtualDiskId", this, "virtualDiskId"); 173 registerField("virtualDiskLocation", this, "virtualDiskLocation"); 174 } 175 176 void UIWizardNewVMPageExpert::sltNameChanged(const QString &strNewText) 177 { 178 /* Call to base-class: */ 179 onNameChanged(strNewText); 180 181 /* Fetch recommended RAM value: */ 182 CGuestOSType type = m_pTypeSelector->type(); 183 m_pRamSlider->setValue(type.GetRecommendedRAM()); 184 m_pRamEditor->setText(QString::number(type.GetRecommendedRAM())); 185 186 /* Broadcast complete-change: */ 187 emit completeChanged(); 188 } 189 190 void UIWizardNewVMPageExpert::sltOsTypeChanged() 191 { 192 /* Call to base-class: */ 193 onOsTypeChanged(); 194 195 /* Fetch recommended RAM value: */ 196 CGuestOSType type = m_pTypeSelector->type(); 197 m_pRamSlider->setValue(type.GetRecommendedRAM()); 198 m_pRamEditor->setText(QString::number(type.GetRecommendedRAM())); 199 200 /* Broadcast complete-change: */ 201 emit completeChanged(); 202 } 203 204 void UIWizardNewVMPageExpert::sltRamSliderValueChanged(int iValue) 205 { 206 /* Call to base-class: */ 207 onRamSliderValueChanged(iValue); 208 209 /* Broadcast complete-change: */ 210 emit completeChanged(); 211 } 212 213 void UIWizardNewVMPageExpert::sltRamEditorTextChanged(const QString &strText) 214 { 215 /* Call to base-class: */ 216 onRamEditorTextChanged(strText); 217 218 /* Broadcast complete-change: */ 219 emit completeChanged(); 220 } 221 222 void UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged() 223 { 224 /* Call to base-class: */ 225 updateVirtualDiskSource(); 226 227 /* Broadcast complete-change: */ 228 emit completeChanged(); 229 } 230 231 void UIWizardNewVMPageExpert::sltGetWithFileOpenDialog() 232 { 233 /* Call to base-class: */ 234 getWithFileOpenDialog(); 235 } 236 237 void UIWizardNewVMPageExpert::retranslateUi() 238 { 52 239 /* Translate widgets: */ 53 m_pLabel1->setText(tableTemplate().arg("<b>STOP!</b> Before continuing, please understand what you are doing. " 54 "Computer system virtualization involves complex concepts, " 55 "which no user interface can hide. Please make sure that you have read " 56 "the first section of the user manual before continuing " 57 "or seeking out online assistance!")); 58 m_pLabel2->setText(UIWizardNewVM::tr("<p>This wizard will guide you through the steps that are necessary " 59 "to create a new virtual machine for VirtualBox.</p><p>%1</p>").arg(standardHelpText())); 60 } 61 62 void UIWizardNewVMPageBasic1::initializePage() 240 m_pNameCnt->setTitle(UIWizardNewVM::tr("&Name")); 241 m_pTypeCnt->setTitle(UIWizardNewVM::tr("OS &Type")); 242 m_pMemoryCnt->setTitle(UIWizardNewVM::tr("Base &Memory Size")); 243 m_pRamUnits->setText(VBoxGlobal::tr("MB", "size suffix MBytes=1024 KBytes")); 244 m_pRamMin->setText(QString("%1 %2").arg(m_pRamSlider->minRAM()).arg(VBoxGlobal::tr("MB", "size suffix MBytes=1024 KBytes"))); 245 m_pRamMax->setText(QString("%1 %2").arg(m_pRamSlider->maxRAM()).arg(VBoxGlobal::tr("MB", "size suffix MBytes=1024 KBytes"))); 246 m_pDiskCnt->setTitle(UIWizardNewVM::tr("Start-up &Disk")); 247 m_pDiskCreate->setText(UIWizardNewVM::tr("&Create new hard disk")); 248 m_pDiskPresent->setText(UIWizardNewVM::tr("&Use existing hard disk")); 249 m_pVMMButton->setToolTip(UIWizardNewVM::tr("Choose a virtual hard disk file...")); 250 } 251 252 void UIWizardNewVMPageExpert::initializePage() 63 253 { 64 254 /* Translate page: */ 65 255 retranslateUi(); 66 } 67 68 /* static */ 69 QString UIWizardNewVMPageBasic1::tableTemplate() 70 { 71 /* Prepare table template: */ 72 QString strTable("<table cellspacing=0 cellpadding=0>%1</table>"); 73 QString strTableRow("<tr>%1</tr>"); 74 QString strTableData("<td>%1</td>"); 75 QString strTableDataCentered("<td valign=middle>%1</td>"); 76 QString strImage("<img src=\"image\"/>"); 77 QString strSpacing(" "); 78 QString strTableDataImage(strTableDataCentered.arg(strImage)); 79 QString strTableDataSpacing(strTableData.arg(strSpacing)); 80 return strTable.arg(strTableRow.arg(strTableDataImage + strTableDataSpacing + strTableData)); 81 } 82 256 257 /* 'Name' field should have focus initially: */ 258 m_pNameEditor->setFocus(); 259 } 260 261 void UIWizardNewVMPageExpert::cleanupPage() 262 { 263 /* Call to base-class: */ 264 ensureNewVirtualDiskDeleted(); 265 cleanupMachineFolder(); 266 } 267 268 bool UIWizardNewVMPageExpert::isComplete() const 269 { 270 /* Make sure mandatory fields are complete, 271 * 'ram' field feats the bounds, 272 * 'virtualDisk' field feats the rules: */ 273 return UIWizardPage::isComplete() && 274 (m_pRamSlider->value() >= qMax(1, (int)m_pRamSlider->minRAM()) && m_pRamSlider->value() <= (int)m_pRamSlider->maxRAM()) && 275 (!m_pDiskCnt->isChecked() || !m_pDiskPresent->isChecked() || !vboxGlobal().findMedium(m_pDiskSelector->id()).isNull()); 276 } 277 278 bool UIWizardNewVMPageExpert::validatePage() 279 { 280 /* Initial result: */ 281 bool fResult = true; 282 283 /* Lock finish button: */ 284 startProcessing(); 285 286 /* Try to create machine folder: */ 287 if (fResult) 288 fResult = createMachineFolder(); 289 290 /* Try to assign boot virtual-disk: */ 291 if (fResult) 292 { 293 /* Ensure there is no virtual-disk created yet: */ 294 Assert(m_virtualDisk.isNull()); 295 if (fResult) 296 { 297 if (!m_pDiskCnt->isChecked()) 298 { 299 /* Ask user about disk-less machine: */ 300 fResult = msgCenter().confirmHardDisklessMachine(this); 301 } 302 else if (m_pDiskCreate->isChecked()) 303 { 304 /* Show the New Virtual Disk wizard if necessary: */ 305 fResult = getWithNewVirtualDiskWizard(); 306 } 307 } 308 } 309 310 /* Try to create VM: */ 311 if (fResult) 312 fResult = qobject_cast<UIWizardNewVM*>(wizard())->createVM(); 313 314 /* Unlock finish button: */ 315 endProcessing(); 316 317 /* Return result: */ 318 return fResult; 319 } 320 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h
r40929 r41021 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * UIWizardNewVMPage Basic1class declaration4 * UIWizardNewVMPageExpert class declaration 5 5 */ 6 6 … … 17 17 */ 18 18 19 #ifndef __UIWizardNewVMPage Basic1_h__20 #define __UIWizardNewVMPage Basic1_h__19 #ifndef __UIWizardNewVMPageExpert_h__ 20 #define __UIWizardNewVMPageExpert_h__ 21 21 22 22 /* Local includes: */ 23 #include "UIWizardPage.h" 24 #include "COMDefs.h" 25 #include "QIWithRetranslateUI.h" 23 #include "UIWizardNewVMPageBasic1.h" 24 #include "UIWizardNewVMPageBasic2.h" 25 #include "UIWizardNewVMPageBasic3.h" 26 #include "UIWizardNewVMPageBasic4.h" 27 #include "UIWizardNewVMPageBasic5.h" 26 28 27 /* Forward declarations: */ 28 class QIRichTextLabel; 29 30 /* 1st page of the New Virtual Machine wizard: */ 31 class UIWizardNewVMPageBasic1 : public UIWizardPage 29 /* Expert page of the New Virtual Machine wizard: */ 30 class UIWizardNewVMPageExpert : public UIWizardPage, 31 public UIWizardNewVMPage1, 32 public UIWizardNewVMPage2, 33 public UIWizardNewVMPage3, 34 public UIWizardNewVMPage4, 35 public UIWizardNewVMPage5 32 36 { 33 37 Q_OBJECT; 38 Q_PROPERTY(QString machineFolder READ machineFolder WRITE setMachineFolder); 39 Q_PROPERTY(QString machineBaseName READ machineBaseName WRITE setMachineBaseName); 40 Q_PROPERTY(CMedium virtualDisk READ virtualDisk WRITE setVirtualDisk); 41 Q_PROPERTY(QString virtualDiskId READ virtualDiskId WRITE setVirtualDiskId); 42 Q_PROPERTY(QString virtualDiskLocation READ virtualDiskLocation WRITE setVirtualDiskLocation); 34 43 35 44 public: 36 45 37 46 /* Constructor: */ 38 UIWizardNewVMPageBasic1(); 47 UIWizardNewVMPageExpert(); 48 49 protected: 50 51 /* Wrapper to access 'this' from base part: */ 52 UIWizardPage* thisImp() { return this; } 53 /* Wrapper to access 'wizard-field' from base part: */ 54 QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); } 55 56 private slots: 57 58 /* Handlers: */ 59 void sltNameChanged(const QString &strNewText); 60 void sltOsTypeChanged(); 61 void sltRamSliderValueChanged(int iValue); 62 void sltRamEditorTextChanged(const QString &strText); 63 void sltVirtualDiskSourceChanged(); 64 void sltGetWithFileOpenDialog(); 39 65 40 66 private: … … 45 71 /* Prepare stuff: */ 46 72 void initializePage(); 73 void cleanupPage(); 47 74 48 /* Helpers: */ 49 static QString tableTemplate(); 50 51 /* Widgets: */ 52 QIRichTextLabel *m_pLabel1; 53 QIRichTextLabel *m_pLabel2; 75 /* Validation stuff: */ 76 bool isComplete() const; 77 bool validatePage(); 54 78 }; 55 79 56 #endif // __UIWizardNewVMPage Basic1_h__80 #endif // __UIWizardNewVMPageExpert_h__ 57 81
Note:
See TracChangeset
for help on using the changeset viewer.

