Changeset 37406 in vbox
- Timestamp:
- Jun 10, 2011 1:04:03 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 72203
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r37374 r37406 289 289 mNewAction = new QAction (this); 290 290 mAddAction = new QAction (this); 291 mCopyAction = new QAction (this); 291 292 mRemoveAction = new QAction (this); 292 293 mReleaseAction = new QAction (this); … … 295 296 connect (mNewAction, SIGNAL (triggered()), this, SLOT (doNewMedium())); 296 297 connect (mAddAction, SIGNAL (triggered()), this, SLOT (doAddMedium())); 298 connect (mCopyAction, SIGNAL (triggered()), this, SLOT (doCopyMedium())); 297 299 connect (mRemoveAction, SIGNAL (triggered()), this, SLOT (doRemoveMedium())); 298 300 connect (mReleaseAction, SIGNAL (triggered()), this, SLOT (doReleaseMedium())); … … 307 309 ":/hd_add_22px.png", ":/hd_add_16px.png", 308 310 ":/hd_add_disabled_22px.png", ":/hd_add_disabled_16px.png")); 311 mCopyAction->setIcon(UIIconPool::iconSetFull ( 312 QSize (22, 22), QSize (16, 16), 313 ":/hd_new_22px.png", ":/hd_new_16px.png", 314 ":/hd_new_disabled_22px.png", ":/hd_new_disabled_16px.png")); 309 315 mRemoveAction->setIcon(UIIconPool::iconSetFull ( 310 316 QSize (22, 22), QSize (16, 16), … … 320 326 ":/refresh_disabled_22px.png", ":/refresh_disabled_16px.png")); 321 327 328 mActionsContextMenu->addAction (mCopyAction); 322 329 mActionsContextMenu->addAction (mRemoveAction); 323 330 mActionsContextMenu->addAction (mReleaseAction); … … 348 355 // mToolBar->addAction (mNewAction); 349 356 // mToolBar->addAction (mAddAction); 357 mToolBar->addAction (mCopyAction); 350 358 // mToolBar->addSeparator(); 351 359 mToolBar->addAction (mRemoveAction); … … 358 366 // mActionsMenu->addAction (mNewAction); 359 367 // mActionsMenu->addAction (mAddAction); 368 mActionsMenu->addAction (mCopyAction); 360 369 // mActionsMenu->addSeparator(); 361 370 mActionsMenu->addAction (mRemoveAction); … … 591 600 mNewAction->setText (tr ("&New...")); 592 601 mAddAction->setText (tr ("&Add...")); 602 mCopyAction->setText (tr ("&Copy...")); 593 603 mRemoveAction->setText (tr ("R&emove")); 594 604 mReleaseAction->setText (tr ("Re&lease")); … … 597 607 mNewAction->setShortcut (QKeySequence (QKeySequence::New)); 598 608 mAddAction->setShortcut (QKeySequence ("Ins")); 609 mCopyAction->setShortcut (QKeySequence ("Ctrl+C")); 599 610 mRemoveAction->setShortcut (QKeySequence (QKeySequence::Delete)); 600 611 mReleaseAction->setShortcut (QKeySequence ("Ctrl+L")); … … 603 614 mNewAction->setStatusTip (tr ("Create a new virtual hard disk")); 604 615 mAddAction->setStatusTip (tr ("Add an existing medium")); 616 mCopyAction->setStatusTip (tr ("Copy an existing medium")); 605 617 mRemoveAction->setStatusTip (tr ("Remove the selected medium")); 606 618 mReleaseAction->setStatusTip (tr ("Release the selected medium by detaching it from the machines")); … … 611 623 mAddAction->setToolTip (mAddAction->text().remove ('&') + 612 624 QString (" (%1)").arg (mAddAction->shortcut().toString())); 625 mCopyAction->setToolTip (mCopyAction->text().remove ('&') + 626 QString (" (%1)").arg (mCopyAction->shortcut().toString())); 613 627 mRemoveAction->setToolTip (mRemoveAction->text().remove ('&') + 614 628 QString (" (%1)").arg (mRemoveAction->shortcut().toString())); … … 1029 1043 } 1030 1044 1045 void VBoxMediaManagerDlg::doCopyMedium() 1046 { 1047 /* Get current tree: */ 1048 QTreeWidget *pTree = currentTreeWidget(); 1049 /* Get current item of current tree: */ 1050 MediaItem *pItem = toMediaItem(pTree->currentItem()); 1051 1052 UINewHDWizard wizard(this /* parent dialog */, 1053 tr("%1_copy", "copied virtual disk name").arg(QFileInfo(pItem->text(0)).baseName()) /* default name */, 1054 QFileInfo(pItem->location()).absolutePath() /* default path */, 1055 0 /* default size, not important for copying */, 1056 pItem->medium().medium() /* base medium for copying */); 1057 1058 if (wizard.exec() == QDialog::Accepted) 1059 { 1060 /* Search for the newly created hard disk: */ 1061 MediaItem *pItem = searchItem(mTwHD, wizard.hardDisk().GetId()); 1062 AssertReturnVoid(pItem); 1063 /* Select the newly created hard disk: */ 1064 mTwHD->setCurrentItem(pItem); 1065 } 1066 } 1067 1031 1068 void VBoxMediaManagerDlg::doRemoveMedium() 1032 1069 { … … 1383 1420 bool newEnabled = currentTreeWidgetType() == VBoxDefs::MediumType_HardDisk; 1384 1421 bool addEnabled = true; 1422 bool copyEnabled = notInEnum && item && checkMediumFor (item, Action_Copy); 1385 1423 bool removeEnabled = notInEnum && item && checkMediumFor (item, Action_Remove); 1386 1424 bool releaseEnabled = item && checkMediumFor (item, Action_Release); … … 1388 1426 mNewAction->setEnabled (newEnabled); 1389 1427 mAddAction->setEnabled (addEnabled); 1428 mCopyAction->setEnabled (copyEnabled); 1390 1429 mRemoveAction->setEnabled (removeEnabled); 1391 1430 mReleaseAction->setEnabled (releaseEnabled); … … 1706 1745 } 1707 1746 return true; 1747 } 1748 case Action_Copy: 1749 { 1750 /* False for children: */ 1751 return !aItem->medium().parent(); 1708 1752 } 1709 1753 case Action_Remove: -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.h
r32760 r37406 40 40 enum TabIndex { HDTab = 0, CDTab, FDTab }; 41 41 enum ItemAction { ItemAction_Added, ItemAction_Updated, ItemAction_Removed }; 42 enum Action { Action_Select, Action_Edit, Action_ Remove, Action_Release };42 enum Action { Action_Select, Action_Edit, Action_Copy, Action_Remove, Action_Release }; 43 43 44 44 public: … … 85 85 void doNewMedium(); 86 86 void doAddMedium(); 87 void doCopyMedium(); 87 88 void doRemoveMedium(); 88 89 void doReleaseMedium(); … … 155 156 QAction *mNewAction; 156 157 QAction *mAddAction; 158 QAction *mCopyAction; 157 159 QAction *mRemoveAction; 158 160 QAction *mReleaseAction; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizard.cpp
r37374 r37406 186 186 }; 187 187 188 UINewHDWizard::UINewHDWizard(QWidget *pParent, const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize )188 UINewHDWizard::UINewHDWizard(QWidget *pParent, const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize, const CMedium &initialHardDisk) 189 189 : QIWizard(pParent) 190 , m_wizardType(initialHardDisk.isNull() ? UINewHDWizardType_Creating : UINewHDWizardType_Copying) 190 191 { 191 192 /* Create & add pages: */ … … 194 195 addPage(new UINewHDWizardPageVariant); 195 196 addPage(new UINewHDWizardPageOptions(strDefaultName, strDefaultPath, uDefaultSize)); 196 addPage(new UINewHDWizardPageSummary );197 addPage(new UINewHDWizardPageSummary(initialHardDisk)); 197 198 198 199 /* Translate wizard: */ … … 222 223 void UINewHDWizard::retranslateUi() 223 224 { 224 /* Assign wizard title: */ 225 setWindowTitle(tr("Create New Virtual Disk")); 225 /* Translate wizard: */ 226 switch (wizardType()) 227 { 228 case UINewHDWizardType_Creating: 229 setWindowTitle(tr("Create New Virtual Disk")); 230 break; 231 case UINewHDWizardType_Copying: 232 setWindowTitle(tr("Copy Virtual Disk")); 233 break; 234 default: 235 break; 236 } 226 237 } 227 238 … … 237 248 Ui::UINewHDWizardPageWelcome::retranslateUi(this); 238 249 239 /* Set 'welcome' page title: */ 240 setTitle(tr("Welcome to the virtual disk creation wizard")); 250 /* Translate 'welcome' page: */ 251 switch (wizardType()) 252 { 253 case UINewHDWizardType_Creating: 254 setTitle(tr("Welcome to the virtual disk creation wizard")); 255 m_pLabel->setText("This wizard will help you to create a new virtual disk for your virtual machine."); 256 break; 257 case UINewHDWizardType_Copying: 258 setTitle(tr("Welcome to the virtual disk copying wizard")); 259 m_pLabel->setText("This wizard will help you to copy a virtual disk."); 260 break; 261 default: 262 break; 263 } 241 264 242 265 /* Append page text with common part: */ … … 335 358 Ui::UINewHDWizardPageFormat::retranslateUi(this); 336 359 337 /* Set 'format' page title: */360 /* Translate 'format' page: */ 338 361 setTitle(tr("Virtual disk file type")); 362 m_pLabel->setText("Please choose the type of file that you would like to use for the new virtual disk. " 363 "If you do not need to use it with other virtualization software you can leave this setting unchanged."); 339 364 340 365 /* Translate 'format' buttons: */ … … 429 454 Ui::UINewHDWizardPageVariant::retranslateUi(this); 430 455 431 /* Set 'variant' page title: */456 /* Translate 'variant' page: */ 432 457 setTitle(tr("Virtual disk storage details")); 458 m_pLabel->setText("Please choose whether the new virtual disk file should expand as it is used or be created fully expanded."); 433 459 434 460 /* Translate other text: */ … … 542 568 Ui::UINewHDWizardPageOptions::retranslateUi(this); 543 569 544 /* Set 'options' page title: */ 545 setTitle(tr("Virtual disk file location and size")); 570 /* Translate 'options' page: */ 571 switch (wizardType()) 572 { 573 case UINewHDWizardType_Creating: 574 setTitle(tr("Virtual disk file location and size")); 575 m_pLabel2->setText(tr("Select the size of the virtual disk in megabytes. This size will be reported to the Guest OS as the maximum size of this virtual disk.")); 576 break; 577 case UINewHDWizardType_Copying: 578 setTitle(tr("Virtual disk file location")); 579 m_pLabel2->setText(QString()); 580 break; 581 default: 582 break; 583 } 584 m_pLabel1->setText(tr("Press the <b>Select</b> button to select the location of a file to store the virtual disk data or type a file name in the entry field.")); 546 585 } 547 586 … … 550 589 /* Retranslate page: */ 551 590 retranslateUi(); 591 592 /* Setup 'options' page: */ 593 switch (wizardType()) 594 { 595 case UINewHDWizardType_Creating: 596 m_pLabel2->setVisible(true); 597 m_pSizeCnt->setVisible(true); 598 break; 599 case UINewHDWizardType_Copying: 600 m_pLabel2->setHidden(true); 601 m_pSizeCnt->setHidden(true); 602 break; 603 default: 604 break; 605 } 552 606 553 607 /* Initialize name: */ … … 769 823 } 770 824 771 UINewHDWizardPageSummary::UINewHDWizardPageSummary() 825 UINewHDWizardPageSummary::UINewHDWizardPageSummary(const CMedium &initialHardDisk) 826 : m_initialHardDisk(initialHardDisk) 772 827 { 773 828 /* Decorate page: */ … … 789 844 Ui::UINewHDWizardPageSummary::retranslateUi(this); 790 845 791 /* Set 'summary' page title: */846 /* Translate 'options' page: */ 792 847 setTitle(tr("Summary")); 848 switch (wizardType()) 849 { 850 case UINewHDWizardType_Creating: 851 m_pLabel1->setText(tr("You are going to create a new virtual disk with the following parameters:")); 852 break; 853 case UINewHDWizardType_Copying: 854 m_pLabel1->setText(tr("You are going to create a copied virtual disk with the following parameters:")); 855 break; 856 default: 857 break; 858 } 859 m_pLabel2->setText(tr("If the above settings are correct, press the <b>%1</b> button. " 860 "Once you press it the new virtual disk file will be created.") 861 .arg(VBoxGlobal::replaceHtmlEntities(VBoxGlobal::removeAccelMark(wizard()->buttonText(QWizard::FinishButton))))); 793 862 794 863 /* Compose common summary: */ … … 817 886 818 887 m_pSummaryText->setText("<table cellspacing=0 cellpadding=0>" + strSummary + "</table>"); 819 820 m_pLabel2->setText(tr("If the above settings are correct, press the <b>%1</b> button. "821 "Once you press it a new virtual disk file will be created.")822 .arg(VBoxGlobal::replaceHtmlEntities(VBoxGlobal::removeAccelMark(wizard()->buttonText(QWizard::FinishButton)))));823 888 } 824 889 … … 852 917 qulonglong uSize = field("mediumSize").toULongLong(); 853 918 919 /* Check attributes: */ 854 920 AssertReturn(!strMediumPath.isNull(), false); 855 921 AssertReturn(uSize > 0, false); 856 922 923 /* Get vbox object: */ 857 924 CVirtualBox vbox = vboxGlobal().virtualBox(); 858 925 926 /* Create new hard disk: */ 927 CMedium hardDisk = vbox.CreateHardDisk(mediumFormat.GetName(), strMediumPath); 859 928 CProgress progress; 860 861 CMedium hardDisk = vbox.CreateHardDisk(mediumFormat.GetName(), strMediumPath);862 863 929 if (!vbox.isOk()) 864 930 { … … 867 933 } 868 934 869 progress = hardDisk.CreateBaseStorage(uSize, uVariant); 870 935 /* Depending on dialog type: */ 936 switch (wizardType()) 937 { 938 case UINewHDWizardType_Creating: 939 { 940 /* Create base storage for the new hard disk: */ 941 progress = hardDisk.CreateBaseStorage(uSize, uVariant); 942 break; 943 } 944 case UINewHDWizardType_Copying: 945 { 946 /* Copy existing hard disk to the new hard disk: */ 947 progress = m_initialHardDisk.CloneTo(hardDisk, uVariant, CMedium() /* parent */); 948 break; 949 } 950 default: 951 return false; 952 } 953 954 /* Check for errors: */ 871 955 if (!hardDisk.isOk()) 872 956 { … … 874 958 return false; 875 959 } 876 877 960 vboxProblem().showModalProgressDialog(progress, windowTitle(), ":/progress_media_create_90px.png", this, true); 878 879 961 if (progress.GetCanceled()) 880 962 return false; 881 882 963 if (!progress.isOk() || progress.GetResultCode() != 0) 883 964 { … … 887 968 888 969 /* Inform everybody there is a new medium: */ 889 vboxGlobal().addMedium(VBoxMedium(CMedium(hardDisk), VBoxDefs::MediumType_HardDisk, KMediumState_Created));890 891 m_HardDisk = hardDisk; 970 m_hardDisk = hardDisk; 971 vboxGlobal().addMedium(VBoxMedium(m_hardDisk, VBoxDefs::MediumType_HardDisk, KMediumState_Created)); 972 892 973 return true; 893 974 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizard.h
r37374 r37406 36 36 class UIExclusivenessManager; 37 37 38 /* Wizard type: */ 39 enum UINewHDWizardType 40 { 41 UINewHDWizardType_Creating, 42 UINewHDWizardType_Copying 43 }; 44 38 45 /* New hard disk wizard class: */ 39 46 class UINewHDWizard : public QIWizard … … 44 51 45 52 /* Constructor: */ 46 UINewHDWizard(QWidget *pParent, const QString &strDefaultName = QString(), const QString &strDefaultPath = QString(), qulonglong uDefaultSize = 0); 53 UINewHDWizard(QWidget *pParent, 54 const QString &strDefaultName = QString(), const QString &strDefaultPath = QString(), 55 qulonglong uDefaultSize = 0, const CMedium &initialHardDisk = CMedium()); 56 57 /* Stuff for wizard type: */ 58 UINewHDWizardType wizardType() const { return m_wizardType; } 47 59 48 60 /* Returns created hard disk: */ … … 53 65 /* Translation stuff: */ 54 66 void retranslateUi(); 67 68 /* Wizard type: */ 69 UINewHDWizardType m_wizardType; 55 70 }; 56 71 … … 69 84 70 85 /* Returns parent wizard object: */ 71 UINewHDWizard* wizard() { return qobject_cast<UINewHDWizard*>(QIWizardPage::wizard()); } 86 UINewHDWizard* wizard() const { return qobject_cast<UINewHDWizard*>(QIWizardPage::wizard()); } 87 88 /* Returns parent wizard type: */ 89 UINewHDWizardType wizardType() const { return wizard()->wizardType(); } 72 90 }; 73 91 … … 267 285 268 286 /* Constructor: */ 269 UINewHDWizardPageSummary( );287 UINewHDWizardPageSummary(const CMedium &initialHardDisk); 270 288 271 289 protected: … … 285 303 bool createHardDisk(); 286 304 305 /* Initial hard disk: */ 306 CMedium m_initialHardDisk; 307 287 308 /* Stuff for 'hardDisk' field: */ 288 CMedium hardDisk() const { return m_ HardDisk; }289 void setHardDisk(const CMedium &hardDisk) { m_ HardDisk = hardDisk; }290 CMedium m_ HardDisk;309 CMedium hardDisk() const { return m_hardDisk; } 310 void setHardDisk(const CMedium &hardDisk) { m_hardDisk = hardDisk; } 311 CMedium m_hardDisk; 291 312 }; 292 313 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageFormat.ui
r37331 r37406 39 39 <bool>true</bool> 40 40 </property> 41 <property name="text">42 <string><p>Please choose the type of file that you would like to use for the new virtual disk. If you do not need to use this virtual machine with other virtualization software you can leave this setting unchanged.</p></string>43 </property>44 41 </widget> 45 42 </item> -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageOptions.ui
r37331 r37406 39 39 <bool>true</bool> 40 40 </property> 41 <property name="text">42 <string><p>Press the <b>Select</b> button to select the location of a file to store the virtual disk data or type a file name in the entry field.</p></string>43 </property>44 41 </widget> 45 42 </item> … … 67 64 <property name="wordWrap"> 68 65 <bool>true</bool> 69 </property>70 <property name="text">71 <string><p>Select the size of the virtual disk in megabytes. This size will be reported to the Guest OS as the maximum size of this virtual disk.</p></string>72 66 </property> 73 67 </widget> -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageSummary.ui
r37331 r37406 38 38 <property name="wordWrap"> 39 39 <bool>true</bool> 40 </property>41 <property name="text">42 <string>You are going to create a new virtual disk with the following parameters:</string>43 40 </property> 44 41 </widget> -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageVariant.ui
r37331 r37406 39 39 <bool>true</bool> 40 40 </property> 41 <property name="text">42 <string><p>Please choose whether the new virtual disk file should expand as it is used or be created fully expanded.</p></string>43 </property>44 41 </widget> 45 42 </item> -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageWelcome.ui
r37331 r37406 39 39 <bool>true</bool> 40 40 </property> 41 <property name="text">42 <string><p>This wizard will help you to create a new virtual disk for your virtual machine.</p></string>43 </property>44 41 </widget> 45 42 </item>
Note:
See TracChangeset
for help on using the changeset viewer.