Changeset 26656 in vbox
- Timestamp:
- Feb 19, 2010 2:25:18 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r26637 r26656 372 372 , m_bIsPreventAutoClose(false) 373 373 { 374 /* Prepare action groups: */375 prepareActionGroups();376 377 /* Prepare action connections: */378 prepareActionConnections();379 380 /* Check the status of required features: */381 prepareRequiredFeatures();382 383 /* Load common logic settings: */384 loadLogicSettings();385 374 } 386 375 387 376 UIMachineLogic::~UIMachineLogic() 388 377 { 389 /* Save common logic settings: */390 saveLogicSettings();391 392 378 #ifdef VBOX_WITH_DEBUGGER_GUI 393 379 /* Close debugger: */ … … 399 385 void UIMachineLogic::updateAppearanceOf(int iElement) 400 386 { 387 /* Update logic: */ 401 388 CMachine machine = session().GetMachine(); 402 389 … … 410 397 actionsPool()->action(UIActionIndex_Toggle_Pause)->setEnabled(isRunningOrPaused); 411 398 } 399 400 /* Update window: */ 401 machineWindowWrapper()->updateAppearanceOf(iElement); 402 } 403 404 void UIMachineLogic::prepareActionGroups() 405 { 406 /* Create group for all actions that are enabled only when the VM is running. 407 * Note that only actions whose enabled state depends exclusively on the 408 * execution state of the VM are added to this group. */ 409 m_pRunningActions = new QActionGroup(this); 410 m_pRunningActions->setExclusive(false); 411 412 /* Create group for all actions that are enabled when the VM is running or paused. 413 * Note that only actions whose enabled state depends exclusively on the 414 * execution state of the VM are added to this group. */ 415 m_pRunningOrPausedActions = new QActionGroup(this); 416 m_pRunningOrPausedActions->setExclusive(false); 417 418 // TODO: Move actions into approprivate action groups! 419 } 420 421 void UIMachineLogic::prepareActionConnections() 422 { 423 /* "Machine" actions connections */ 424 connect(actionsPool()->action(UIActionIndex_Simple_AdjustWindow), SIGNAL(triggered()), 425 this, SLOT(sltAdjustWindow())); 426 connect(actionsPool()->action(UIActionIndex_Toggle_MouseIntegration), SIGNAL(toggled(bool)), 427 this, SLOT(sltToggleMouseIntegration(bool))); 428 connect(actionsPool()->action(UIActionIndex_Simple_TypeCAD), SIGNAL(triggered()), 429 this, SLOT(sltTypeCAD())); 430 #ifdef Q_WS_X11 431 connect(actionsPool()->action(UIActionIndex_Simple_TypeCABS), SIGNAL(triggered()), 432 this, SLOT(sltTypeCABS())); 433 #endif 434 connect(actionsPool()->action(UIActionIndex_Simple_TakeSnapshot), SIGNAL(triggered()), 435 this, SLOT(sltTakeSnapshot())); 436 connect(actionsPool()->action(UIActionIndex_Simple_InformationDialog), SIGNAL(triggered()), 437 this, SLOT(sltShowInformationDialog())); 438 connect(actionsPool()->action(UIActionIndex_Simple_Reset), SIGNAL(triggered()), 439 this, SLOT(sltReset())); 440 connect(actionsPool()->action(UIActionIndex_Toggle_Pause), SIGNAL(toggled(bool)), 441 this, SLOT(sltPause(bool))); 442 connect(actionsPool()->action(UIActionIndex_Simple_Shutdown), SIGNAL(triggered()), 443 this, SLOT(sltACPIShutdown())); 444 connect(actionsPool()->action(UIActionIndex_Simple_Close), SIGNAL(triggered()), 445 this, SLOT(sltClose())); 446 447 /* "Devices" actions connections */ 448 connect(actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->menu(), SIGNAL(aboutToShow()), 449 this, SLOT(sltPrepareStorageMenu())); 450 connect(actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->menu(), SIGNAL(aboutToShow()), 451 this, SLOT(sltPrepareStorageMenu())); 452 connect(actionsPool()->action(UIActionIndex_Simple_NetworkAdaptersDialog), SIGNAL(triggered()), 453 this, SLOT(sltOpenNetworkAdaptersDialog())); 454 connect(actionsPool()->action(UIActionIndex_Simple_SharedFoldersDialog), SIGNAL(triggered()), 455 this, SLOT(sltOpenSharedFoldersDialog())); 456 connect(actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu(), SIGNAL(aboutToShow()), 457 this, SLOT(sltPrepareUSBMenu())); 458 connect(actionsPool()->action(UIActionIndex_Toggle_VRDP), SIGNAL(toggled(bool)), 459 this, SLOT(sltSwitchVrdp(bool))); 460 connect(actionsPool()->action(UIActionIndex_Simple_InstallGuestTools), SIGNAL(triggered()), 461 this, SLOT(sltInstallGuestAdditions())); 462 463 #ifdef VBOX_WITH_DEBUGGER_GUI 464 /* "Debug" actions connections */ 465 connect(actionsPool()->action(UIActionIndex_Menu_Debug)->menu(), SIGNAL(aboutToShow()), 466 this, SLOT(sltPrepareDebugMenu())); 467 connect(actionsPool()->action(UIActionIndex_Simple_Statistics), SIGNAL(triggered()), 468 this, SLOT(sltShowDebugStatistics())); 469 connect(actionsPool()->action(UIActionIndex_Simple_CommandLine), SIGNAL(triggered()), 470 this, SLOT(sltShowDebugCommandLine())); 471 connect(actionsPool()->action(UIActionIndex_Toggle_Logging), SIGNAL(toggled(bool)), 472 this, SLOT(sltLoggingToggled(bool))); 473 #endif 474 } 475 476 void UIMachineLogic::prepareRequiredFeatures() 477 { 478 CConsole console = session().GetConsole(); 479 480 /* Check if the virtualization feature is required. */ 481 bool bIs64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType(console.GetGuest().GetOSTypeId()).GetIs64Bit(); 482 bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType(console.GetGuest().GetOSTypeId()).GetRecommendedVirtEx(); 483 AssertMsg(!bIs64BitsGuest || fRecommendVirtEx, ("Virtualization support missed for 64bit guest!\n")); 484 bool bIsVirtEnabled = console.GetDebugger().GetHWVirtExEnabled(); 485 if (fRecommendVirtEx && !bIsVirtEnabled) 486 { 487 bool ret; 488 489 // TODO: Check that logic! 490 //sltPause(true); 491 492 bool fVTxAMDVSupported = vboxGlobal().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx); 493 494 if (bIs64BitsGuest) 495 ret = vboxProblem().warnAboutVirtNotEnabled64BitsGuest(fVTxAMDVSupported); 496 else 497 ret = vboxProblem().warnAboutVirtNotEnabledGuestRequired(fVTxAMDVSupported); 498 499 // TODO: Close application! 500 //if (ret == true) 501 // machineWindowWrapper()->machineWindow()->close(); 502 // TODO: Check that logic! 503 //else 504 // sltPause(false); 505 } 506 507 #ifdef Q_WS_MAC 508 # ifdef VBOX_WITH_ICHAT_THEATER 509 initSharedAVManager(); 510 # endif 511 #endif 512 } 513 514 void UIMachineLogic::loadLogicSettings() 515 { 516 CMachine machine = session().GetMachine(); 517 518 /* Extra-data settings */ 519 { 520 QString strSettings; 521 522 strSettings = machine.GetExtraData(VBoxDefs::GUI_AutoresizeGuest); 523 if (strSettings != "off") 524 actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->setChecked(true); 525 526 strSettings = machine.GetExtraData(VBoxDefs::GUI_FirstRun); 527 if (strSettings == "yes") 528 m_bIsFirstTimeStarted = true; 529 530 strSettings = machine.GetExtraData(VBoxDefs::GUI_SaveMountedAtRuntime); 531 if (strSettings == "no") 532 m_bIsAutoSaveMedia = false; 533 } 534 535 /* Initial settings */ 536 { 537 /* Initialize storage stuff: */ 538 int iDevicesCountCD = 0; 539 int iDevicesCountFD = 0; 540 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments(); 541 foreach (const CMediumAttachment &attachment, attachments) 542 { 543 if (attachment.GetType() == KDeviceType_DVD) 544 ++ iDevicesCountCD; 545 if (attachment.GetType() == KDeviceType_Floppy) 546 ++ iDevicesCountFD; 547 } 548 actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->setData(iDevicesCountCD); 549 actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->setData(iDevicesCountFD); 550 actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->setVisible(iDevicesCountCD); 551 actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->setVisible(iDevicesCountFD); 552 } 553 554 /* Availability settings */ 555 { 556 /* USB Stuff: */ 557 CUSBController usbController = machine.GetUSBController(); 558 if (usbController.isNull()) 559 { 560 /* Hide USB_Menu: */ 561 actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu()->setVisible(false); 562 } 563 else 564 { 565 /* Enable/Disable USB_Menu: */ 566 actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu()->setEnabled(usbController.GetEnabled()); 567 } 568 569 /* VRDP Stuff: */ 570 CVRDPServer vrdpServer = machine.GetVRDPServer(); 571 if (vrdpServer.isNull()) 572 { 573 /* Hide VRDP Action: */ 574 actionsPool()->action(UIActionIndex_Toggle_VRDP)->setVisible(false); 575 } 576 } 577 } 578 579 void UIMachineLogic::saveLogicSettings() 580 { 581 CMachine machine = session().GetMachine(); 582 583 /* Extra-data settings */ 584 { 585 machine.SetExtraData(VBoxDefs::GUI_AutoresizeGuest, 586 actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->isChecked() ? "on" : "off"); 587 588 machine.SetExtraData(VBoxDefs::GUI_FirstRun, QString()); 589 590 // TODO: Move to fullscreen/seamless logic: 591 //machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide, mMiniToolBar->isAutoHide() ? "on" : "off"); 592 } 412 593 } 413 594 414 595 void UIMachineLogic::sltAdjustWindow() 415 596 { 416 if (!machineWindowWrapper()) 597 /* Do not process if window or view is missing! */ 598 if (!machineWindowWrapper() || !machineWindowWrapper()->machineView()) 417 599 return; 418 600 601 /* Exit maximized window state if actual: */ 419 602 if (machineWindowWrapper()->machineWindow()->isMaximized()) 420 603 machineWindowWrapper()->machineWindow()->showNormal(); 421 604 605 /* Normalize view's geometry: */ 422 606 machineWindowWrapper()->machineView()->normalizeGeometry(true); 423 607 } … … 425 609 void UIMachineLogic::sltToggleMouseIntegration(bool aOff) 426 610 { 427 if (!machineWindowWrapper()) 611 /* Do not process if window or view is missing! */ 612 if (!machineWindowWrapper() || !machineWindowWrapper()->machineView()) 428 613 return; 429 614 615 /* Disable/Enable mouse-integration for view: */ 430 616 machineWindowWrapper()->machineView()->setMouseIntegrationEnabled(!aOff); 431 432 updateAppearanceOf(UIVisualElement_MouseIntegrationStuff);433 617 } 434 618 … … 445 629 { 446 630 CKeyboard keyboard = session().GetConsole().GetKeyboard(); 447 Assert 631 Assert(!keyboard.isNull()); 448 632 static QVector<LONG> aSequence(6); 449 633 aSequence[0] = 0x1d; /* Ctrl down */ … … 460 644 void UIMachineLogic::sltTakeSnapshot() 461 645 { 646 /* Do not process if window is missing! */ 462 647 if (!machineWindowWrapper()) 463 648 return; … … 510 695 void UIMachineLogic::sltShowInformationDialog() 511 696 { 697 /* Do not process if window is missing! */ 698 if (!machineWindowWrapper()) 699 return; 700 512 701 // TODO: Call for singleton information dialog for this machine! 513 702 //VBoxVMInformationDlg::createInformationDlg(session(), machineWindowWrapper()->machineWindow()); … … 516 705 void UIMachineLogic::sltReset() 517 706 { 707 /* Do not process if window is missing! */ 518 708 if (!machineWindowWrapper()) 519 709 return; 520 710 711 /* Confirm/Reset current console: */ 521 712 if (vboxProblem().confirmVMReset(machineWindowWrapper()->machineWindow())) 522 713 session().GetConsole().Reset(); … … 525 716 void UIMachineLogic::sltPause(bool aOn) 526 717 { 527 if (!machineWindowWrapper()) 528 return; 529 718 /* Do not process if window is missing! */ 530 719 pause(aOn); 531 720 721 /* Update appearance: */ 532 722 updateAppearanceOf(UIVisualElement_PauseStuff); 533 723 } … … 535 725 void UIMachineLogic::sltACPIShutdown() 536 726 { 537 if (!machineWindowWrapper())538 return;539 540 727 CConsole console = session().GetConsole(); 541 728 729 /* Warn the user about ACPI is not available if so: */ 542 730 if (!console.GetGuestEnteredACPIMode()) 543 731 return vboxProblem().cannotSendACPIToMachine(); 544 732 733 /* Send ACPI shutdown signal, warn if failed: */ 545 734 console.PowerButton(); 546 735 if (!console.isOk()) … … 550 739 void UIMachineLogic::sltClose() 551 740 { 741 /* Do not process if window is missing! */ 552 742 if (!machineWindowWrapper()) 553 743 return; 554 744 745 /* Close machine window: */ 555 746 machineWindowWrapper()->machineWindow()->close(); 556 747 } … … 807 998 void UIMachineLogic::sltOpenNetworkAdaptersDialog() 808 999 { 1000 /* Do not process if window is missing! */ 809 1001 if (!machineWindowWrapper()) 810 1002 return; 811 1003 1004 /* Show network settings dialog: */ 812 1005 UINetworkAdaptersDialog dlg(machineWindowWrapper()->machineWindow(), session()); 813 1006 dlg.exec(); … … 816 1009 void UIMachineLogic::sltOpenSharedFoldersDialog() 817 1010 { 1011 /* Do not process if window is missing! */ 818 1012 if (!machineWindowWrapper()) 819 1013 return; 820 1014 1015 /* Show shared folders settings dialog: */ 821 1016 UISharedFoldersDialog dlg(machineWindowWrapper()->machineWindow(), session()); 822 1017 dlg.exec(); … … 833 1028 void UIMachineLogic::sltSwitchVrdp(bool aOn) 834 1029 { 835 if (!machineWindowWrapper()) 836 return; 837 1030 /* Enable VRDP server if possible: */ 838 1031 CVRDPServer server = session().GetMachine().GetVRDPServer(); 839 1032 AssertMsg(!server.isNull(), ("VRDP Server should not be null!\n")); 840 841 1033 server.SetEnabled(aOn); 842 1034 1035 /* Update appearance: */ 843 1036 updateAppearanceOf(UIVisualElement_VRDPStuff); 844 1037 } … … 846 1039 void UIMachineLogic::sltInstallGuestAdditions() 847 1040 { 1041 /* Do not process if window is missing! */ 848 1042 if (!machineWindowWrapper()) 849 1043 return; … … 877 1071 878 1072 /* Download the required image */ 1073 // TODO: Rework additions downloader logic... 1074 #if 0 879 1075 int result = vboxProblem().cannotFindGuestAdditions(QDir::toNativeSeparators(strSrc1), QDir::toNativeSeparators(strSrc2)); 880 1076 if (result == QIMessageBox::Yes) 881 1077 { 882 QString source = QString("http://download.virtualbox.org/virtualbox/%1/") 883 .arg (vbox.GetVersion().remove("_OSE")) + name; 1078 QString source = QString("http://download.virtualbox.org/virtualbox/%1/").arg(vbox.GetVersion().remove("_OSE")) + name; 884 1079 QString target = QDir(vboxGlobal().virtualBox().GetHomeFolder()).absoluteFilePath(name); 885 1080 886 // TODO: Think more about additions downloader... 887 //UIAdditionsDownloader *dl = 888 // new UIAdditionsDownloader(source, target, mDevicesInstallGuestToolsAction); 889 //machineWindowWrapper()->statusBar()->addWidget(dl, 0); 890 //dl->start(); 891 } 1081 //UIAdditionsDownloader *pdl = new UIAdditionsDownloader(source, target, mDevicesInstallGuestToolsAction); 1082 //machineWindowWrapper()->statusBar()->addWidget(pdl, 0); 1083 //pdl->start(); 1084 } 1085 #endif 892 1086 } 893 1087 … … 1091 1285 } 1092 1286 1093 void UIMachineLogic::prepareActionGroups()1094 {1095 /* Create group for all actions that are enabled only when the VM is running.1096 * Note that only actions whose enabled state depends exclusively on the1097 * execution state of the VM are added to this group. */1098 m_pRunningActions = new QActionGroup(this);1099 m_pRunningActions->setExclusive(false);1100 1101 /* Create group for all actions that are enabled when the VM is running or paused.1102 * Note that only actions whose enabled state depends exclusively on the1103 * execution state of the VM are added to this group. */1104 m_pRunningOrPausedActions = new QActionGroup(this);1105 m_pRunningOrPausedActions->setExclusive(false);1106 1107 // TODO: Move actions into approprivate action groups!1108 }1109 1110 void UIMachineLogic::prepareActionConnections()1111 {1112 /* "Machine" actions connections */1113 connect(actionsPool()->action(UIActionIndex_Simple_AdjustWindow), SIGNAL(triggered()),1114 this, SLOT(sltAdjustWindow()));1115 connect(actionsPool()->action(UIActionIndex_Toggle_MouseIntegration), SIGNAL(toggled(bool)),1116 this, SLOT(sltToggleMouseIntegration(bool)));1117 connect(actionsPool()->action(UIActionIndex_Simple_TypeCAD), SIGNAL(triggered()),1118 this, SLOT(sltTypeCAD()));1119 #ifdef Q_WS_X111120 connect(actionsPool()->action(UIActionIndex_Simple_TypeCABS), SIGNAL(triggered()),1121 this, SLOT(sltTypeCABS()));1122 #endif1123 connect(actionsPool()->action(UIActionIndex_Simple_TakeSnapshot), SIGNAL(triggered()),1124 this, SLOT(sltTakeSnapshot()));1125 connect(actionsPool()->action(UIActionIndex_Simple_InformationDialog), SIGNAL(triggered()),1126 this, SLOT(sltShowInformationDialog()));1127 connect(actionsPool()->action(UIActionIndex_Simple_Reset), SIGNAL(triggered()),1128 this, SLOT(sltReset()));1129 connect(actionsPool()->action(UIActionIndex_Toggle_Pause), SIGNAL(toggled(bool)),1130 this, SLOT(sltPause(bool)));1131 connect(actionsPool()->action(UIActionIndex_Simple_Shutdown), SIGNAL(triggered()),1132 this, SLOT(sltACPIShutdown()));1133 connect(actionsPool()->action(UIActionIndex_Simple_Close), SIGNAL(triggered()),1134 this, SLOT(sltClose()));1135 1136 /* "Devices" actions connections */1137 connect(actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->menu(), SIGNAL(aboutToShow()),1138 this, SLOT(sltPrepareStorageMenu()));1139 connect(actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->menu(), SIGNAL(aboutToShow()),1140 this, SLOT(sltPrepareStorageMenu()));1141 connect(actionsPool()->action(UIActionIndex_Simple_NetworkAdaptersDialog), SIGNAL(triggered()),1142 this, SLOT(sltOpenNetworkAdaptersDialog()));1143 connect(actionsPool()->action(UIActionIndex_Simple_SharedFoldersDialog), SIGNAL(triggered()),1144 this, SLOT(sltOpenSharedFoldersDialog()));1145 connect(actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu(), SIGNAL(aboutToShow()),1146 this, SLOT(sltPrepareUSBMenu()));1147 connect(actionsPool()->action(UIActionIndex_Toggle_VRDP), SIGNAL(toggled(bool)),1148 this, SLOT(sltSwitchVrdp(bool)));1149 connect(actionsPool()->action(UIActionIndex_Simple_InstallGuestTools), SIGNAL(triggered()),1150 this, SLOT(sltInstallGuestAdditions()));1151 1152 #ifdef VBOX_WITH_DEBUGGER_GUI1153 /* "Debug" actions connections */1154 connect(actionsPool()->action(UIActionIndex_Menu_Debug)->menu(), SIGNAL(aboutToShow()),1155 this, SLOT(sltPrepareDebugMenu()));1156 connect(actionsPool()->action(UIActionIndex_Simple_Statistics), SIGNAL(triggered()),1157 this, SLOT(sltShowDebugStatistics()));1158 connect(actionsPool()->action(UIActionIndex_Simple_CommandLine), SIGNAL(triggered()),1159 this, SLOT(sltShowDebugCommandLine()));1160 connect(actionsPool()->action(UIActionIndex_Toggle_Logging), SIGNAL(toggled(bool)),1161 this, SLOT(dbgLoggingToggled(bool)));1162 #endif1163 }1164 1165 void UIMachineLogic::prepareRequiredFeatures()1166 {1167 CConsole console = session().GetConsole();1168 1169 /* Check if the virtualization feature is required. */1170 bool bIs64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType(console.GetGuest().GetOSTypeId()).GetIs64Bit();1171 bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType(console.GetGuest().GetOSTypeId()).GetRecommendedVirtEx();1172 AssertMsg(!bIs64BitsGuest || fRecommendVirtEx, ("Virtualization support missed for 64bit guest!\n"));1173 bool bIsVirtEnabled = console.GetDebugger().GetHWVirtExEnabled();1174 if (fRecommendVirtEx && !bIsVirtEnabled)1175 {1176 bool ret;1177 1178 // TODO: Check that logic!1179 //sltPause(true);1180 1181 bool fVTxAMDVSupported = vboxGlobal().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx);1182 1183 if (bIs64BitsGuest)1184 ret = vboxProblem().warnAboutVirtNotEnabled64BitsGuest(fVTxAMDVSupported);1185 else1186 ret = vboxProblem().warnAboutVirtNotEnabledGuestRequired(fVTxAMDVSupported);1187 1188 // TODO: Close application!1189 //if (ret == true)1190 // machineWindowWrapper()->machineWindow()->close();1191 // TODO: Check that logic!1192 //else1193 // sltPause(false);1194 }1195 1196 #ifdef Q_WS_MAC1197 # ifdef VBOX_WITH_ICHAT_THEATER1198 initSharedAVManager();1199 # endif1200 #endif1201 }1202 1203 void UIMachineLogic::loadLogicSettings()1204 {1205 CMachine machine = session().GetMachine();1206 1207 /* Extra-data settings */1208 {1209 QString strSettings;1210 1211 strSettings = machine.GetExtraData(VBoxDefs::GUI_AutoresizeGuest);1212 if (strSettings != "off")1213 actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->setChecked(true);1214 1215 strSettings = machine.GetExtraData(VBoxDefs::GUI_FirstRun);1216 if (strSettings == "yes")1217 m_bIsFirstTimeStarted = true;1218 1219 strSettings = machine.GetExtraData(VBoxDefs::GUI_SaveMountedAtRuntime);1220 if (strSettings == "no")1221 m_bIsAutoSaveMedia = false;1222 }1223 1224 /* Initial settings */1225 {1226 /* Initialize storage stuff: */1227 int iDevicesCountCD = 0;1228 int iDevicesCountFD = 0;1229 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments();1230 foreach (const CMediumAttachment &attachment, attachments)1231 {1232 if (attachment.GetType() == KDeviceType_DVD)1233 ++ iDevicesCountCD;1234 if (attachment.GetType() == KDeviceType_Floppy)1235 ++ iDevicesCountFD;1236 }1237 actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->setData(iDevicesCountCD);1238 actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->setData(iDevicesCountFD);1239 actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->setVisible(iDevicesCountCD);1240 actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->setVisible(iDevicesCountFD);1241 }1242 1243 /* Availability settings */1244 {1245 /* USB Stuff: */1246 CUSBController usbController = machine.GetUSBController();1247 if (usbController.isNull())1248 {1249 /* Hide USB_Menu: */1250 actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu()->setVisible(false);1251 }1252 else1253 {1254 /* Enable/Disable USB_Menu: */1255 actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu()->setEnabled(usbController.GetEnabled());1256 }1257 1258 /* VRDP Stuff: */1259 CVRDPServer vrdpServer = machine.GetVRDPServer();1260 if (vrdpServer.isNull())1261 {1262 /* Hide VRDP Action: */1263 actionsPool()->action(UIActionIndex_Toggle_VRDP)->setVisible(false);1264 }1265 }1266 }1267 1268 void UIMachineLogic::saveLogicSettings()1269 {1270 CMachine machine = session().GetMachine();1271 1272 /* Extra-data settings */1273 {1274 machine.SetExtraData(VBoxDefs::GUI_AutoresizeGuest,1275 actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->isChecked() ? "on" : "off");1276 1277 machine.SetExtraData(VBoxDefs::GUI_FirstRun, QString());1278 1279 // TODO: Move to fullscreen/seamless logic:1280 //machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide, mMiniToolBar->isAutoHide() ? "on" : "off");1281 }1282 }1283 1284 1287 bool UIMachineLogic::pause(bool bOn) 1285 1288 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r26637 r26656 73 73 virtual void updateAppearanceOf(int iElement); 74 74 75 /* Prepare helpers: */ 76 virtual void prepareActionGroups(); 77 virtual void prepareActionConnections(); 78 virtual void prepareRequiredFeatures(); 79 virtual void loadLogicSettings(); 80 81 /* Cleanup helpers: */ 82 void saveLogicSettings(); 83 //void cleanupRequiredFeatures(); 84 //void cleanupActionConnections(); 85 //void cleanupActionGroups(); 86 75 87 /* Protected getters: */ 76 88 UIMachineWindow* machineWindowWrapper() { return m_pMachineWindowContainer; } … … 128 140 private: 129 141 130 /* Prepare helpers: */131 void prepareActionGroups();132 void prepareActionConnections();133 void prepareRequiredFeatures();134 void loadLogicSettings();135 136 /* Cleanup helpers: */137 void saveLogicSettings();138 //void cleanupRequiredFeatures();139 //void cleanupActionConnections();140 //void cleanupActionGroups();141 142 142 /* Utility functions: */ 143 143 void installGuestAdditionsFrom(const QString &strSource); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r26637 r26656 56 56 } 57 57 58 void UIMachineWindow::destroy(UIMachineWindow *pWhichWindow) 59 { 60 delete pWhichWindow; 61 } 62 58 63 UIMachineWindow::UIMachineWindow(UIMachineLogic *pMachineLogic) 59 64 : m_pMachineLogic(pMachineLogic) 60 { 61 /* Prepare window icon: */ 62 prepareWindowIcon(); 63 64 /* Load common window settings: */ 65 loadWindowSettings(); 66 67 /* Translate common window: */ 68 retranslateWindow(); 65 , m_pMachineWindow(0) 66 , m_pMachineView(0) 67 { 69 68 } 70 69 71 70 UIMachineWindow::~UIMachineWindow() 72 71 { 73 // Nothing for now! 74 } 75 76 void UIMachineWindow::retranslateWindow() 72 } 73 74 void UIMachineWindow::retranslateUi() 77 75 { 78 76 #ifdef VBOX_OSE … … 108 106 // mMiniToolBar->setDisplayText(machine.GetName() + strSnapshotName); 109 107 } 108 } 109 110 void UIMachineWindow::prepareWindowIcon() 111 { 112 #if !(defined (Q_WS_WIN) || defined (Q_WS_MAC)) 113 /* The default application icon (will be changed to VM-specific icon little bit later): 114 * 1. On Win32, it's built-in to the executable; 115 * 2. On Mac OS X the icon referenced in info.plist is used. */ 116 machineWindow()->setWindowIcon(QIcon(":/VirtualBox_48px.png")); 117 #endif 118 119 #ifndef Q_WS_MAC 120 /* Set the VM-specific application icon except Mac OS X: */ 121 CMachine machine = machineLogic()->session().GetMachine(); 122 machineWindow()->setWindowIcon(vboxGlobal().vmGuestOSTypeIcon(machine.GetOSTypeId())); 123 #endif 124 } 125 126 void UIMachineWindow::loadWindowSettings() 127 { 128 #ifdef Q_WS_MAC 129 QString testStr = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled).toLower(); 130 /* Default to true if it is an empty value */ 131 bool bIsDockIconEnabled = testStr.isEmpty() || testStr == "true"; 132 machineView()->setDockIconEnabled(bIsDockIconEnabled); 133 machineView()->updateDockOverlay(); 134 #endif 110 135 } 111 136 … … 368 393 } 369 394 } 370 371 void UIMachineWindow::prepareWindowIcon()372 {373 #if !(defined (Q_WS_WIN) || defined (Q_WS_MAC))374 /* The default application icon (will be changed to VM-specific icon little bit later):375 * 1. On Win32, it's built-in to the executable;376 * 2. On Mac OS X the icon referenced in info.plist is used. */377 machineWindow()->setWindowIcon(QIcon(":/VirtualBox_48px.png"));378 #endif379 380 #ifndef Q_WS_MAC381 /* Set the VM-specific application icon except Mac OS X: */382 CMachine machine = machineLogic()->session().GetMachine();383 machineWindow()->setWindowIcon(vboxGlobal().vmGuestOSTypeIcon(machine.GetOSTypeId()));384 #endif385 }386 387 void UIMachineWindow::loadWindowSettings()388 {389 #ifdef Q_WS_MAC390 QString testStr = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled).toLower();391 /* Default to true if it is an empty value */392 bool bIsDockIconEnabled = testStr.isEmpty() || testStr == "true";393 machineView()->setDockIconEnabled(bIsDockIconEnabled);394 machineView()->updateDockOverlay();395 #endif396 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h
r26637 r26656 40 40 /* Factory function to create required machine window child: */ 41 41 static UIMachineWindow* create(UIMachineLogic *pMachineLogic, UIVisualStateType visualStateType); 42 static void destroy(UIMachineWindow *pWhichWindow); 42 43 43 44 /* Abstract slot to close machine window: */ … … 56 57 57 58 /* Translate routine: */ 58 v oid retranslateWindow();59 virtual void retranslateUi(); 59 60 60 61 /* Update routines: */ 61 62 virtual void updateAppearanceOf(int iElement); 63 64 /* Prepare helpers: */ 65 virtual void prepareWindowIcon(); 66 virtual void loadWindowSettings(); 67 68 /* Cleanup helpers: */ 69 //virtual void saveWindowSettings(); 70 //virtual void cleanupWindowIcon(); 62 71 63 72 /* Common machine window event handlers: */ … … 68 77 69 78 /* Protected variables: */ 79 UIMachineLogic *m_pMachineLogic; 70 80 QWidget *m_pMachineWindow; 71 81 UIMachineView *m_pMachineView; 82 QString m_strWindowTitlePrefix; 72 83 73 private: 74 75 /* Prepare helpers: */ 76 void prepareWindowIcon(); 77 void loadWindowSettings(); 78 79 /* Cleanup helpers: */ 80 //void saveWindowSettings(); 81 //void cleanupWindowIcon(); 82 83 /* Getter variables: */ 84 UIMachineLogic *m_pMachineLogic; 85 86 /* Helper variables: */ 87 QString m_strWindowTitlePrefix; 84 friend class UIMachineLogic; 88 85 }; 89 86 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp
r26637 r26656 39 39 : UIMachineLogic(pParent, session, pActionsPool, UIVisualStateType_Normal) 40 40 { 41 /* Prepare action groups: */ 42 prepareActionGroups(); 43 41 44 /* Prepare action connections: */ 42 45 prepareActionConnections(); 43 46 47 /* Check the status of required features: */ 48 prepareRequiredFeatures(); 49 44 50 /* Prepare normal machine window: */ 45 51 prepareMachineWindow(); 52 53 /* Load common logic settings: */ 54 loadLogicSettings(); 55 56 /* Update all the elements: */ 57 updateAppearanceOf(UIVisualElement_AllStuff); 46 58 } 47 59 48 60 UIMachineLogicNormal::~UIMachineLogicNormal() 49 61 { 62 /* Save common logic settings: */ 63 saveLogicSettings(); 64 50 65 /* Cleanup normal machine window: */ 51 66 cleanupMachineWindow(); … … 76 91 void UIMachineLogicNormal::prepareActionConnections() 77 92 { 93 /* Parent class connections: */ 94 UIMachineLogic::prepareActionConnections(); 95 96 /* This class connections: */ 78 97 connect(actionsPool()->action(UIActionIndex_Menu_NetworkAdapters)->menu(), SIGNAL(aboutToShow()), 79 98 this, SLOT(sltPrepareNetworkAdaptersMenu())); … … 84 103 void UIMachineLogicNormal::prepareMachineWindow() 85 104 { 105 /* Do not prepare window if its ready: */ 86 106 if (machineWindowWrapper()) 87 107 return; … … 94 114 #endif /* Q_WS_MAC */ 95 115 116 /* Create machine window: */ 96 117 m_pMachineWindowContainer = UIMachineWindow::create(this, visualStateType()); 97 118 … … 99 120 setMachineState(session().GetConsole().GetState()); 100 121 101 /* Update all the stuff: */ 102 updateAppearanceOf(UIVisualElement_AllStuff); 103 122 /* Notify user about mouse&keyboard auto-capturing: */ 104 123 if (vboxGlobal().settings().autoCapture()) 105 124 vboxProblem().remindAboutAutoCapture(); 106 125 107 /* Notify the console scroll-view about the console-window is opened: */108 machineWindowWrapper()->machineView()->onViewOpened();109 110 126 bool saved = machineState() == KMachineState_Saved; 111 127 … … 113 129 CConsole console = session().GetConsole(); 114 130 131 /* Shows first run wizard if necessary: */ 115 132 if (isFirstTimeStarted()) 116 133 { 117 134 UIFirstRunWzd wzd(machineWindowWrapper()->machineWindow(), machine); 118 135 wzd.exec(); 119 120 /* Remove GUI_FirstRun extra data key from the machine settings 121 * file after showing the wizard once. */ 122 machine.SetExtraData (VBoxDefs::GUI_FirstRun, QString::null); 123 } 136 machine.SetExtraData(VBoxDefs::GUI_FirstRun, QString()); 137 } 138 139 140 // TODO: Do not start VM yet! 141 return; 142 124 143 125 144 /* Start VM: */ 126 145 CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ? 127 146 console.PowerUpPaused() : console.PowerUp(); 128 129 147 /* Check for an immediate failure */ 130 148 if (!console.isOk()) … … 134 152 return; 135 153 } 136 137 //machineWindowWrapper()->machineView()->attach();138 154 139 155 /* Disable auto closure because we want to have a chance to show the error dialog on startup failure: */ … … 165 181 } 166 182 167 #if 0 // TODO: Is it necessary now? 168 * Checking if the fullscreen mode should be activated: */ 169 QString str = machine.GetExtraData (VBoxDefs::GUI_Fullscreen); 170 if (str == "on") 171 mVmFullscreenAction->setChecked (true); 172 173 /* If seamless mode should be enabled then check if it is enabled 174 * currently and re-enable it if seamless is supported: */ 175 if (mVmSeamlessAction->isChecked() && m_bIsSeamlessSupported && m_bIsGraphicsSupported) 176 toggleFullscreenMode (true, true); 177 183 #if 0 // TODO: Rework debugger logic! 178 184 # ifdef VBOX_WITH_DEBUGGER_GUI 179 185 /* Open the debugger in "full screen" mode requested by the user. */ … … 205 211 #endif 206 212 207 connect(machineWindowWrapper()->machineView(), SIGNAL(machineStateChanged(KMachineState)), this, SLOT(sltUpdateMachineState(KMachineState))); 208 connect(machineWindowWrapper()->machineView(), SIGNAL(additionsStateChanged(const QString&, bool, bool, bool)), 209 this, SLOT(sltUpdateAdditionsState(const QString &, bool, bool, bool))); 210 connect(machineWindowWrapper()->machineView(), SIGNAL(mouseStateChanged(int)), this, SLOT(sltUpdateMouseState(int))); 211 212 /* Re-request all the static values finally after view is really opened and attached: */ 213 updateAppearanceOf(UIVisualElement_VirtualizationStuff); 213 /* Configure view connections: */ 214 if (machineWindowWrapper()->machineView()) 215 { 216 connect(machineWindowWrapper()->machineView(), SIGNAL(machineStateChanged(KMachineState)), 217 this, SLOT(sltUpdateMachineState(KMachineState))); 218 connect(machineWindowWrapper()->machineView(), SIGNAL(additionsStateChanged(const QString&, bool, bool, bool)), 219 this, SLOT(sltUpdateAdditionsState(const QString &, bool, bool, bool))); 220 connect(machineWindowWrapper()->machineView(), SIGNAL(mouseStateChanged(int)), 221 this, SLOT(sltUpdateMouseState(int))); 222 } 214 223 } 215 224 216 225 void UIMachineLogicNormal::cleanupMachineWindow() 217 226 { 227 /* Do not cleanup machine window if it is not present: */ 218 228 if (!machineWindowWrapper()) 219 229 return; 230 231 /* Cleanup machine window: */ 232 UIMachineWindow::destroy(m_pMachineWindowContainer); 233 m_pMachineWindowContainer = 0; 220 234 221 235 // TODO: What should be done on window destruction? -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h
r26637 r26656 62 62 //void saveLogicSettings(); 63 63 void cleanupMachineWindow(); 64 //void cleanupActionConnections(); 64 65 65 66 friend class UIMachineLogic; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp
r26637 r26656 51 51 m_pMachineWindow = this; 52 52 53 /* Prepare window icon: */ 54 prepareWindowIcon(); 55 53 56 /* Prepare menu: */ 54 57 prepareMenu(); … … 68 71 /* Retranslate normal window finally: */ 69 72 retranslateUi(); 73 74 /* Update all the elements: */ 75 updateAppearanceOf(UIVisualElement_AllStuff); 76 77 /* Show window: */ 78 show(); 70 79 } 71 80 … … 285 294 { 286 295 /* Translate parent class: */ 287 retranslateWindow();296 UIMachineWindow::retranslateUi(); 288 297 } 289 298 … … 678 687 void UIMachineWindowNormal::prepareMachineView() 679 688 { 689 return; // TODO: Do not create view for now! 690 680 691 CMachine machine = machineLogic()->session().GetMachine(); 681 692 … … 707 718 void UIMachineWindowNormal::loadWindowSettings() 708 719 { 720 /* Load parent class settings: */ 721 UIMachineWindow::loadWindowSettings(); 722 723 /* Load this class settings: */ 709 724 CMachine machine = machineLogic()->session().GetMachine(); 710 725 … … 733 748 setGeometry(m_normalGeometry); 734 749 735 /* Normalize to the optimal size */ 736 machineView()->normalizeGeometry(true /* adjust position? */); 750 /* Normalize view to the optimal size */ 751 if (machineView()) 752 machineView()->normalizeGeometry(true /* adjust position? */); 737 753 738 754 /* Maximize if needed */ … … 743 759 { 744 760 /* Normalize to the optimal size */ 745 machineView()->normalizeGeometry(true /* adjust position? */); 761 if (machineView()) 762 machineView()->normalizeGeometry(true /* adjust position? */); 746 763 747 764 /* Move newly created window to the screen center: */ … … 784 801 { 785 802 QString strWindowPosition = QString("%1,%2,%3,%4") 786 .arg(m_normalGeometry.x()).arg(m_normalGeometry.y())787 .arg(m_normalGeometry.width()).arg(m_normalGeometry.height());803 .arg(m_normalGeometry.x()).arg(m_normalGeometry.y()) 804 .arg(m_normalGeometry.width()).arg(m_normalGeometry.height()); 788 805 if (isMaximized()) 789 806 strWindowPosition += QString(",%1").arg(VBoxDefs::GUI_LastWindowPosition_Max); … … 796 813 /* Stop LED-update timer: */ 797 814 m_pIdleTimer->stop(); 798 m_pIdleTimer->disconnect(SIGNAL(timeout()), this, SLOT( updateDeviceLights()));799 } 815 m_pIdleTimer->disconnect(SIGNAL(timeout()), this, SLOT(sltUpdateIndicators())); 816 }
Note:
See TracChangeset
for help on using the changeset viewer.