- Timestamp:
- Jul 29, 2021 1:12:07 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145997
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r90405 r90406 1864 1864 if (pItem->itemType() == UIVirtualMachineItemType_Local) 1865 1865 { 1866 /* Open a session to modify VM state: */ 1867 CSession comSession = uiCommon().openExistingSession(pItem->id()); 1868 if (comSession.isNull()) 1869 break; 1870 1871 /* Get session console: */ 1872 CConsole comConsole = comSession.GetConsole(); 1873 /* Prepare machine power down: */ 1874 CProgress comProgress = comConsole.PowerDown(); 1875 if (!comConsole.isOk()) 1876 msgCenter().cannotPowerDownMachine(comConsole); 1877 else 1878 { 1879 /* Show machine power down progress: */ 1880 msgCenter().showModalProgressDialog(comProgress, pItem->name(), ":/progress_poweroff_90px.png"); 1881 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1882 msgCenter().cannotPowerDownMachine(comProgress, pItem->name()); 1883 else 1884 { 1885 /* Sanity check: */ 1886 AssertPtrReturnVoid(pItem->toLocal()); 1887 /* Restore snapshot if requested: */ 1888 const bool fDiscardStateOnPowerOff = gEDataManager->discardStateOnPowerOff(pItem->id()); 1889 if (fDiscardStateOnPowerOff && pItem->toLocal()->snapshotCount() > 0) 1890 uiCommon().restoreCurrentSnapshot(pItem->id()); 1891 } 1892 } 1893 1894 /* Unlock machine finally: */ 1895 comSession.UnlockMachine(); 1866 /* Powering VM down: */ 1867 UINotificationProgressMachinePowerDown *pNotification = new UINotificationProgressMachinePowerDown(pItem->id()); 1868 notificationCenter().append(pNotification); 1896 1869 } 1897 1870 /* For real cloud machine: */ -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r90405 r90406 397 397 398 398 /********************************************************************************************************************************* 399 * Class UINotificationProgressMachinePowerDown implementation. * 400 *********************************************************************************************************************************/ 401 402 UINotificationProgressMachinePowerDown::UINotificationProgressMachinePowerDown(const QUuid &uId) 403 : m_uId(uId) 404 { 405 connect(this, &UINotificationProgress::sigProgressFinished, 406 this, &UINotificationProgressMachinePowerDown::sltHandleProgressFinished); 407 } 408 409 QString UINotificationProgressMachinePowerDown::name() const 410 { 411 return UINotificationProgress::tr("Powering VM down ..."); 412 } 413 414 QString UINotificationProgressMachinePowerDown::details() const 415 { 416 return UINotificationProgress::tr("<b>VM Name:</b> %1").arg(m_strName); 417 } 418 419 CProgress UINotificationProgressMachinePowerDown::createProgress(COMResult &comResult) 420 { 421 /* Open a session thru which we will modify the machine: */ 422 m_comSession = uiCommon().openExistingSession(m_uId); 423 if (m_comSession.isNull()) 424 return CProgress(); 425 426 /* Get session machine: */ 427 CMachine comMachine = m_comSession.GetMachine(); 428 if (!m_comSession.isOk()) 429 { 430 comResult = m_comSession; 431 m_comSession.UnlockMachine(); 432 return CProgress(); 433 } 434 435 /* Acquire VM name: */ 436 m_strName = comMachine.GetName(); 437 if (!comMachine.isOk()) 438 { 439 comResult = comMachine; 440 m_comSession.UnlockMachine(); 441 return CProgress(); 442 } 443 444 /* Get session console: */ 445 CConsole comConsole = m_comSession.GetConsole(); 446 if (!m_comSession.isOk()) 447 { 448 comResult = m_comSession; 449 m_comSession.UnlockMachine(); 450 return CProgress(); 451 } 452 453 /* Initialize progress-wrapper: */ 454 CProgress comProgress = comConsole.PowerDown(); 455 /* Store COM result: */ 456 comResult = comConsole; 457 /* Return progress-wrapper: */ 458 return comProgress; 459 } 460 461 void UINotificationProgressMachinePowerDown::sltHandleProgressFinished() 462 { 463 /* Unlock session finally: */ 464 m_comSession.UnlockMachine(); 465 } 466 467 468 /********************************************************************************************************************************* 399 469 * Class UINotificationProgressMachineMediaRemove implementation. * 400 470 *********************************************************************************************************************************/ -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r90405 r90406 298 298 }; 299 299 300 /** UINotificationProgress extension for machine power-down functionality. */ 301 class SHARED_LIBRARY_STUFF UINotificationProgressMachinePowerDown : public UINotificationProgress 302 { 303 Q_OBJECT; 304 305 public: 306 307 /** Constructs machine power-down notification-progress. 308 * @param comMachine Brings the machine being powered-down. */ 309 UINotificationProgressMachinePowerDown(const QUuid &uId); 310 311 protected: 312 313 /** Returns object name. */ 314 virtual QString name() const /* override final */; 315 /** Returns object details. */ 316 virtual QString details() const /* override final */; 317 /** Creates and returns started progress-wrapper. */ 318 virtual CProgress createProgress(COMResult &comResult) /* override final */; 319 320 private slots: 321 322 /** Handles signal about progress being finished. */ 323 void sltHandleProgressFinished(); 324 325 private: 326 327 /** Holds the machine id. */ 328 QUuid m_uId; 329 /** Holds the session being opened. */ 330 CSession m_comSession; 331 /** Holds the machine name. */ 332 QString m_strName; 333 }; 334 300 335 /** UINotificationProgress extension for machine media remove functionality. */ 301 336 class SHARED_LIBRARY_STUFF UINotificationProgressMachineMediaRemove : public UINotificationProgress
Note:
See TracChangeset
for help on using the changeset viewer.