VirtualBox

Changeset 26656 in vbox


Ignore:
Timestamp:
Feb 19, 2010 2:25:18 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: Cumulative update for new running VM core. Now UIMachineLogic(+Normal) & UIMachineWindow(+Normal) are works.

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  
    372372    , m_bIsPreventAutoClose(false)
    373373{
    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();
    385374}
    386375
    387376UIMachineLogic::~UIMachineLogic()
    388377{
    389     /* Save common logic settings: */
    390     saveLogicSettings();
    391 
    392378#ifdef VBOX_WITH_DEBUGGER_GUI
    393379    /* Close debugger: */
     
    399385void UIMachineLogic::updateAppearanceOf(int iElement)
    400386{
     387    /* Update logic: */
    401388    CMachine machine = session().GetMachine();
    402389
     
    410397        actionsPool()->action(UIActionIndex_Toggle_Pause)->setEnabled(isRunningOrPaused);
    411398    }
     399
     400    /* Update window: */
     401    machineWindowWrapper()->updateAppearanceOf(iElement);
     402}
     403
     404void 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
     421void 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
     476void 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
     514void 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
     579void 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    }
    412593}
    413594
    414595void UIMachineLogic::sltAdjustWindow()
    415596{
    416     if (!machineWindowWrapper())
     597    /* Do not process if window or view is missing! */
     598    if (!machineWindowWrapper() || !machineWindowWrapper()->machineView())
    417599        return;
    418600
     601    /* Exit maximized window state if actual: */
    419602    if (machineWindowWrapper()->machineWindow()->isMaximized())
    420603        machineWindowWrapper()->machineWindow()->showNormal();
    421604
     605    /* Normalize view's geometry: */
    422606    machineWindowWrapper()->machineView()->normalizeGeometry(true);
    423607}
     
    425609void UIMachineLogic::sltToggleMouseIntegration(bool aOff)
    426610{
    427     if (!machineWindowWrapper())
     611    /* Do not process if window or view is missing! */
     612    if (!machineWindowWrapper() || !machineWindowWrapper()->machineView())
    428613        return;
    429614
     615    /* Disable/Enable mouse-integration for view: */
    430616    machineWindowWrapper()->machineView()->setMouseIntegrationEnabled(!aOff);
    431 
    432     updateAppearanceOf(UIVisualElement_MouseIntegrationStuff);
    433617}
    434618
     
    445629{
    446630    CKeyboard keyboard = session().GetConsole().GetKeyboard();
    447     Assert (!keyboard.isNull());
     631    Assert(!keyboard.isNull());
    448632    static QVector<LONG> aSequence(6);
    449633    aSequence[0] = 0x1d; /* Ctrl down */
     
    460644void UIMachineLogic::sltTakeSnapshot()
    461645{
     646    /* Do not process if window is missing! */
    462647    if (!machineWindowWrapper())
    463648        return;
     
    510695void UIMachineLogic::sltShowInformationDialog()
    511696{
     697    /* Do not process if window is missing! */
     698    if (!machineWindowWrapper())
     699        return;
     700
    512701    // TODO: Call for singleton information dialog for this machine!
    513702    //VBoxVMInformationDlg::createInformationDlg(session(), machineWindowWrapper()->machineWindow());
     
    516705void UIMachineLogic::sltReset()
    517706{
     707    /* Do not process if window is missing! */
    518708    if (!machineWindowWrapper())
    519709        return;
    520710
     711    /* Confirm/Reset current console: */
    521712    if (vboxProblem().confirmVMReset(machineWindowWrapper()->machineWindow()))
    522713        session().GetConsole().Reset();
     
    525716void UIMachineLogic::sltPause(bool aOn)
    526717{
    527     if (!machineWindowWrapper())
    528         return;
    529 
     718    /* Do not process if window is missing! */
    530719    pause(aOn);
    531720
     721    /* Update appearance: */
    532722    updateAppearanceOf(UIVisualElement_PauseStuff);
    533723}
     
    535725void UIMachineLogic::sltACPIShutdown()
    536726{
    537     if (!machineWindowWrapper())
    538         return;
    539 
    540727    CConsole console = session().GetConsole();
    541728
     729    /* Warn the user about ACPI is not available if so: */
    542730    if (!console.GetGuestEnteredACPIMode())
    543731        return vboxProblem().cannotSendACPIToMachine();
    544732
     733    /* Send ACPI shutdown signal, warn if failed: */
    545734    console.PowerButton();
    546735    if (!console.isOk())
     
    550739void UIMachineLogic::sltClose()
    551740{
     741    /* Do not process if window is missing! */
    552742    if (!machineWindowWrapper())
    553743        return;
    554744
     745    /* Close machine window: */
    555746    machineWindowWrapper()->machineWindow()->close();
    556747}
     
    807998void UIMachineLogic::sltOpenNetworkAdaptersDialog()
    808999{
     1000    /* Do not process if window is missing! */
    8091001    if (!machineWindowWrapper())
    8101002        return;
    8111003
     1004    /* Show network settings dialog: */
    8121005    UINetworkAdaptersDialog dlg(machineWindowWrapper()->machineWindow(), session());
    8131006    dlg.exec();
     
    8161009void UIMachineLogic::sltOpenSharedFoldersDialog()
    8171010{
     1011    /* Do not process if window is missing! */
    8181012    if (!machineWindowWrapper())
    8191013        return;
    8201014
     1015    /* Show shared folders settings dialog: */
    8211016    UISharedFoldersDialog dlg(machineWindowWrapper()->machineWindow(), session());
    8221017    dlg.exec();
     
    8331028void UIMachineLogic::sltSwitchVrdp(bool aOn)
    8341029{
    835     if (!machineWindowWrapper())
    836         return;
    837 
     1030    /* Enable VRDP server if possible: */
    8381031    CVRDPServer server = session().GetMachine().GetVRDPServer();
    8391032    AssertMsg(!server.isNull(), ("VRDP Server should not be null!\n"));
    840 
    8411033    server.SetEnabled(aOn);
    8421034
     1035    /* Update appearance: */
    8431036    updateAppearanceOf(UIVisualElement_VRDPStuff);
    8441037}
     
    8461039void UIMachineLogic::sltInstallGuestAdditions()
    8471040{
     1041    /* Do not process if window is missing! */
    8481042    if (!machineWindowWrapper())
    8491043        return;
     
    8771071
    8781072    /* Download the required image */
     1073    // TODO: Rework additions downloader logic...
     1074    #if 0
    8791075    int result = vboxProblem().cannotFindGuestAdditions(QDir::toNativeSeparators(strSrc1), QDir::toNativeSeparators(strSrc2));
    8801076    if (result == QIMessageBox::Yes)
    8811077    {
    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;
    8841079        QString target = QDir(vboxGlobal().virtualBox().GetHomeFolder()).absoluteFilePath(name);
    8851080
    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
    8921086}
    8931087
     
    10911285}
    10921286
    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 the
    1097      * 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 the
    1103      * 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_X11
    1120     connect(actionsPool()->action(UIActionIndex_Simple_TypeCABS), SIGNAL(triggered()),
    1121             this, SLOT(sltTypeCABS()));
    1122 #endif
    1123     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_GUI
    1153     /* "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 #endif
    1163 }
    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         else
    1186             ret = vboxProblem().warnAboutVirtNotEnabledGuestRequired(fVTxAMDVSupported);
    1187 
    1188         // TODO: Close application!
    1189         //if (ret == true)
    1190         //    machineWindowWrapper()->machineWindow()->close();
    1191         // TODO: Check that logic!
    1192         //else
    1193         //    sltPause(false);
    1194     }
    1195 
    1196 #ifdef Q_WS_MAC
    1197 # ifdef VBOX_WITH_ICHAT_THEATER
    1198     initSharedAVManager();
    1199 # endif
    1200 #endif
    1201 }
    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         else
    1253         {
    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 
    12841287bool UIMachineLogic::pause(bool bOn)
    12851288{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r26637 r26656  
    7373    virtual void updateAppearanceOf(int iElement);
    7474
     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
    7587    /* Protected getters: */
    7688    UIMachineWindow* machineWindowWrapper() { return m_pMachineWindowContainer; }
     
    128140private:
    129141
    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 
    142142    /* Utility functions: */
    143143    void installGuestAdditionsFrom(const QString &strSource);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r26637 r26656  
    5656}
    5757
     58void UIMachineWindow::destroy(UIMachineWindow *pWhichWindow)
     59{
     60    delete pWhichWindow;
     61}
     62
    5863UIMachineWindow::UIMachineWindow(UIMachineLogic *pMachineLogic)
    5964    : 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{
    6968}
    7069
    7170UIMachineWindow::~UIMachineWindow()
    7271{
    73     // Nothing for now!
    74 }
    75 
    76 void UIMachineWindow::retranslateWindow()
     72}
     73
     74void UIMachineWindow::retranslateUi()
    7775{
    7876#ifdef VBOX_OSE
     
    108106        // mMiniToolBar->setDisplayText(machine.GetName() + strSnapshotName);
    109107    }
     108}
     109
     110void 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
     126void 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
    110135}
    111136
     
    368393    }
    369394}
    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 #endif
    379 
    380 #ifndef Q_WS_MAC
    381     /* Set the VM-specific application icon except Mac OS X: */
    382     CMachine machine = machineLogic()->session().GetMachine();
    383     machineWindow()->setWindowIcon(vboxGlobal().vmGuestOSTypeIcon(machine.GetOSTypeId()));
    384 #endif
    385 }
    386 
    387 void UIMachineWindow::loadWindowSettings()
    388 {
    389 #ifdef Q_WS_MAC
    390     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 #endif
    396 }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r26637 r26656  
    4040    /* Factory function to create required machine window child: */
    4141    static UIMachineWindow* create(UIMachineLogic *pMachineLogic, UIVisualStateType visualStateType);
     42    static void destroy(UIMachineWindow *pWhichWindow);
    4243
    4344    /* Abstract slot to close machine window: */
     
    5657
    5758    /* Translate routine: */
    58     void retranslateWindow();
     59    virtual void retranslateUi();
    5960
    6061    /* Update routines: */
    6162    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();
    6271
    6372    /* Common machine window event handlers: */
     
    6877
    6978    /* Protected variables: */
     79    UIMachineLogic *m_pMachineLogic;
    7080    QWidget *m_pMachineWindow;
    7181    UIMachineView *m_pMachineView;
     82    QString m_strWindowTitlePrefix;
    7283
    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;
    8885};
    8986
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r26637 r26656  
    3939    : UIMachineLogic(pParent, session, pActionsPool, UIVisualStateType_Normal)
    4040{
     41    /* Prepare action groups: */
     42    prepareActionGroups();
     43
    4144    /* Prepare action connections: */
    4245    prepareActionConnections();
    4346
     47    /* Check the status of required features: */
     48    prepareRequiredFeatures();
     49
    4450    /* Prepare normal machine window: */
    4551    prepareMachineWindow();
     52
     53    /* Load common logic settings: */
     54    loadLogicSettings();
     55
     56    /* Update all the elements: */
     57    updateAppearanceOf(UIVisualElement_AllStuff);
    4658}
    4759
    4860UIMachineLogicNormal::~UIMachineLogicNormal()
    4961{
     62    /* Save common logic settings: */
     63    saveLogicSettings();
     64
    5065    /* Cleanup normal machine window: */
    5166    cleanupMachineWindow();
     
    7691void UIMachineLogicNormal::prepareActionConnections()
    7792{
     93    /* Parent class connections: */
     94    UIMachineLogic::prepareActionConnections();
     95
     96    /* This class connections: */
    7897    connect(actionsPool()->action(UIActionIndex_Menu_NetworkAdapters)->menu(), SIGNAL(aboutToShow()),
    7998            this, SLOT(sltPrepareNetworkAdaptersMenu()));
     
    84103void UIMachineLogicNormal::prepareMachineWindow()
    85104{
     105    /* Do not prepare window if its ready: */
    86106    if (machineWindowWrapper())
    87107        return;
     
    94114#endif /* Q_WS_MAC */
    95115
     116    /* Create machine window: */
    96117    m_pMachineWindowContainer = UIMachineWindow::create(this, visualStateType());
    97118
     
    99120    setMachineState(session().GetConsole().GetState());
    100121
    101     /* Update all the stuff: */
    102     updateAppearanceOf(UIVisualElement_AllStuff);
    103 
     122    /* Notify user about mouse&keyboard auto-capturing: */
    104123    if (vboxGlobal().settings().autoCapture())
    105124        vboxProblem().remindAboutAutoCapture();
    106125
    107     /* Notify the console scroll-view about the console-window is opened: */
    108     machineWindowWrapper()->machineView()->onViewOpened();
    109 
    110126    bool saved = machineState() == KMachineState_Saved;
    111127
     
    113129    CConsole console = session().GetConsole();
    114130
     131    /* Shows first run wizard if necessary: */
    115132    if (isFirstTimeStarted())
    116133    {
    117134        UIFirstRunWzd wzd(machineWindowWrapper()->machineWindow(), machine);
    118135        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
    124143
    125144    /* Start VM: */
    126145    CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ?
    127146                         console.PowerUpPaused() : console.PowerUp();
    128 
    129147    /* Check for an immediate failure */
    130148    if (!console.isOk())
     
    134152        return;
    135153    }
    136 
    137     //machineWindowWrapper()->machineView()->attach();
    138154
    139155    /* Disable auto closure because we want to have a chance to show the error dialog on startup failure: */
     
    165181    }
    166182
    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!
    178184# ifdef VBOX_WITH_DEBUGGER_GUI
    179185    /* Open the debugger in "full screen" mode requested by the user. */
     
    205211#endif
    206212
    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    }
    214223}
    215224
    216225void UIMachineLogicNormal::cleanupMachineWindow()
    217226{
     227    /* Do not cleanup machine window if it is not present: */
    218228    if (!machineWindowWrapper())
    219229        return;
     230
     231    /* Cleanup machine window: */
     232    UIMachineWindow::destroy(m_pMachineWindowContainer);
     233    m_pMachineWindowContainer = 0;
    220234
    221235    // TODO: What should be done on window destruction?
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h

    r26637 r26656  
    6262    //void saveLogicSettings();
    6363    void cleanupMachineWindow();
     64    //void cleanupActionConnections();
    6465
    6566    friend class UIMachineLogic;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r26637 r26656  
    5151    m_pMachineWindow = this;
    5252
     53    /* Prepare window icon: */
     54    prepareWindowIcon();
     55
    5356    /* Prepare menu: */
    5457    prepareMenu();
     
    6871    /* Retranslate normal window finally: */
    6972    retranslateUi();
     73
     74    /* Update all the elements: */
     75    updateAppearanceOf(UIVisualElement_AllStuff);
     76
     77    /* Show window: */
     78    show();
    7079}
    7180
     
    285294{
    286295    /* Translate parent class: */
    287     retranslateWindow();
     296    UIMachineWindow::retranslateUi();
    288297}
    289298
     
    678687void UIMachineWindowNormal::prepareMachineView()
    679688{
     689    return; // TODO: Do not create view for now!
     690
    680691    CMachine machine = machineLogic()->session().GetMachine();
    681692
     
    707718void UIMachineWindowNormal::loadWindowSettings()
    708719{
     720    /* Load parent class settings: */
     721    UIMachineWindow::loadWindowSettings();
     722
     723    /* Load this class settings: */
    709724    CMachine machine = machineLogic()->session().GetMachine();
    710725
     
    733748            setGeometry(m_normalGeometry);
    734749
    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? */);
    737753
    738754            /* Maximize if needed */
     
    743759        {
    744760            /* Normalize to the optimal size */
    745             machineView()->normalizeGeometry(true /* adjust position? */);
     761            if (machineView())
     762                machineView()->normalizeGeometry(true /* adjust position? */);
    746763
    747764            /* Move newly created window to the screen center: */
     
    784801    {
    785802        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());
    788805        if (isMaximized())
    789806            strWindowPosition += QString(",%1").arg(VBoxDefs::GUI_LastWindowPosition_Max);
     
    796813    /* Stop LED-update timer: */
    797814    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.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette