- Timestamp:
- Aug 11, 2023 3:38:01 PM (18 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICloudNetworkingStuff.cpp
r98103 r100861 603 603 return pParent->handleNow(pNotification); 604 604 } 605 606 void UICloudNetworkingStuff::createCloudMachineClone(const QString &strProviderShortName, 607 const QString &strProfileName, 608 const CCloudMachine &comCloudMachine, 609 const QString &strCloneName, 610 UINotificationCenter *pParent) 611 { 612 /* Create cloud client: */ 613 CCloudClient comCloudClient = cloudClientByName(strProviderShortName, 614 strProfileName, 615 pParent); 616 if (comCloudClient.isNotNull()) 617 { 618 /* Clone specified cloud machine asynchronously: */ 619 UINotificationProgressCloudMachineClone *pNotification = 620 new UINotificationProgressCloudMachineClone(comCloudClient, comCloudMachine, strCloneName); 621 pParent->append(pNotification); 622 } 623 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICloudNetworkingStuff.h
r98103 r100861 184 184 const CForm &comForm, 185 185 UINotificationCenter *pParent); 186 187 /** Creates cloud machine clone. 188 * @param strProviderShortName Brings short provider name. 189 * @param strProfileName Brings profile name. 190 * @param comCloudMachine Brings cloud machine instance of which being cloned. 191 * @param strCloneName Brings clone name. 192 * @param pParent Brings notification-center reference. */ 193 SHARED_LIBRARY_STUFF void createCloudMachineClone(const QString &strProviderShortName, 194 const QString &strProfileName, 195 const CCloudMachine &comCloudMachine, 196 const QString &strCloneName, 197 UINotificationCenter *pParent); 186 198 } 187 199 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r100654 r100861 50 50 #include "QIDialogButtonBox.h" 51 51 #include "QIFileDialog.h" 52 #include "QILineEdit.h" 52 53 #include "QIRichTextLabel.h" 53 54 #include "UIActionPoolManager.h" … … 169 170 }; 170 171 172 /** QDialog extension used to ask for a cloud machine clone name. */ 173 class UIAcquireCloudMachineCloneNameDialog : public QIWithRetranslateUI<QDialog> 174 { 175 Q_OBJECT; 176 177 public: 178 179 /** Constructs dialog passing @a pParent to the base-class. 180 * @param strName Brings the clone name by default. */ 181 UIAcquireCloudMachineCloneNameDialog(QWidget *pParent, const QString &strName); 182 183 /** Returns value. */ 184 QString value() const; 185 186 protected: 187 188 /** Handles translation event. */ 189 virtual void retranslateUi() RT_OVERRIDE; 190 191 private slots: 192 193 /** Performs revalidation. */ 194 void sltRevalidate(); 195 196 private: 197 198 /** Prepares all. */ 199 void prepare(); 200 /** Prepares widgets. */ 201 void prepareWidgets(); 202 203 /** Holds the clone name by default. */ 204 QString m_strName; 205 206 /** Holds the text-editor instance. */ 207 QILineEdit *m_pEditor; 208 /** Holds the button-box instance. */ 209 QIDialogButtonBox *m_pButtonBox; 210 }; 211 171 212 172 213 /********************************************************************************************************************************* … … 433 474 m_pTextEditor->setPlainText(file.readAll()); 434 475 return true; 476 } 477 478 479 /********************************************************************************************************************************* 480 * Class UIAcquireCloudMachineCloneNameDialog implementation. * 481 *********************************************************************************************************************************/ 482 483 UIAcquireCloudMachineCloneNameDialog::UIAcquireCloudMachineCloneNameDialog(QWidget *pParent, const QString &strName) 484 : QIWithRetranslateUI<QDialog>(pParent) 485 , m_strName(strName) 486 , m_pEditor(0) 487 , m_pButtonBox(0) 488 { 489 prepare(); 490 sltRevalidate(); 491 } 492 493 QString UIAcquireCloudMachineCloneNameDialog::value() const 494 { 495 return m_pEditor ? m_pEditor->text() : QString(); 496 } 497 498 void UIAcquireCloudMachineCloneNameDialog::prepare() 499 { 500 /* Prepare widgets: */ 501 prepareWidgets(); 502 /* Apply language settings: */ 503 retranslateUi(); 504 505 /* Resize to suitable size: */ 506 const int iMinimumHeightHint = minimumSizeHint().height(); 507 resize(iMinimumHeightHint * 1.618, iMinimumHeightHint); 508 } 509 510 void UIAcquireCloudMachineCloneNameDialog::prepareWidgets() 511 { 512 /* Prepare layout: */ 513 QVBoxLayout *pLayout = new QVBoxLayout(this); 514 if (pLayout) 515 { 516 /* Prepare editor: */ 517 m_pEditor = new QILineEdit(this); 518 if (m_pEditor) 519 { 520 m_pEditor->setText(m_strName); 521 m_pEditor->setMinimumWidthByText(QString().fill('0', 20)); 522 connect(m_pEditor, &QILineEdit::textChanged, this, &UIAcquireCloudMachineCloneNameDialog::sltRevalidate); 523 pLayout->addWidget(m_pEditor); 524 } 525 526 /* Intermediate stretch: */ 527 pLayout->addStretch(); 528 529 /* Prepare button-box: */ 530 m_pButtonBox = new QIDialogButtonBox(this); 531 if (m_pButtonBox) 532 { 533 m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); 534 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIAcquireCloudMachineCloneNameDialog::accept); 535 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIAcquireCloudMachineCloneNameDialog::reject); 536 pLayout->addWidget(m_pButtonBox); 537 } 538 } 539 } 540 541 void UIAcquireCloudMachineCloneNameDialog::retranslateUi() 542 { 543 setWindowTitle(tr("Clone name")); 544 m_pEditor->setPlaceholderText(tr("Enter clone name")); 545 } 546 547 void UIAcquireCloudMachineCloneNameDialog::sltRevalidate() 548 { 549 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(!m_pEditor->text().isEmpty()); 435 550 } 436 551 … … 1237 1352 void UIVirtualBoxManager::sltOpenCloneMachineWizard() 1238 1353 { 1239 /* Configure wizard variables: */ 1240 m_fSnapshotCloneByDefault = false; 1241 QAction *pAction = qobject_cast<QAction*>(sender()); 1242 if ( pAction 1243 && pAction == actionPool()->action(UIActionIndexMN_M_Snapshot_S_Clone)) 1244 m_fSnapshotCloneByDefault = true; 1245 1246 /* Open Clone VM Wizard: */ 1247 sltOpenWizard(WizardType_CloneVM); 1354 /* Get current items: */ 1355 QList<UIVirtualMachineItem*> items = currentItems(); 1356 1357 /* We are opening Clone VM wizard for local VMs only: */ 1358 if (isItemsLocal(items)) 1359 { 1360 /* Configure wizard variables: */ 1361 m_fSnapshotCloneByDefault = false; 1362 QAction *pAction = qobject_cast<QAction*>(sender()); 1363 if ( pAction 1364 && pAction == actionPool()->action(UIActionIndexMN_M_Snapshot_S_Clone)) 1365 m_fSnapshotCloneByDefault = true; 1366 1367 /* Open Clone VM Wizard: */ 1368 sltOpenWizard(WizardType_CloneVM); 1369 } 1370 /* For cloud VMs we have no such wizard for now: */ 1371 else if (isItemsCloud(items)) 1372 { 1373 /* Acquire item, propose clone name: */ 1374 UIVirtualMachineItem *pItem = items.first(); 1375 const QString strName = QString("%1_clone").arg(pItem->name()); 1376 1377 /* Create Acquire Clone VM name dialog: */ 1378 QPointer<UIAcquireCloudMachineCloneNameDialog> pDialog = new UIAcquireCloudMachineCloneNameDialog(this, strName); 1379 if (pDialog->exec() == QDialog::Accepted) 1380 { 1381 /* Parse current full group name: */ 1382 const QString strFullGroupName = m_pWidget->fullGroupName(); 1383 const QString strProviderShortName = strFullGroupName.section('/', 1, 1); 1384 const QString strProfileName = strFullGroupName.section('/', 2, 2); 1385 1386 /* Acquire cloud machine: */ 1387 const CCloudMachine comMachine = pItem->toCloud()->machine(); 1388 1389 /* Clone VM: */ 1390 createCloudMachineClone(strProviderShortName, strProfileName, 1391 comMachine, pDialog->value(), 1392 gpNotificationCenter); 1393 } 1394 delete pDialog; 1395 } 1248 1396 } 1249 1397 … … 2998 3146 pMenu->addSeparator(); 2999 3147 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 3148 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Clone)); 3000 3149 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Remove)); 3001 3150 pMenu->addSeparator(); … … 3544 3693 return !isGroupSavingInProgress() && 3545 3694 items.size() == 1 && 3546 pItem->toLocal() &&3547 3695 pItem->isItemEditable(); 3548 3696 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r100654 r100861 1564 1564 { 1565 1565 pMenuMachine->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 1566 pMenuMachine->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Clone)); 1566 1567 pMenuMachine->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Remove)); 1567 1568 pMenuMachine->addSeparator(); -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r100654 r100861 3184 3184 if (error().isEmpty()) 3185 3185 emit sigCloudMachineRemoved(m_strProviderShortName, m_strProfileName, m_strName); 3186 } 3187 3188 3189 /********************************************************************************************************************************* 3190 * Class UINotificationProgressCloudMachineClone implementation. * 3191 *********************************************************************************************************************************/ 3192 3193 UINotificationProgressCloudMachineClone::UINotificationProgressCloudMachineClone(const CCloudClient &comClient, 3194 const CCloudMachine &comMachine, 3195 const QString &strCloneName) 3196 : m_comClient(comClient) 3197 , m_comMachine(comMachine) 3198 , m_strCloneName(strCloneName) 3199 { 3200 } 3201 3202 QString UINotificationProgressCloudMachineClone::name() const 3203 { 3204 return UINotificationProgress::tr("Cloning cloud VM ..."); 3205 } 3206 3207 QString UINotificationProgressCloudMachineClone::details() const 3208 { 3209 return UINotificationProgress::tr("<b>VM Name:</b> %1").arg(m_strName); 3210 } 3211 3212 CProgress UINotificationProgressCloudMachineClone::createProgress(COMResult &comResult) 3213 { 3214 // This is wrong, we need to acquire ocid, we have no one for now .. 3215 m_uId = m_comMachine.GetId(); 3216 if (!m_comMachine.isOk()) 3217 { 3218 /* Store COM result: */ 3219 comResult = m_comMachine; 3220 /* Return progress-wrapper: */ 3221 return CProgress(); 3222 } 3223 /* Acquire cloud VM name: */ 3224 m_strName = m_comMachine.GetName(); 3225 if (!m_comMachine.isOk()) 3226 { 3227 /* Store COM result: */ 3228 comResult = m_comMachine; 3229 /* Return progress-wrapper: */ 3230 return CProgress(); 3231 } 3232 3233 /* Initialize progress-wrapper: */ 3234 CCloudMachine comCloneMachine; 3235 // This is wrong, we need to pass ocid, we have no one for now .. 3236 const QString strId = m_uId.toString(); 3237 CProgress comProgress = m_comClient.CloneInstance(strId, m_strCloneName, comCloneMachine); 3238 /* Store COM result: */ 3239 comResult = m_comMachine; 3240 /* Return progress-wrapper: */ 3241 return comProgress; 3186 3242 } 3187 3243 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r100654 r100861 1822 1822 }; 1823 1823 1824 /** UINotificationProgress extension for cloud machine clone functionality. */ 1825 class SHARED_LIBRARY_STUFF UINotificationProgressCloudMachineClone : public UINotificationProgress 1826 { 1827 Q_OBJECT; 1828 1829 public: 1830 1831 /** Constructs cloud machine clone notification-progress. 1832 * @param comClient Brings the cloud client to clone cloud machine. 1833 * @param comMachine Brings the cloud machine to be cloned. 1834 * @param strCloneName Brings the clone name. */ 1835 UINotificationProgressCloudMachineClone(const CCloudClient &comClient, 1836 const CCloudMachine &comMachine, 1837 const QString &strCloneName); 1838 1839 protected: 1840 1841 /** Returns object name. */ 1842 virtual QString name() const /* override final */; 1843 /** Returns object details. */ 1844 virtual QString details() const /* override final */; 1845 /** Creates and returns started progress-wrapper. */ 1846 virtual CProgress createProgress(COMResult &comResult) /* override final */; 1847 1848 private: 1849 1850 /** Holds the client cloning machine. */ 1851 CCloudClient m_comClient; 1852 /** Holds the machine being reset. */ 1853 CCloudMachine m_comMachine; 1854 /** Holds the clone name. */ 1855 QString m_strCloneName; 1856 // This is wrong, we need to store ocid, we have no one for now .. 1857 QUuid m_uId; 1858 /** Holds the machine name. */ 1859 QString m_strName; 1860 }; 1861 1824 1862 /** UINotificationProgress extension for cloud machine reset functionality. */ 1825 1863 class SHARED_LIBRARY_STUFF UINotificationProgressCloudMachineReset : public UINotificationProgress
Note:
See TracChangeset
for help on using the changeset viewer.