Changeset 98617 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 17, 2023 11:44:48 AM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155909
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r98607 r98617 661 661 void UIMachine::saveState() 662 662 { 663 /* Prepare VM to be saved: */ 664 if (!uisession()->prepareToBeSaved()) 665 return; 666 667 /* Enable 'manual-override', 668 * preventing automatic Runtime UI closing: */ 669 setManualOverrideMode(true); 670 671 /* Now, do the magic: */ 672 LogRel(("GUI: Saving VM state..\n")); 673 UINotificationProgressMachineSaveState *pNotification = 674 new UINotificationProgressMachineSaveState(uisession()->machine()); 675 connect(pNotification, &UINotificationProgressMachineSaveState::sigMachineStateSaved, 676 this, &UIMachine::sltHandleMachineStateSaved); 677 gpNotificationCenter->append(pNotification); 663 uisession()->saveState(); 678 664 } 679 665 680 666 void UIMachine::shutdown() 681 667 { 682 /* Prepare VM to be shutdowned: */ 683 if (!uisession()->prepareToBeShutdowned()) 684 return; 685 686 /* Now, do the magic: */ 687 LogRel(("GUI: Sending ACPI shutdown signal..\n")); 688 CConsole comConsole = uisession()->console(); 689 comConsole.PowerButton(); 690 if (!comConsole.isOk()) 691 UINotificationMessage::cannotACPIShutdownMachine(uisession()->console()); 668 uisession()->shutdown(); 692 669 } 693 670 694 671 void UIMachine::powerOff(bool fIncludingDiscard) 695 672 { 696 /* Enable 'manual-override', 697 * preventing automatic Runtime UI closing: */ 698 setManualOverrideMode(true); 699 700 /* Now, do the magic: */ 701 LogRel(("GUI: Powering VM off..\n")); 702 UINotificationProgressMachinePowerOff *pNotification = 703 new UINotificationProgressMachinePowerOff(uisession()->machine(), 704 uisession()->console(), 705 fIncludingDiscard); 706 connect(pNotification, &UINotificationProgressMachinePowerOff::sigMachinePoweredOff, 707 this, &UIMachine::sltHandleMachinePoweredOff); 708 gpNotificationCenter->append(pNotification); 673 uisession()->powerOff(fIncludingDiscard); 709 674 } 710 675 … … 1045 1010 emit sigCursorPositionChange(); 1046 1011 } 1047 }1048 1049 void UIMachine::sltHandleMachineStateSaved(bool fSuccess)1050 {1051 /* Let user try again if saving failed: */1052 if (!fSuccess)1053 {1054 /* Disable 'manual-override' finally: */1055 setManualOverrideMode(false);1056 }1057 /* Close Runtime UI otherwise: */1058 else1059 closeRuntimeUI();1060 }1061 1062 void UIMachine::sltHandleMachinePoweredOff(bool fSuccess, bool fIncludingDiscard)1063 {1064 /* Let user try again if power off failed: */1065 if (!fSuccess)1066 {1067 /* Disable 'manual-override' finally: */1068 setManualOverrideMode(false);1069 }1070 /* Check for other tasks otherwise: */1071 else1072 {1073 if (fIncludingDiscard)1074 {1075 /* Now, do more magic! */1076 UINotificationProgressSnapshotRestore *pNotification =1077 new UINotificationProgressSnapshotRestore(uiCommon().managedVMUuid());1078 connect(pNotification, &UINotificationProgressSnapshotRestore::sigSnapshotRestored,1079 this, &UIMachine::sltHandleSnapshotRestored);1080 gpNotificationCenter->append(pNotification);1081 }1082 else1083 closeRuntimeUI();1084 }1085 }1086 1087 void UIMachine::sltHandleSnapshotRestored(bool)1088 {1089 /* Close Runtime UI independent of snapshot restoring state: */1090 closeRuntimeUI();1091 1012 } 1092 1013 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r98607 r98617 613 613 /** @} */ 614 614 615 /** @name Close stuff.616 ** @{ */617 /** Handles signal about machine state saved.618 * @param fSuccess Brings whether state was saved successfully. */619 void sltHandleMachineStateSaved(bool fSuccess);620 /** Handles signal about machine powered off.621 * @param fSuccess Brings whether machine was powered off successfully.622 * @param fIncludingDiscard Brings whether machine state should be discarded. */623 void sltHandleMachinePoweredOff(bool fSuccess, bool fIncludingDiscard);624 /** Handles signal about snapshot restored.625 * @param fSuccess Brings whether machine was powered off successfully. */626 void sltHandleSnapshotRestored(bool fSuccess);627 /** @} */628 629 615 private: 630 616 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r98607 r98617 804 804 } 805 805 806 bool UISession::prepareToBeSaved() 807 { 808 return isPaused() 809 || (isRunning() && pause()); 810 } 811 812 bool UISession::prepareToBeShutdowned() 813 { 806 void UISession::saveState() 807 { 808 if ( isPaused() 809 || (isRunning() && pause())) 810 { 811 /* Enable 'manual-override', 812 * preventing automatic Runtime UI closing: */ 813 uimachine()->setManualOverrideMode(true); 814 815 /* Now, do the magic: */ 816 LogRel(("GUI: Saving VM state..\n")); 817 UINotificationProgressMachineSaveState *pNotification = 818 new UINotificationProgressMachineSaveState(machine()); 819 connect(pNotification, &UINotificationProgressMachineSaveState::sigMachineStateSaved, 820 this, &UISession::sltHandleMachineStateSaved); 821 gpNotificationCenter->append(pNotification); 822 } 823 } 824 825 void UISession::shutdown() 826 { 827 /* Check whether guest is in proper mode: */ 814 828 bool fValidMode = false; 815 829 acquireWhetherGuestEnteredACPIMode(fValidMode); 816 830 if (!fValidMode) 817 831 UINotificationMessage::cannotSendACPIToMachine(); 818 return fValidMode; 832 else 833 { 834 /* Now, do the magic: */ 835 LogRel(("GUI: Sending ACPI shutdown signal..\n")); 836 CConsole comConsole = console(); 837 comConsole.PowerButton(); 838 if (!comConsole.isOk()) 839 UINotificationMessage::cannotACPIShutdownMachine(comConsole); 840 } 841 } 842 843 void UISession::powerOff(bool fIncludingDiscard) 844 { 845 /* Enable 'manual-override', 846 * preventing automatic Runtime UI closing: */ 847 uimachine()->setManualOverrideMode(true); 848 849 /* Now, do the magic: */ 850 LogRel(("GUI: Powering VM off..\n")); 851 UINotificationProgressMachinePowerOff *pNotification = 852 new UINotificationProgressMachinePowerOff(machine(), 853 console(), 854 fIncludingDiscard); 855 connect(pNotification, &UINotificationProgressMachinePowerOff::sigMachinePoweredOff, 856 this, &UISession::sltHandleMachinePoweredOff); 857 gpNotificationCenter->append(pNotification); 819 858 } 820 859 … … 889 928 /* Notify listeners about GA state change event came: */ 890 929 emit sigAdditionsStateChange(); 930 } 931 932 void UISession::sltHandleMachineStateSaved(bool fSuccess) 933 { 934 /* Let user try again if saving failed: */ 935 if (!fSuccess) 936 { 937 /* Disable 'manual-override' finally: */ 938 uimachine()->setManualOverrideMode(false); 939 } 940 /* Close Runtime UI otherwise: */ 941 else 942 uimachine()->closeRuntimeUI(); 943 } 944 945 void UISession::sltHandleMachinePoweredOff(bool fSuccess, bool fIncludingDiscard) 946 { 947 /* Let user try again if power off failed: */ 948 if (!fSuccess) 949 { 950 /* Disable 'manual-override' finally: */ 951 uimachine()->setManualOverrideMode(false); 952 } 953 /* Check for other tasks otherwise: */ 954 else 955 { 956 if (fIncludingDiscard) 957 { 958 /* Now, do more magic! */ 959 UINotificationProgressSnapshotRestore *pNotification = 960 new UINotificationProgressSnapshotRestore(uiCommon().managedVMUuid()); 961 connect(pNotification, &UINotificationProgressSnapshotRestore::sigSnapshotRestored, 962 this, &UISession::sltHandleSnapshotRestored); 963 gpNotificationCenter->append(pNotification); 964 } 965 else 966 uimachine()->closeRuntimeUI(); 967 } 968 } 969 970 void UISession::sltHandleSnapshotRestored(bool) 971 { 972 /* Close Runtime UI independent of snapshot restoring state: */ 973 uimachine()->closeRuntimeUI(); 891 974 } 892 975 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r98607 r98617 395 395 bool acquireWhetherGuestEnteredACPIMode(bool &fEntered); 396 396 397 /** Prepares VM to be saved. */ 398 bool prepareToBeSaved(); 399 /** Returns whether VM can be shutdowned. */ 400 bool prepareToBeShutdowned(); 397 /** Saves VM state, then closes Runtime UI. */ 398 void saveState(); 399 /** Calls for guest shutdown to close Runtime UI. */ 400 void shutdown(); 401 /** Powers VM off, then closes Runtime UI. */ 402 void powerOff(bool fIncludingDiscard); 401 403 /** @} */ 402 404 … … 431 433 /** Handles event about guest additions change. */ 432 434 void sltAdditionsChange(); 435 /** @} */ 436 437 /** @name Close stuff. 438 ** @{ */ 439 /** Handles signal about machine state saved. 440 * @param fSuccess Brings whether state was saved successfully. */ 441 void sltHandleMachineStateSaved(bool fSuccess); 442 /** Handles signal about machine powered off. 443 * @param fSuccess Brings whether machine was powered off successfully. 444 * @param fIncludingDiscard Brings whether machine state should be discarded. */ 445 void sltHandleMachinePoweredOff(bool fSuccess, bool fIncludingDiscard); 446 /** Handles signal about snapshot restored. 447 * @param fSuccess Brings whether machine was powered off successfully. */ 448 void sltHandleSnapshotRestored(bool fSuccess); 433 449 /** @} */ 434 450
Note:
See TracChangeset
for help on using the changeset viewer.