VirtualBox

Ignore:
Timestamp:
Feb 25, 2010 1:53:19 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
58030
Message:

FE/Qt4: New running VM core: cumulative patch.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStateIndicator.h

    r26758 r26773  
    4949public slots:
    5050
    51     void setState (int aState);
    52     void setState (bool aState) { setState ((int) aState); }
     51    virtual void setState (int aState);
     52    virtual void setState (bool aState) { setState ((int) aState); }
    5353
    5454signals:
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r26758 r26773  
    2626#include "VBoxGlobal.h"
    2727#include "COMDefs.h"
     28#include "UIMachineDefs.h"
    2829#include "QIWithRetranslateUI.h"
    2930
     
    551552    }
    552553
     554public slots:
     555
     556    void setState(int iState)
     557    {
     558        if ((iState & UIMouseStateType_MouseAbsoluteDisabled) &&
     559            (iState & UIMouseStateType_MouseAbsolute) &&
     560            !(iState & UIMouseStateType_MouseCaptured))
     561        {
     562            QIStateIndicator::setState(4);
     563        }
     564        else
     565        {
     566            QIStateIndicator::setState(iState & (UIMouseStateType_MouseAbsolute | UIMouseStateType_MouseCaptured));
     567        }
     568    }
     569
    553570protected:
    554571    /* For compatibility reason we do it here, later this should be moved to
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r26754 r26773  
    243243};
    244244
    245 #if 0
     245#if 0 // TODO: Rework additions downloader logic!
    246246class UIAdditionsDownloader : public VBoxDownloaderWgt
    247247{
     
    369369                               UIActionsPool *pActionsPool,
    370370                               UIVisualStateType visualStateType)
    371     /* Initialize parent class: */
    372371    : QObject(pParent)
    373     /* Initialize protected members: */
    374     , m_pMachineWindowContainer(0)
    375     /* Initialize private members: */
    376372    , m_pSession(pSession)
    377373    , m_pActionsPool(pActionsPool)
    378374    , m_machineState(KMachineState_Null)
    379375    , m_visualStateType(visualStateType)
    380     /* Action groups: */
     376    , m_pMachineWindowWrapper(0)
    381377    , m_pRunningActions(0)
    382378    , m_pRunningOrPausedActions(0)
    383     /* Bool flags: */
    384     , m_bIsFirstTimeStarted(false)
    385     , m_bIsOpenViewFinished(false)
    386     , m_bIsGraphicsSupported(false)
    387     , m_bIsSeamlessSupported(false)
    388     , m_bIsAutoSaveMedia(true)
    389     , m_bIsPreventAutoClose(false)
     379    , m_fIsFirstTimeStarted(false)
     380    , m_fIsIgnoringRutimeMediums(false)
     381    , m_fIsAdditionsActive(false)
     382    , m_fIsGuestSupportsGraphics(false)
     383    , m_fIsGuestSupportsSeamless(false)
     384    , m_fIsMouseSupportsAbsolute(false)
     385    , m_fIsHostCursorNeeded(false)
     386    , m_fIsPreventAutoClose(false)
    390387{
    391388}
     
    399396}
    400397
     398CSession& UIMachineLogic::session()
     399{
     400    return m_pSession->session();
     401}
     402
    401403void UIMachineLogic::prepareConsoleConnections()
    402404{
     405    /* Machine state-change updater: */
    403406    connect(uisession(), SIGNAL(sigStateChange(KMachineState)), this, SLOT(sltMachineStateChanged(KMachineState)));
     407
     408    /* Guest additions state-change updater: */
    404409    connect(uisession(), SIGNAL(sigAdditionsStateChange()), this, SLOT(sltAdditionsStateChanged()));
     410
     411    /* Mouse capability state-change updater: */
     412    connect(uisession(), SIGNAL(sigMouseCapabilityChange(bool, bool)), this, SLOT(sltMouseCapabilityChanged(bool, bool)));
     413
     414    /* USB devices state-change updater: */
    405415    connect(uisession(), SIGNAL(sigUSBDeviceStateChange(const CUSBDevice &, bool, const CVirtualBoxErrorInfo &)),
    406416            this, SLOT(sltUSBDeviceStateChange(const CUSBDevice &, bool, const CVirtualBoxErrorInfo &)));
     417
     418    /* Runtime errors notifier: */
    407419    connect(uisession(), SIGNAL(sigRuntimeError(bool, const QString &, const QString &)),
    408420            this, SLOT(sltRuntimeError(bool, const QString &, const QString &)));
     
    423435    m_pRunningOrPausedActions->setExclusive(false);
    424436
    425     /* Move actions into first group: */
     437    /* Move actions into running actions group: */
    426438    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_Fullscreen));
    427439    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_Seamless));
     440    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize));
    428441    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Simple_AdjustWindow));
    429442    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Simple_TypeCAD));
     
    439452#endif
    440453
    441     /* Move actions into second group: */
    442     m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize));
     454    /* Move actions into running-n-paused actions group: */
    443455    m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Menu_MouseIntegration));
    444456    m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Toggle_MouseIntegration));
     
    460472void UIMachineLogic::prepareActionConnections()
    461473{
    462     /* "Machine" actions connections */
     474    /* "Machine" actions connections: */
    463475    connect(actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize), SIGNAL(toggled(bool)),
    464476            this, SLOT(sltToggleGuestAutoresize(bool)));
     
    486498            this, SLOT(sltClose()));
    487499
    488     /* "Devices" actions connections */
     500    /* "Devices" actions connections: */
    489501    connect(actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->menu(), SIGNAL(aboutToShow()),
    490502            this, SLOT(sltPrepareStorageMenu()));
     
    503515
    504516#ifdef VBOX_WITH_DEBUGGER_GUI
    505     /* "Debug" actions connections */
     517    /* "Debug" actions connections: */
    506518    connect(actionsPool()->action(UIActionIndex_Menu_Debug)->menu(), SIGNAL(aboutToShow()),
    507519            this, SLOT(sltPrepareDebugMenu()));
     
    566578        strSettings = machine.GetExtraData(VBoxDefs::GUI_FirstRun);
    567579        if (strSettings == "yes")
    568             m_bIsFirstTimeStarted = true;
     580            m_fIsFirstTimeStarted = true;
    569581
    570582        strSettings = machine.GetExtraData(VBoxDefs::GUI_SaveMountedAtRuntime);
    571583        if (strSettings == "no")
    572             m_bIsAutoSaveMedia = false;
     584            m_fIsIgnoringRutimeMediums = true;
    573585    }
    574586
     
    615627        }
    616628    }
     629
     630#if 0
     631    /* Dynamical property settings: */
     632    {
     633        /* Load dynamical properties: */
     634        m_machineState = uisession()->property("MachineLogic/MachineState").value<KMachineState>();
     635        m_fIsAdditionsActive = uisession()->property("MachineLogic/IsAdditionsActive").toBool();
     636        m_fIsGuestSupportsGraphics = uisession()->property("MachineLogic/IsGuestSupportsGraphics").toBool();
     637        m_fIsGuestSupportsSeamless = uisession()->property("MachineLogic/IsGuestSupportsSeamless").toBool();
     638        m_fIsMouseSupportsAbsolute = uisession()->property("MachineLogic/IsMouseSupportsAbsolute").toBool();
     639        m_fIsHostCursorNeeded = uisession()->property("MachineLogic/IsHostCursorNeeded").toBool();
     640
     641        /* Update relative things: */
     642        updateMachineState();
     643        updateAdditionsState();
     644        updateMouseCapability();
     645    }
     646#endif
    617647}
    618648
     
    632662        //machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide, mMiniToolBar->isAutoHide() ? "on" : "off");
    633663    }
    634 }
    635 
    636 CSession& UIMachineLogic::session()
    637 {
    638     return m_pSession->session();
    639 }
    640 
    641 void UIMachineLogic::sltMachineStateChanged(KMachineState newMachineState)
    642 {
    643     if (m_machineState != newMachineState)
    644     {
    645         /* Variable flags: */
    646         bool bIsRunning = newMachineState == KMachineState_Running ||
    647                           newMachineState == KMachineState_Teleporting ||
    648                           newMachineState == KMachineState_LiveSnapshotting;
    649         bool bIsRunningOrPaused = bIsRunning ||
    650                                   newMachineState == KMachineState_Paused;
    651 
    652         /* Update action groups: */
    653         m_pRunningActions->setEnabled(bIsRunning);
    654         m_pRunningOrPausedActions->setEnabled(bIsRunningOrPaused);
    655 
    656         /* Do we have GURU? */
    657         bool bIsGuruMeditation = false;
    658 
    659         switch (newMachineState)
    660         {
    661             case KMachineState_Stuck:
     664
     665#if 0
     666    /* Dynamical property settings: */
     667    {
     668        /* Save dynamical properties: */
     669        uisession()->setProperty("MachineLogic/MachineState", QVariant::fromValue(machineState()));
     670        uisession()->setProperty("MachineLogic/IsAdditionsActive", m_fIsAdditionsActive);
     671        uisession()->setProperty("MachineLogic/IsGuestSupportsGraphics", m_fIsGuestSupportsGraphics);
     672        uisession()->setProperty("MachineLogic/IsGuestSupportsSeamless", m_fIsGuestSupportsSeamless);
     673        uisession()->setProperty("MachineLogic/IsMouseSupportsAbsolute", m_fIsMouseSupportsAbsolute);
     674        uisession()->setProperty("MachineLogic/IsHostCursorNeeded", m_fIsHostCursorNeeded);
     675    }
     676#endif
     677}
     678
     679void UIMachineLogic::updateMachineState()
     680{
     681    /* State flags: */
     682    bool fIsRunning = machineState() == KMachineState_Running ||
     683                      machineState() == KMachineState_Teleporting ||
     684                      machineState() == KMachineState_LiveSnapshotting;
     685    bool fIsRunningOrPaused = fIsRunning ||
     686                              machineState() == KMachineState_Paused;
     687
     688    /* Update action groups: */
     689    m_pRunningActions->setEnabled(fIsRunning);
     690    m_pRunningOrPausedActions->setEnabled(fIsRunningOrPaused);
     691
     692    /* Do we have GURU? */
     693    bool fIsGuruMeditation = false;
     694
     695    switch (machineState())
     696    {
     697        case KMachineState_Stuck:
     698        {
     699            /* We will handle GURU later: */
     700            fIsGuruMeditation = true;
     701            break;
     702        }
     703        case KMachineState_Paused:
     704        {
     705            QAction *pPauseAction = actionsPool()->action(UIActionIndex_Toggle_Pause);
     706            if (!pPauseAction->isChecked())
    662707            {
    663                 bIsGuruMeditation = true;
    664                 break;
     708                /* Was paused from CSession side: */
     709                pPauseAction->blockSignals(true);
     710                pPauseAction->setChecked(true);
     711                pPauseAction->blockSignals(false);
    665712            }
    666             case KMachineState_Paused:
     713            break;
     714        }
     715        case KMachineState_Running:
     716        case KMachineState_Teleporting:
     717        case KMachineState_LiveSnapshotting:
     718        {
     719            QAction *pPauseAction = actionsPool()->action(UIActionIndex_Toggle_Pause);
     720            if (pPauseAction->isChecked())
    667721            {
    668                 /* Was paused from CMachine side? */
    669                 QAction *pPauseAction = actionsPool()->action(UIActionIndex_Toggle_Pause);
    670                 if (!pPauseAction->isChecked())
    671                 {
    672                     pPauseAction->blockSignals(true);
    673                     pPauseAction->setChecked(true);
    674                     pPauseAction->blockSignals(false);
    675                 }
    676                 break;
     722                /* Was resumed from CSession side: */
     723                pPauseAction->blockSignals(true);
     724                pPauseAction->setChecked(false);
     725                pPauseAction->blockSignals(false);
    677726            }
    678             case KMachineState_Running:
    679             case KMachineState_Teleporting:
    680             case KMachineState_LiveSnapshotting:
    681             {
    682                 /* Was started from CMachine side? */
    683                 QAction *pPauseAction = actionsPool()->action(UIActionIndex_Toggle_Pause);
    684                 if (isPaused() && pPauseAction->isChecked())
    685                 {
    686                     pPauseAction->blockSignals(true);
    687                     pPauseAction->setChecked(false);
    688                     pPauseAction->blockSignals(false);
    689                 }
    690                 break;
    691             }
     727            break;
     728        }
    692729#ifdef Q_WS_X11
    693             case KMachineState_Starting:
    694             case KMachineState_Restoring:
    695             case KMachineState_TeleportingIn:
    696             {
    697                 /* The keyboard handler may wish to do some release logging on startup.
    698                  * Tell it that the logger is now active. */
    699                 doXKeyboardLogging(QX11Info::display());
    700                 break;
    701             }
    702 #endif
    703             default:
    704                 break;
    705         }
    706 
    707         /* Now storing new state: */
    708         m_machineState = newMachineState;
    709 
    710         /* Close VM if was closed someway: */
    711         if (m_machineState == KMachineState_PoweredOff || m_machineState == KMachineState_Saved ||
    712             m_machineState == KMachineState_Teleported || m_machineState == KMachineState_Aborted)
    713         {
    714             /* VM has been powered off or saved or aborted, no matter internally or externally.
    715              * We must *safely* close the console window unless auto closure is disabled: */
    716             if (!m_bIsPreventAutoClose)
    717                 machineWindowWrapper()->sltTryClose();
    718         }
    719 
    720         /* Process GURU: */
    721         if (bIsGuruMeditation)
    722         {
    723             if (machineWindowWrapper()->machineView())
    724                 machineWindowWrapper()->machineView()->setIgnoreGuestResize(true);
    725 
    726             CConsole console = session().GetConsole();
    727             QString strLogFolder = console.GetMachine().GetLogFolder();
    728 
    729             /* Take the screenshot for debugging purposes and save it */
    730             QString strFileName = strLogFolder + "/VBox.png";
    731             CDisplay display = console.GetDisplay();
    732             QImage shot = QImage(display.GetWidth(), display.GetHeight(), QImage::Format_RGB32);
    733             display.TakeScreenShot(shot.bits(), shot.width(), shot.height());
    734             shot.save(QFile::encodeName(strFileName), "PNG");
    735 
    736             /* Warn the user about GURU: */
    737             if (vboxProblem().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder)))
    738             {
    739                 qApp->processEvents();
    740                 console.PowerDown();
    741                 if (!console.isOk())
    742                     vboxProblem().cannotStopMachine(console);
    743             }
    744         }
     730        case KMachineState_Starting:
     731        case KMachineState_Restoring:
     732        case KMachineState_TeleportingIn:
     733        {
     734            /* The keyboard handler may wish to do some release logging on startup.
     735             * Tell it that the logger is now active. */
     736            doXKeyboardLogging(QX11Info::display());
     737            break;
     738        }
     739#endif
     740        default:
     741            break;
     742    }
     743
     744    /* Close VM if was closed someway: */
     745    if (machineState() == KMachineState_PoweredOff || machineState() == KMachineState_Saved ||
     746        machineState() == KMachineState_Teleported || machineState() == KMachineState_Aborted)
     747    {
     748        /* VM has been powered off or saved or aborted, no matter internally or externally.
     749         * We must *safely* close the console window unless auto closure is disabled: */
     750        sltClose();
     751        return;
     752    }
     753
     754    /* Process GURU: */
     755    if (fIsGuruMeditation)
     756    {
     757        if (machineWindowWrapper()->machineView())
     758            machineWindowWrapper()->machineView()->setIgnoreGuestResize(true);
     759
     760        CConsole console = session().GetConsole();
     761        QString strLogFolder = console.GetMachine().GetLogFolder();
     762
     763        /* Take the screenshot for debugging purposes and save it */
     764        QString strFileName = strLogFolder + "/VBox.png";
     765        CDisplay display = console.GetDisplay();
     766        QImage shot = QImage(display.GetWidth(), display.GetHeight(), QImage::Format_RGB32);
     767        display.TakeScreenShot(shot.bits(), shot.width(), shot.height());
     768        shot.save(QFile::encodeName(strFileName), "PNG");
     769
     770        /* Warn the user about GURU: */
     771        if (vboxProblem().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder)))
     772        {
     773            qApp->processEvents();
     774            console.PowerDown();
     775            if (!console.isOk())
     776                vboxProblem().cannotStopMachine(console);
     777        }
     778    }
    745779
    746780#ifdef Q_WS_MAC
    747         /* Update Dock Overlay: */
    748         if (   machineWindowWrapper()
    749             && machineWindowWrapper()->machineView())
    750             machineWindowWrapper()->machineView()->updateDockOverlay();
     781    /* Update Dock Overlay: */
     782    if (machineWindowWrapper() && machineWindowWrapper()->machineView())
     783        machineWindowWrapper()->machineView()->updateDockOverlay();
    751784#endif /* Q_WS_MAC */
    752     }
    753 }
    754 
    755 void UIMachineLogic::sltAdditionsStateChanged()
    756 {
    757     /* Get console guest: */
     785}
     786
     787void UIMachineLogic::updateAdditionsState()
     788{
     789    /* Update action groups: */
     790    actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->setEnabled(m_fIsAdditionsActive && m_fIsGuestSupportsGraphics);
     791    actionsPool()->action(UIActionIndex_Toggle_Seamless)->setEnabled(m_fIsAdditionsActive && m_fIsGuestSupportsGraphics && m_fIsGuestSupportsSeamless);
     792
     793#if 0 // TODO: Enter seamless if necessary!
     794    /* If seamless mode should be enabled then check if it is enabled currently and re-enable it if open-view procedure is finished */
     795    if (actionsPool()->action(UIActionIndex_Toggle_Seamless)->isChecked() &&
     796        m_fIsAdditionsActive && m_fIsGuestSupportsGraphics && m_fIsGuestSupportsSeamless)
     797        toggleFullscreenMode(true, true);
     798#endif
     799
     800    /* Check the GA version only in case of additions are active: */
     801    if (!m_fIsAdditionsActive)
     802        return;
     803
     804    /* Check the Guest Additions version and warn the user about possible compatibility issues in case if the installed version is outdated. */
    758805    CGuest guest = session().GetConsole().GetGuest();
    759 
    760     /* Variable flags: */
    761     bool bIsActive = guest.GetAdditionsActive();
    762     bool bIsGraphicsSupported = guest.GetSupportsGraphics();
    763     bool bIsSeamlessSupported = guest.GetSupportsSeamless();
    764 
    765     /* Update action groups: */
    766     actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->setEnabled(bIsActive && bIsGraphicsSupported);
    767     actionsPool()->action(UIActionIndex_Toggle_Seamless)->setEnabled(bIsActive && bIsGraphicsSupported && bIsSeamlessSupported);
    768 
    769     /* Store new values: */
    770     m_bIsSeamlessSupported = bIsSeamlessSupported;
    771     m_bIsGraphicsSupported = bIsGraphicsSupported;
    772 
    773 #if 0 // TODO: Re-activate seamless if necessary!
    774     /* If seamless mode should be enabled then check if it is enabled currently and re-enable it if open-view procedure is finished */
    775     if ((m_bIsSeamlessSupported != bIsSeamlessSupported) || (m_bIsGraphicsSupported != bIsGraphicsSupported))
    776     {
    777         if (actionsPool()->action(UIActionIndex_Toggle_Seamless)->isChecked() && m_bIsOpenViewFinished && bIsGraphicsSupported && bIsSeamlessSupported)
    778             toggleFullscreenMode(true, true);
    779     }
    780 #endif
    781 
    782     /* Check the GA version only in case of additions are active: */
    783     if (!bIsActive)
    784         return;
    785 
    786     /* Check the Guest Additions version and warn the user about possible compatibility issues in case if the installed version is outdated. */
    787806    QString strVersion = guest.GetAdditionsVersion();
    788807    uint uVersion = strVersion.toUInt();
     
    804823}
    805824
     825void UIMachineLogic::updateMouseCapability()
     826{
     827    /* Update related things: */
     828    QAction *pAction = actionsPool()->action(UIActionIndex_Toggle_MouseIntegration);
     829    pAction->setEnabled(m_fIsMouseSupportsAbsolute && !m_fIsHostCursorNeeded);
     830    pAction->setChecked(m_fIsHostCursorNeeded || pAction->isChecked());
     831}
     832
     833void UIMachineLogic::sltMachineStateChanged(KMachineState state)
     834{
     835    /* Check if something had changed: */
     836    if (m_machineState != state)
     837    {
     838        /* Store new data: */
     839        m_machineState = state;
     840
     841        /* Update machine state: */
     842        updateMachineState();
     843    }
     844}
     845
     846void UIMachineLogic::sltAdditionsStateChanged()
     847{
     848    /* Get our guest: */
     849    CGuest guest = session().GetConsole().GetGuest();
     850
     851    /* Variable flags: */
     852    bool fIsAdditionsActive = guest.GetAdditionsActive();
     853    bool fIsGuestSupportsGraphics = guest.GetSupportsGraphics();
     854    bool fIsGuestSupportsSeamless = guest.GetSupportsSeamless();
     855
     856    /* Check if something had changed: */
     857    if (m_fIsAdditionsActive != fIsAdditionsActive ||
     858        m_fIsGuestSupportsGraphics != fIsGuestSupportsGraphics ||
     859        m_fIsGuestSupportsSeamless != fIsGuestSupportsSeamless)
     860    {
     861        /* Store new data: */
     862        m_fIsAdditionsActive = fIsAdditionsActive;
     863        m_fIsGuestSupportsGraphics = fIsGuestSupportsGraphics;
     864        m_fIsGuestSupportsSeamless = fIsGuestSupportsSeamless;
     865
     866        /* Update additions state: */
     867        updateAdditionsState();
     868    }
     869}
     870
     871void UIMachineLogic::sltMouseCapabilityChanged(bool fIsSupportsAbsolute, bool fIsHostCursorNeeded)
     872{
     873    /* Check if something is changed: */
     874    if (m_fIsMouseSupportsAbsolute != fIsSupportsAbsolute || m_fIsHostCursorNeeded != fIsHostCursorNeeded)
     875    {
     876        /* Store new data: */
     877        m_fIsMouseSupportsAbsolute = fIsSupportsAbsolute;
     878        m_fIsHostCursorNeeded = fIsHostCursorNeeded;
     879
     880        /* Update mouse capability: */
     881        updateMouseCapability();
     882    }
     883}
     884
    806885void UIMachineLogic::sltUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error)
    807886{
     
    822901}
    823902
    824 void UIMachineLogic::sltToggleGuestAutoresize(bool /* bEnabled */)
     903void UIMachineLogic::sltToggleGuestAutoresize(bool bEnabled)
    825904{
    826905    /* Do not process if window or view is missing! */
     
    828907        return;
    829908
    830     // TODO: Enable/Disable guest-autoresize for machine view! */
     909    machineWindowWrapper()->machineView()->setGuestAutoresizeEnabled(bEnabled);
    831910}
    832911
     
    887966
    888967    /* Remember the paused state. */
    889     bool bWasPaused = m_machineState == KMachineState_Paused;
     968    bool bWasPaused = machineState() == KMachineState_Paused;
    890969    if (!bWasPaused)
    891970    {
     
    9781057
    9791058    /* Close machine window: */
    980     machineWindowWrapper()->machineWindow()->close();
     1059    machineWindowWrapper()->sltTryClose();
    9811060}
    9821061
     
    12301309
    12311310    /* Save medium mounted at runtime */
    1232     if (wasMounted && m_bIsAutoSaveMedia)
     1311    if (wasMounted && !m_fIsIgnoringRutimeMediums)
    12331312    {
    12341313        machine.SaveSettings();
     
    14401519}
    14411520#endif
    1442 
    1443 void UIMachineLogic::sltMouseStateChanged(int iState)
    1444 {
    1445     actionsPool()->action(UIActionIndex_Toggle_MouseIntegration)->setEnabled(iState & UIMouseStateType_MouseAbsolute);
    1446 }
    14471521
    14481522bool UIMachineLogic::pause(bool bOn)
     
    15451619
    15461620        /* Save medium mounted at runtime */
    1547         if (isMounted && m_bIsAutoSaveMedia)
     1621        if (isMounted && !m_fIsIgnoringRutimeMediums)
    15481622        {
    15491623            machine.SaveSettings();
     
    17531827        mIsFullscreen = aOn;
    17541828        mVmAdjustWindowAction->setEnabled (!aOn);
    1755         mVmSeamlessAction->setEnabled (!aOn && m_bIsSeamlessSupported && m_bIsGraphicsSupported);
     1829        mVmSeamlessAction->setEnabled (!aOn && m_fIsGuestSupportsSeamless && m_fIsGuestSupportsGraphics);
    17561830    }
    17571831
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r26754 r26773  
    5555    UIActionsPool* actionsPool() { return m_pActionsPool; }
    5656    UIVisualStateType visualStateType() const { return m_visualStateType; }
    57     UIMachineWindow* machineWindowWrapper() { return m_pMachineWindowContainer; }
     57    UIMachineWindow* machineWindowWrapper() { return m_pMachineWindowWrapper; }
    5858    KMachineState machineState() const { return m_machineState; }
    59     bool isPaused() const { return m_machineState == KMachineState_Paused ||
    60                             m_machineState == KMachineState_TeleportingPausedVM; }
     59    bool isPaused() const { return machineState() == KMachineState_Paused ||
     60                                   machineState() == KMachineState_TeleportingPausedVM; }
     61    bool isPreventAutoClose() const { return m_fIsPreventAutoClose; }
     62
     63    /* Public setters: */
     64    void setPreventAutoClose(bool fIsPreventAutoClose) { m_fIsPreventAutoClose = fIsPreventAutoClose; }
    6165
    6266protected:
     
    6973    virtual ~UIMachineLogic();
    7074
     75    /* Protected getters: */
     76    CSession& session();
     77    bool isFirstTimeStarted() const { return m_fIsFirstTimeStarted; }
     78
     79    /* Protected setters: */
     80    void setMachineWindowWrapper(UIMachineWindow *pMachineWindowWrapper) { m_pMachineWindowWrapper = pMachineWindowWrapper; }
     81
     82    /* Console related routines: */
     83    bool pause() { return pause(true); }
     84    bool unpause() { return pause(false); }
     85
    7186    /* Prepare helpers: */
    7287    virtual void prepareConsoleConnections();
     
    7893    /* Cleanup helpers: */
    7994    virtual void saveLogicSettings();
    80     //virtual void cleanupRequiredFeatures();
    81     //virtual void cleanupActionConnections();
    82     //virtual void cleanupActionGroups();
    83     //virtual void cleanupConsoleConnections();
    84 
    85     /* Protected getters: */
    86     CSession& session();
    87     bool isFirstTimeStarted() const { return m_bIsFirstTimeStarted; }
    88     bool isPreventAutoClose() const { return m_bIsPreventAutoClose; }
    89 
    90     /* Pretected setters: */
    91     void setMachineState(KMachineState state) { m_machineState = state; }
    92     void setPreventAutoClose(bool bIsPreventAutoClose) { m_bIsPreventAutoClose = bIsPreventAutoClose; }
    93     void setOpenViewFinished(bool bIsOpenViewFinished) { m_bIsOpenViewFinished = bIsOpenViewFinished; }
    94 
    95     /* Console related routines: */
    96     bool pause() { return pause(true); }
    97     bool unpause() { return pause(false); }
    98 
    99     /* Protected variables: */
    100     UIMachineWindow *m_pMachineWindowContainer;
     95    virtual void cleanupRequiredFeatures() {}
     96    virtual void cleanupActionConnections() {}
     97    virtual void cleanupActionGroups() {}
     98    virtual void cleanupConsoleConnections() {}
     99
     100    /* Update helpers: */
     101    virtual void updateMachineState();
     102    virtual void updateAdditionsState();
     103    virtual void updateMouseCapability();
     104
     105protected slots:
     106
     107    /* Console callback handlers: */
     108    virtual void sltMachineStateChanged(KMachineState machineState);
     109    virtual void sltAdditionsStateChanged();
     110    virtual void sltMouseCapabilityChanged(bool fIsSupportsAbsolute, bool fNeedsHostCursor);
     111    virtual void sltUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error);
     112    virtual void sltRuntimeError(bool bIsFatal, const QString &strErrorId, const QString &strMessage);
    101113
    102114private slots:
    103 
    104     /* Console callback handlers: */
    105     void sltMachineStateChanged(KMachineState newMachineState);
    106     void sltAdditionsStateChanged();
    107     void sltUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error);
    108     void sltRuntimeError(bool bIsFatal, const QString &strErrorId, const QString &strMessage);
    109115
    110116    /* "Machine" menu funtionality */
     
    140146#endif
    141147
    142     /* Machine view handlers: */
    143     void sltMouseStateChanged(int iState);
    144 
    145148private:
    146149
     
    157160    KMachineState m_machineState;
    158161    UIVisualStateType m_visualStateType;
     162    UIMachineWindow *m_pMachineWindowWrapper;
    159163
    160164    QActionGroup *m_pRunningActions;
    161165    QActionGroup *m_pRunningOrPausedActions;
    162166
    163     bool m_bIsFirstTimeStarted : 1;
    164     bool m_bIsOpenViewFinished : 1;
    165     bool m_bIsGraphicsSupported : 1;
    166     bool m_bIsSeamlessSupported : 1;
    167     bool m_bIsAutoSaveMedia : 1;
    168     bool m_bIsPreventAutoClose : 1;
    169 
    170     /* Friend classes: */
    171     friend class UIMachineWindow;
     167    bool m_fIsFirstTimeStarted : 1;
     168    bool m_fIsIgnoringRutimeMediums : 1;
     169    bool m_fIsAdditionsActive : 1;
     170    bool m_fIsGuestSupportsGraphics : 1;
     171    bool m_fIsGuestSupportsSeamless : 1;
     172    bool m_fIsMouseSupportsAbsolute : 1;
     173    bool m_fIsHostCursorNeeded : 1;
     174    bool m_fIsPreventAutoClose : 1;
    172175
    173176#ifdef VBOX_WITH_DEBUGGER_GUI
     
    182185#endif
    183186
     187    /* Friend classes: */
     188    friend class UIMachineWindow;
     189
    184190#if 0 // TODO: Where to move that?
    185191# ifdef Q_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r26754 r26773  
    8585#endif /* defined (Q_WS_MAC) */
    8686
    87 /** Menu activation event */
     87/* Menu activation event */
    8888class ActivateMenuEvent : public QEvent
    8989{
    9090public:
    9191
    92     ActivateMenuEvent (QAction *aData)
     92    ActivateMenuEvent (QAction *pAction)
    9393        : QEvent((QEvent::Type)VBoxDefs::ActivateMenuEventType)
    94         , mAction(aData) {}
    95     QAction *action() const { return mAction; }
     94        , m_pAction(pAction) {}
     95    QAction* action() const { return m_pAction; }
    9696
    9797private:
    9898
    99     QAction *mAction;
     99    QAction *m_pAction;
    100100};
    101101
     
    106106    VBoxViewport(QWidget *pParent) : QWidget(pParent)
    107107    {
    108         /* No need for background drawing */
     108        /* No need for background drawing: */
    109109        setAttribute(Qt::WA_OpaquePaintEvent);
    110110    }
     
    160160    }
    161161    return view;
     162}
     163
     164int UIMachineView::keyboardState() const
     165{
     166    return (m_bIsKeyboardCaptured ? UIViewStateType_KeyboardCaptured : 0) |
     167           (m_bIsHostkeyPressed ? UIViewStateType_HostKeyPressed : 0);
     168}
     169
     170int UIMachineView::mouseState() const
     171{
     172    return (m_bIsMouseCaptured ? UIMouseStateType_MouseCaptured : 0) |
     173           (m_bIsMouseAbsolute ? UIMouseStateType_MouseAbsolute : 0) |
     174           (m_bIsMouseIntegrated ? 0 : UIMouseStateType_MouseAbsoluteDisabled);
    162175}
    163176
     
    200213                            )
    201214    : QAbstractScrollArea(pMachineWindow->machineWindow())
    202     /* Private members: */
    203215    , m_pMachineWindow(pMachineWindow)
    204216    , m_console(pMachineWindow->machineLogic()->uisession()->session().GetConsole())
     
    218230    , m_bIsMouseAbsolute(false)
    219231    , m_bIsMouseIntegrated(true)
     232    , m_fIsHideHostPointer(true)
    220233    , m_bIsHostkeyPressed(false)
    221234    , m_bIsHostkeyAlone (false)
     235    , m_bIsHostkeyInCapture(false)
    222236    , m_bIsGuestSupportsGraphics(false)
    223237    , m_bIsMachineWindowResizeIgnored(true)
    224238    , m_bIsFrameBufferResizeIgnored(false)
    225239    , m_bIsGuestResizeIgnored(false)
    226     , m_numLock(false)
    227     , m_scrollLock(false)
    228     , m_capsLock(false)
    229     , m_fPassCAD (false)
    230     , m_fHideHostPointer(true)
     240    , m_fNumLock(false)
     241    , m_fCapsLock(false)
     242    , m_fScrollLock(false)
     243    , m_fPassCAD(false)
    231244#ifdef VBOX_WITH_VIDEOHWACCEL
    232245    , m_fAccelerate2DVideo(bAccelerate2DVideo)
     
    239252    , m_darwinEventHandlerRef(NULL)
    240253# endif /* !QT_MAC_USE_COCOA */
    241     , m_darwinKeyModifiers (0)
     254    , m_darwinKeyModifiers(0)
    242255    , m_fKeyboardGrabbed (false)
    243     , mDockIconEnabled (true)
     256    , mDockIconEnabled(true)
    244257#endif
    245258    , m_desktopGeometryType(DesktopGeo_Invalid)
     
    255268{
    256269#ifdef VBOX_WITH_DEBUGGER
    257     /** @todo figure out a more proper fix. */
    258     /* HACK ALERT! Really ugly workaround for the resizing to 9x1 done
    259      *             by DevVGA if provoked before power on. */
     270    // TODO: Fix all DEBUGGER stuff!
     271    /* HACK ALERT! Really ugly workaround for the resizing to 9x1 done by DevVGA if provoked before power on. */
    260272    QSize fb(m_pFrameBuffer->width(), m_pFrameBuffer->height());
    261273    if ((fb.width() < 16 || fb.height() < 16) && (vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled()))
     
    305317        case DesktopGeo_Automatic:
    306318            geometry = QRect(0, 0,
    307                             qMax(m_desktopGeometry.width(), m_storedConsoleSize.width()),
    308                             qMax(m_desktopGeometry.height(), m_storedConsoleSize.height()));
     319                             qMax(m_desktopGeometry.width(), m_storedConsoleSize.width()),
     320                             qMax(m_desktopGeometry.height(), m_storedConsoleSize.height()));
    309321            break;
    310322        case DesktopGeo_Any:
     
    339351         * (or at least its width and height) is a constant. */
    340352        m_desktopGeometry = QRect(0, 0, desktop.width() - frame.width() + window.width(),
    341                                        desktop.height() - frame.height() + window.height());
    342     }
    343 }
    344 
    345 void UIMachineView::setDesktopGeometry(DesktopGeo aGeo, int aWidth, int aHeight)
    346 {
    347     switch (aGeo)
     353                                        desktop.height() - frame.height() + window.height());
     354    }
     355}
     356
     357void UIMachineView::setDesktopGeometry(DesktopGeo geometry, int aWidth, int aHeight)
     358{
     359    switch (geometry)
    348360    {
    349361        case DesktopGeo_Fixed:
     
    365377            break;
    366378        default:
    367             AssertMsgFailed(("Invalid desktop geometry type %d\n", aGeo));
     379            AssertMsgFailed(("Invalid desktop geometry type %d\n", geometry));
    368380            m_desktopGeometryType = DesktopGeo_Invalid;
    369381    }
     
    476488{
    477489    /* Prepare view frame: */
    478     setFrameStyle(QFrame::NoFrame);
     490    //setFrameStyle(QFrame::NoFrame);
    479491
    480492    /* Pressed keys: */
     
    573585void UIMachineView::prepareConsoleConnections()
    574586{
     587    /* UISession notifier: */
    575588    UISession *sender = machineWindowWrapper()->machineLogic()->uisession();
     589
     590    /* Machine state-change updater: */
     591    connect(sender, SIGNAL(sigStateChange(KMachineState)), this, SLOT(sltMachineStateChanged(KMachineState)));
     592
     593    /* Guest additions state-change updater: */
     594    connect(sender, SIGNAL(sigAdditionsStateChange()), this, SLOT(sltAdditionsStateChanged()));
     595
     596    /* Keyboard LEDs state-change updater: */
     597    connect(sender, SIGNAL(sigKeyboardLedsChange(bool, bool, bool)), this, SLOT(sltKeyboardLedsChanged(bool, bool, bool)));
     598
     599    /* Mouse pointer shape state-change updater: */
    576600    connect(sender, SIGNAL(sigMousePointerShapeChange(bool, bool, uint, uint, uint, uint, const uchar *)),
    577             this, SLOT(sltMousePointerShapeChange(bool, bool, uint, uint, uint, uint, const uchar *)));
    578     connect(sender, SIGNAL(sigMouseCapabilityChange(bool, bool)), this, SLOT(sltMouseCapabilityChange(bool, bool)));
    579     connect(sender, SIGNAL(sigKeyboardLedsChange(bool, bool, bool)), this, SLOT(sltKeyboardLedsChange(bool, bool, bool)));
    580     connect(sender, SIGNAL(sigStateChange(KMachineState)), this, SLOT(sltStateChange(KMachineState)));
    581     connect(sender, SIGNAL(sigAdditionsStateChange()), this, SLOT(sltAdditionsStateChange()));
     601            this, SLOT(sltMousePointerShapeChanged(bool, bool, uint, uint, uint, uint, const uchar *)));
     602
     603    /* Mouse capability state-change updater: */
     604    connect(sender, SIGNAL(sigMouseCapabilityChange(bool, bool)), this, SLOT(sltMouseCapabilityChanged(bool, bool)));
    582605}
    583606
     
    599622            setDesktopGeometry(DesktopGeo_Fixed, width, height);
    600623        }
    601         connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(doResizeDesktop(int)));
     624        connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(sltDesktopResized()));
    602625
    603626#ifdef Q_WS_X11
     
    614637            m_fPassCAD = true;
    615638    }
     639
     640#if 0
     641    /* Dynamical property settings: */
     642    {
     643        /* Get loader: */
     644        UISession *loader = machineWindowWrapper()->machineLogic()->uisession();
     645
     646        /* Load dynamical properties: */
     647        m_machineState = loader->property("MachineView/MachineState").value<KMachineState>();
     648        m_uNumLockAdaptionCnt = loader->property("MachineView/NumLockAdaptionCnt").toUInt();
     649        m_uCapsLockAdaptionCnt = loader->property("MachineView/CapsLockAdaptionCnt").toUInt();
     650        m_bIsAutoCaptureDisabled = loader->property("MachineView/IsAutoCaptureDisabled").toBool();
     651        m_bIsKeyboardCaptured = loader->property("MachineView/IsKeyboardCaptured").toBool();
     652        m_bIsMouseCaptured = loader->property("MachineView/IsMouseCaptured").toBool();
     653        m_bIsMouseAbsolute = loader->property("MachineView/IsMouseAbsolute").toBool();
     654        m_bIsMouseIntegrated = loader->property("MachineView/IsMouseIntegrated").toBool();
     655        m_fIsHideHostPointer = loader->property("MachineView/IsHideHostPointer").toBool();
     656        m_bIsHostkeyInCapture = loader->property("MachineView/IsHostkeyInCapture").toBool();
     657        m_bIsGuestSupportsGraphics = loader->property("MachineView/IsGuestSupportsGraphics").toBool();
     658        m_fNumLock = loader->property("MachineView/IsNumLock").toBool();
     659        m_fCapsLock = loader->property("MachineView/IsCapsLock").toBool();
     660        m_fScrollLock = loader->property("MachineView/IsScrollLock").toBool();
     661
     662        /* Update related things: */
     663        updateMachineState();
     664        updateAdditionsState();
     665        updateMousePointerShape();
     666        updateMouseCapability();
     667    }
     668#endif
     669}
     670
     671void UIMachineView::saveMachineViewSettings()
     672{
     673#if 0
     674    /* Dynamical property settings: */
     675    {
     676        /* Get saver: */
     677        UISession *saver = machineWindowWrapper()->machineLogic()->uisession();
     678
     679        /* Save dynamical properties: */
     680        saver->setProperty("MachineView/MachineState", QVariant::fromValue(machineState()));
     681        saver->setProperty("MachineView/NumLockAdaptionCnt", m_uNumLockAdaptionCnt);
     682        saver->setProperty("MachineView/CapsLockAdaptionCnt", m_uCapsLockAdaptionCnt);
     683        saver->setProperty("MachineView/IsAutoCaptureDisabled", m_bIsAutoCaptureDisabled);
     684        saver->setProperty("MachineView/IsKeyboardCaptured", m_bIsKeyboardCaptured);
     685        saver->setProperty("MachineView/IsMouseCaptured", m_bIsMouseCaptured);
     686        saver->setProperty("MachineView/IsMouseAbsolute", m_bIsMouseAbsolute);
     687        saver->setProperty("MachineView/IsMouseIntegrated", m_bIsMouseIntegrated);
     688        saver->setProperty("MachineView/IsHideHostPointer", m_fIsHideHostPointer);
     689        saver->setProperty("MachineView/IsHostkeyInCapture", m_bIsHostkeyInCapture);
     690        saver->setProperty("MachineView/IsGuestSupportsGraphics", m_bIsGuestSupportsGraphics);
     691        saver->setProperty("MachineView/IsNumLock", m_fNumLock);
     692        saver->setProperty("MachineView/IsCapsLock", m_fCapsLock);
     693        saver->setProperty("MachineView/IsScrollLock", m_fScrollLock);
     694    }
     695#endif
    616696}
    617697
     
    647727void UIMachineView::cleanupFrameBuffer()
    648728{
    649     /* Cleanup: */
    650729    if (m_pFrameBuffer)
    651730    {
     
    659738}
    660739
    661 void UIMachineView::sltMousePointerShapeChange(bool fIsVisible, bool fHasAlpha,
    662                                                uint uXHot, uint uYHot, uint uWidth, uint uHeight,
    663                                                const uchar *pShapeData)
    664 {
    665     if (m_bIsMouseAbsolute)
    666     {
    667         /* Do we have new shape data? */
    668         if (pShapeData)
    669             setPointerShape(pShapeData, fHasAlpha, uXHot, uYHot, uWidth, uHeight);
    670 
    671         /* Should we hide/show pointer? */
    672         if (fIsVisible)
    673             viewport()->setCursor(m_lastCursor);
    674         else
    675             viewport()->setCursor(Qt::BlankCursor);
    676     }
    677     m_fHideHostPointer = !fIsVisible;
    678 }
    679 
    680 void UIMachineView::sltMouseCapabilityChange(bool bIsSupportsAbsolute, bool bNeedsHostCursor)
    681 {
    682     if (m_bIsMouseAbsolute != bIsSupportsAbsolute)
    683     {
    684         m_bIsMouseAbsolute = bIsSupportsAbsolute;
    685         /* Correct the mouse capture state and reset the cursor to the default shape if necessary: */
    686         if (m_bIsMouseAbsolute)
    687         {
    688             CMouse mouse = m_console.GetMouse();
    689             mouse.PutMouseEventAbsolute(-1, -1, 0, 0 /* Horizontal wheel */, 0);
    690             captureMouse(false, false);
    691         }
    692         else
    693             viewport()->unsetCursor();
    694         emitMouseStateChanged();
    695         vboxProblem().remindAboutMouseIntegration(m_bIsMouseAbsolute);
    696     }
    697     if (bNeedsHostCursor)
    698         setMouseIntegrationLocked(false);
    699     else
    700         setMouseIntegrationLocked(true);
    701 }
    702 
    703 void UIMachineView::sltKeyboardLedsChange(bool bNumLock, bool bCapsLock, bool bScrollLock)
    704 {
    705     if (bNumLock != m_numLock)
    706         m_uNumLockAdaptionCnt = 2;
    707     if (bCapsLock != m_capsLock)
    708         m_uCapsLockAdaptionCnt = 2;
    709     m_numLock    = bNumLock;
    710     m_capsLock   = bCapsLock;
    711     m_scrollLock = bScrollLock;
    712 }
    713 
    714 void UIMachineView::sltStateChange(KMachineState state)
    715 {
    716     switch (state)
     740void UIMachineView::updateMachineState()
     741{
     742    switch (machineState())
    717743    {
    718744        case KMachineState_Paused:
     
    720746        {
    721747            if (mode() != VBoxDefs::TimerMode &&  m_pFrameBuffer &&
    722                 (state != KMachineState_TeleportingPausedVM || m_machineState != KMachineState_Teleporting))
     748                (machineState() != KMachineState_TeleportingPausedVM || machineState() != KMachineState_Teleporting))
    723749            {
    724750                /* Take a screen snapshot. Note that TakeScreenShot() always needs a 32bpp image: */
     
    746772        case KMachineState_Running:
    747773        {
    748             if (m_machineState == KMachineState_Paused || m_machineState == KMachineState_TeleportingPausedVM)
     774            if (machineState() == KMachineState_Paused || machineState() == KMachineState_TeleportingPausedVM)
    749775            {
    750776                if (mode() != VBoxDefs::TimerMode && m_pFrameBuffer)
     
    766792            break;
    767793    }
    768 
    769     m_machineState = state;
    770 }
    771 
    772 void UIMachineView::sltAdditionsStateChange()
    773 {
    774     CGuest guest = console().GetGuest();
    775     bool fIsGuestSupportsGraphics = guest.GetSupportsGraphics();
     794}
     795
     796void UIMachineView::updateAdditionsState()
     797{
     798    /* Check if we should restrict minimum size: */
     799    maybeRestrictMinimumSize();
    776800
    777801#if 0 // TODO: Do we need this?
     
    779803        (machineWindowWrapper()->isTrueSeamless() || machineWindowWrapper()->isTrueFullscreen()))
    780804        mDoResize = true;
    781 #endif
    782     m_bIsGuestSupportsGraphics = fIsGuestSupportsGraphics;
    783 
    784     maybeRestrictMinimumSize();
    785 
    786 #if 0 // TODO: Do we need this?
    787805    /* This will only be acted upon if mDoResize is true: */
    788     doResizeHint();
    789 #endif
     806    sltPerformGuestResize();
     807#endif
     808}
     809
     810void UIMachineView::updateMousePointerShape()
     811{
     812    if (m_bIsMouseAbsolute)
     813    {
     814        /* Should we hide/show pointer? */
     815        if (m_fIsHideHostPointer)
     816            viewport()->setCursor(Qt::BlankCursor);
     817        else
     818            viewport()->setCursor(m_lastCursor);
     819    }
     820}
     821
     822void UIMachineView::updateMouseCapability()
     823{
     824    /* Correct the mouse capture state and reset the cursor to the default shape if necessary: */
     825    if (m_bIsMouseAbsolute)
     826    {
     827        CMouse mouse = m_console.GetMouse();
     828        mouse.PutMouseEventAbsolute(-1, -1, 0, 0 /* Horizontal wheel */, 0);
     829        captureMouse(false, false);
     830    }
     831    else
     832        viewport()->unsetCursor();
     833
     834    /* Notify user about mouse integration state: */
     835    vboxProblem().remindAboutMouseIntegration(m_bIsMouseAbsolute);
     836
     837    /* Notify all watchers: */
     838    emitMouseStateChanged();
     839}
     840
     841void UIMachineView::sltMachineStateChanged(KMachineState state)
     842{
     843    /* Check if something had changed: */
     844    if (m_machineState != state)
     845    {
     846        /* Set new data: */
     847        m_machineState = state;
     848
     849        /* Update depending things: */
     850        updateMachineState();
     851    }
     852}
     853
     854void UIMachineView::sltAdditionsStateChanged()
     855{
     856    /* Get new values: */
     857    CGuest guest = console().GetGuest();
     858    bool bIsGuestSupportsGraphics = guest.GetSupportsGraphics();
     859
     860    /* Check if something had changed: */
     861    if (m_bIsGuestSupportsGraphics != bIsGuestSupportsGraphics)
     862    {
     863        /* Get new data: */
     864        m_bIsGuestSupportsGraphics = bIsGuestSupportsGraphics;
     865
     866        /* Update depending things: */
     867        updateAdditionsState();
     868    }
     869}
     870
     871void UIMachineView::sltKeyboardLedsChanged(bool bNumLock, bool bCapsLock, bool bScrollLock)
     872{
     873    /* Update num lock status: */
     874    if (m_fNumLock != bNumLock)
     875    {
     876        m_fNumLock = bNumLock;
     877        m_uNumLockAdaptionCnt = 2;
     878    }
     879
     880    /* Update caps lock status: */
     881    if (m_fCapsLock != bCapsLock)
     882    {
     883        m_fCapsLock = bCapsLock;
     884        m_uCapsLockAdaptionCnt = 2;
     885    }
     886
     887    /* Update scroll lock status: */
     888    if (m_fScrollLock != bScrollLock)
     889        m_fScrollLock = bScrollLock;
     890}
     891
     892void UIMachineView::sltMousePointerShapeChanged(bool fIsVisible, bool fHasAlpha,
     893                                                uint uXHot, uint uYHot, uint uWidth, uint uHeight,
     894                                                const uchar *pShapeData)
     895{
     896    /* Should we show cursor anyway? */
     897    m_fIsHideHostPointer = !fIsVisible;
     898
     899    /* Should we cache shape data? */
     900    if (pShapeData)
     901        setPointerShape(pShapeData, fHasAlpha, uXHot, uYHot, uWidth, uHeight);
     902
     903    /* Perform cursor update: */
     904    updateMousePointerShape();
     905}
     906
     907void UIMachineView::sltMouseCapabilityChanged(bool bIsSupportsAbsolute, bool /* bNeedsHostCursor */)
     908{
     909    /* Check if something had changed: */
     910    if (m_bIsMouseAbsolute != bIsSupportsAbsolute)
     911    {
     912        /* Get new data: */
     913        m_bIsMouseAbsolute = bIsSupportsAbsolute;
     914
     915        /* Update depending things: */
     916        updateMouseCapability();
     917    }
     918}
     919
     920/* If the desktop geometry is set automatically, this will update it: */
     921void UIMachineView::sltDesktopResized()
     922{
     923    calculateDesktopGeometry();
    790924}
    791925
     
    9271061            calculateDesktopGeometry();
    9281062
    929             /* Enable frame-buffer resize watching only now: */
     1063            /* Enable frame-buffer resize watching: */
    9301064            if (m_bIsFrameBufferResizeIgnored)
    9311065                m_bIsFrameBufferResizeIgnored = false;
     
    12431377                mDoResize = isGuestSupportsGraphics() || machineWindowWrapper()->isTrueFullscreen();
    12441378                if (!m_bIsMachineWindowResizeIgnored && isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled)
    1245                     QTimer::singleShot(300, this, SLOT(doResizeHint()));
     1379                    QTimer::singleShot(300, this, SLOT(sltPerformGuestResize()));
    12461380                break;
    12471381            }
     
    14691603    {
    14701604        /* Currently this is used in winLowKeyboardEvent() only: */
    1471         m_bHostkeyInCapture = m_bIsKeyboardCaptured;
     1605        m_bIsHostkeyInCapture = m_bIsKeyboardCaptured;
    14721606    }
    14731607
     
    19912125    uint8_t what_pressed = (event.flags & 0x01) && (event.vkCode != VK_RSHIFT) ? IsExtKeyPressed : IsKeyPressed;
    19922126    if ((event.flags & 0x80) /* released */ &&
    1993         ((event.vkCode == m_globalSettings.hostKey() && !m_bHostkeyInCapture) ||
     2127        ((event.vkCode == m_globalSettings.hostKey() && !m_bIsHostkeyInCapture) ||
    19942128         (m_pressedKeys[event.scanCode] & (IsKbdCaptured | what_pressed)) == what_pressed))
    19952129        return false;
     
    24912625    XFreeModifiermap(map);
    24922626
    2493     if (m_uNumLockAdaptionCnt && (m_numLock ^ !!(uMask & uKeyMaskNum)))
     2627    if (m_uNumLockAdaptionCnt && (m_fNumLock ^ !!(uMask & uKeyMaskNum)))
    24942628    {
    24952629        -- m_uNumLockAdaptionCnt;
     
    24972631        piCodes[(*puCount)++] = 0x45 | 0x80;
    24982632    }
    2499     if (m_uCapsLockAdaptionCnt && (m_capsLock ^ !!(uMask & uKeyMaskCaps)))
     2633    if (m_uCapsLockAdaptionCnt && (m_fCapsLock ^ !!(uMask & uKeyMaskCaps)))
    25002634    {
    25012635        m_uCapsLockAdaptionCnt--;
     
    25052639         * capslock.  For simplicity, only do this if shift is not
    25062640         * already held down. */
    2507         if (m_capsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
     2641        if (m_fCapsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
    25082642        {
    25092643            piCodes[(*puCount)++] = 0x2a;
     
    25142648#elif defined(Q_WS_WIN32)
    25152649
    2516     if (m_uNumLockAdaptionCnt && (m_numLock ^ !!(GetKeyState(VK_NUMLOCK))))
     2650    if (m_uNumLockAdaptionCnt && (m_fNumLock ^ !!(GetKeyState(VK_NUMLOCK))))
    25172651    {
    25182652        m_uNumLockAdaptionCnt--;
     
    25202654        piCodes[(*puCount)++] = 0x45 | 0x80;
    25212655    }
    2522     if (m_uCapsLockAdaptionCnt && (m_capsLock ^ !!(GetKeyState(VK_CAPITAL))))
     2656    if (m_uCapsLockAdaptionCnt && (m_fCapsLock ^ !!(GetKeyState(VK_CAPITAL))))
    25232657    {
    25242658        m_uCapsLockAdaptionCnt--;
     
    25282662         * capslock.  For simplicity, only do this if shift is not
    25292663         * already held down. */
    2530         if (m_capsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
     2664        if (m_fCapsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
    25312665        {
    25322666            piCodes[(*puCount)++] = 0x2a;
     
    25382672
    25392673    /* if (m_uNumLockAdaptionCnt) ... - NumLock isn't implemented by Mac OS X so ignore it. */
    2540     if (m_uCapsLockAdaptionCnt && (m_capsLock ^ !!(::GetCurrentEventKeyModifiers() & alphaLock)))
     2674    if (m_uCapsLockAdaptionCnt && (m_fCapsLock ^ !!(::GetCurrentEventKeyModifiers() & alphaLock)))
    25412675    {
    25422676        m_uCapsLockAdaptionCnt--;
     
    25462680         * capslock.  For simplicity, only do this if shift is not
    25472681         * already held down. */
    2548         if (m_capsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
     2682        if (m_fCapsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
    25492683        {
    25502684            piCodes[(*puCount)++] = 0x2a;
     
    26002734void UIMachineView::emitKeyboardStateChanged()
    26012735{
    2602     emit keyboardStateChanged((m_bIsKeyboardCaptured ? UIViewStateType_KeyboardCaptured : 0) |
    2603                               (m_bIsHostkeyPressed ? UIViewStateType_HostKeyPressed : 0));
     2736    emit keyboardStateChanged(keyboardState());
    26042737}
    26052738
    26062739void UIMachineView::emitMouseStateChanged()
    26072740{
    2608     emit mouseStateChanged((m_bIsMouseCaptured ? UIMouseStateType_MouseCaptured : 0) |
    2609                            (m_bIsMouseAbsolute ? UIMouseStateType_MouseAbsolute : 0) |
    2610                            (!m_bIsMouseIntegrated ? UIMouseStateType_MouseAbsoluteDisabled : 0));
     2741    emit mouseStateChanged(mouseState());
    26112742}
    26122743
     
    30783209}
    30793210
    3080 void UIMachineView::setMouseIntegrationLocked(bool bDisabled)
    3081 {
    3082     machineWindowWrapper()->machineLogic()->actionsPool()->action(UIActionIndex_Toggle_MouseIntegration)->setChecked(false);
    3083     machineWindowWrapper()->machineLogic()->actionsPool()->action(UIActionIndex_Toggle_MouseIntegration)->setEnabled(bDisabled);
    3084 }
    3085 
    30863211void UIMachineView::dimImage(QImage &img)
    30873212{
     
    31563281     * the overlay stuff only. */
    31573282    if (mDockIconEnabled &&
    3158         (m_machineState == KMachineState_Running ||
    3159          m_machineState == KMachineState_Paused ||
    3160          m_machineState == KMachineState_Teleporting ||
    3161          m_machineState == KMachineState_LiveSnapshotting ||
    3162          m_machineState == KMachineState_Restoring ||
    3163          m_machineState == KMachineState_TeleportingPausedVM ||
    3164          m_machineState == KMachineState_TeleportingIn ||
    3165          m_machineState == KMachineState_Saving))
     3283        (machineState() == KMachineState_Running ||
     3284         machineState() == KMachineState_Paused ||
     3285         machineState() == KMachineState_Teleporting ||
     3286         machineState() == KMachineState_LiveSnapshotting ||
     3287         machineState() == KMachineState_Restoring ||
     3288         machineState() == KMachineState_TeleportingPausedVM ||
     3289         machineState() == KMachineState_TeleportingIn ||
     3290         machineState() == KMachineState_Saving))
    31663291        updateDockIcon();
    31673292    else
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r26754 r26773  
    6464    virtual void normalizeGeometry(bool bAdjustPosition = false) = 0;
    6565
     66    /* Public getters: */
     67    int keyboardState() const;
     68    int mouseState() const;
     69
    6670    /* Public setters: */
    6771    void setIgnoreGuestResize(bool bIgnore) { m_bIsGuestResizeIgnored = bIgnore; }
    68     void setMouseIntegrationEnabled(bool bEnabled);
     72    virtual void setGuestAutoresizeEnabled(bool bEnabled) = 0;
     73    virtual void setMouseIntegrationEnabled(bool bEnabled);
    6974    //void setMachineViewFinalized(bool fTrue = true) { m_bIsMachineWindowResizeIgnored = !fTrue; }
    7075
     
    8590    void resizeHintDone();
    8691
    87 protected slots:
    88 
    89     /* Initiate resize request to guest: */
    90     virtual void doResizeHint(const QSize &aSize = QSize()) = 0;
    91 
    9292protected:
    9393
     94    /* Machine view constructor/destructor: */
    9495    UIMachineView(  UIMachineWindow *pMachineWindow
    9596                  , VBoxDefs::RenderMode renderMode
     
    108109
    109110    /* Protected getters: */
     111    KMachineState machineState() const { return m_machineState; }
    110112    VBoxDefs::RenderMode mode() const { return m_mode; }
    111113    QSize sizeHint() const;
     
    136138
    137139    /* Cleanup routines: */
    138     //virtual void saveMachineViewSettings();
    139     //virtual void cleanupConsoleConnections();
    140     //virtual void cleanupFilters();
     140    virtual void saveMachineViewSettings();
     141    virtual void cleanupConsoleConnections() {}
     142    virtual void cleanupFilters() {}
    141143    virtual void cleanupCommon();
    142144    virtual void cleanupFrameBuffer();
    143145
     146    /* Update routines: */
     147    virtual void updateMachineState();
     148    virtual void updateAdditionsState();
     149    virtual void updateMousePointerShape();
     150    virtual void updateMouseCapability();
     151
     152protected slots:
     153
     154    /* Console callback handlers: */
     155    virtual void sltMachineStateChanged(KMachineState state);
     156    virtual void sltAdditionsStateChanged();
     157    virtual void sltKeyboardLedsChanged(bool bNumLock, bool bCapsLock, bool bScrollLock);
     158    virtual void sltMousePointerShapeChanged(bool fIsVisible, bool fHasAlpha,
     159                                             uint uXHot, uint uYHot, uint uWidth, uint uHeight,
     160                                             const uchar *pShapeData);
     161    virtual void sltMouseCapabilityChanged(bool bIsSupportsAbsolute, bool bNeedsHostCursor);
     162
     163    /* Initiate resize request to guest: */
     164    virtual void sltPerformGuestResize(const QSize &aSize = QSize()) = 0;
     165
    144166private slots:
    145167
    146     void sltMousePointerShapeChange(bool fIsVisible, bool fHasAlpha,
    147                                     uint uXHot, uint uYHot, uint uWidth, uint uHeight,
    148                                     const uchar *pShapeData);
    149     void sltMouseCapabilityChange(bool bIsSupportsAbsolute, bool bNeedsHostCursor);
    150     void sltKeyboardLedsChange(bool bNumLock, bool bCapsLock, bool bScrollLock);
    151     void sltStateChange(KMachineState state);
    152     void sltAdditionsStateChange();
     168    /* Watch dog for desktop resizes: */
     169    void sltDesktopResized();
    153170
    154171#ifdef Q_WS_MAC
     
    213230    void setPointerShape(const uchar *pShapeData, bool fHasAlpha,
    214231                         uint uXHot, uint uYHot, uint uWidth, uint uHeight);
    215     void setMouseIntegrationLocked(bool fDisabled);
    216232
    217233    /* Private getters: */
    218234    bool isRunning() { return m_machineState == KMachineState_Running || m_machineState == KMachineState_Teleporting || m_machineState == KMachineState_LiveSnapshotting; }
    219     bool shouldHideHostPointer() const { return m_bIsMouseCaptured || (m_bIsMouseAbsolute && m_fHideHostPointer); }
     235    bool shouldHideHostPointer() const { return m_bIsMouseCaptured || (m_bIsMouseAbsolute && m_fIsHideHostPointer); }
    220236
    221237    static void dimImage(QImage &img);
     
    240256    uint8_t m_pressedKeysCopy[128];
    241257
    242     long m_uNumLockAdaptionCnt;
    243     long m_uCapsLockAdaptionCnt;
     258    uint m_uNumLockAdaptionCnt;
     259    uint m_uCapsLockAdaptionCnt;
    244260
    245261    bool m_bIsAutoCaptureDisabled : 1;
     
    248264    bool m_bIsMouseAbsolute : 1;
    249265    bool m_bIsMouseIntegrated : 1;
     266    bool m_fIsHideHostPointer;
    250267    bool m_bIsHostkeyPressed : 1;
    251268    bool m_bIsHostkeyAlone : 1;
    252     bool m_bHostkeyInCapture : 1;
     269    bool m_bIsHostkeyInCapture : 1;
    253270    bool m_bIsGuestSupportsGraphics : 1;
    254271    bool m_bIsMachineWindowResizeIgnored : 1;
    255272    bool m_bIsFrameBufferResizeIgnored : 1;
    256273    bool m_bIsGuestResizeIgnored : 1;
    257     bool m_numLock : 1;
    258     bool m_scrollLock : 1;
    259     bool m_capsLock : 1;
     274    bool m_fNumLock : 1;
     275    bool m_fCapsLock : 1;
     276    bool m_fScrollLock : 1;
    260277    bool m_fPassCAD;
    261     bool m_fHideHostPointer;
    262278#ifdef VBOX_WITH_VIDEOHWACCEL
    263279    bool m_fAccelerate2DVideo;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r26730 r26773  
    3232
    3333#include "UISession.h"
     34#include "UIActionsPool.h"
    3435#include "UIMachineLogic.h"
    3536#include "UIMachineWindow.h"
     
    6667void UIMachineWindow::sltTryClose()
    6768{
     69    /* Do not try to close if restricted: */
     70    if (machineLogic()->isPreventAutoClose())
     71        return;
     72
    6873    /* First close any open modal & popup widgets.
    6974     * Use a single shot with timeout 0 to allow the widgets to cleany close and test then again.
     
    9398}
    9499
     100CSession UIMachineWindow::session()
     101{
     102    return m_pMachineLogic->uisession()->session();
     103}
     104
    95105void UIMachineWindow::retranslateUi()
    96106{
     
    105115                              .arg(RTBldCfgRevisionStr())
    106116                              .arg(VBOX_BLEEDING_EDGE);
    107 #endif
    108 }
    109 
    110 void UIMachineWindow::updateAppearanceOf(int iElement)
    111 {
    112     CMachine machine = session().GetMachine();
    113 
    114     if (iElement & UIVisualElement_WindowCaption)
    115     {
    116         QString strSnapshotName;
    117         if (machine.GetSnapshotCount() > 0)
    118         {
    119             CSnapshot snapshot = machine.GetCurrentSnapshot();
    120             strSnapshotName = " (" + snapshot.GetName() + ")";
    121         }
    122         QString strMachineName = machine.GetName() + strSnapshotName;
    123         if (machineLogic()->machineState() != KMachineState_Null)
    124             strMachineName += " [" + vboxGlobal().toString(machineLogic()->machineState()) + "] - ";
    125         strMachineName += m_strWindowTitlePrefix;
    126         machineWindow()->setWindowTitle(strMachineName);
    127 
    128         // TODO: Move that to fullscreen/seamless update routine:
    129         // mMiniToolBar->setDisplayText(machine.GetName() + strSnapshotName);
    130     }
    131 }
    132 
    133 void UIMachineWindow::prepareWindowIcon()
    134 {
    135 #if !(defined (Q_WS_WIN) || defined (Q_WS_MAC))
    136     /* The default application icon (will be changed to VM-specific icon little bit later):
    137      * 1. On Win32, it's built-in to the executable;
    138      * 2. On Mac OS X the icon referenced in info.plist is used. */
    139     machineWindow()->setWindowIcon(QIcon(":/VirtualBox_48px.png"));
    140 #endif
    141 
    142 #ifndef Q_WS_MAC
    143     /* Set the VM-specific application icon except Mac OS X: */
    144     machineWindow()->setWindowIcon(vboxGlobal().vmGuestOSTypeIcon(session().GetMachine().GetOSTypeId()));
    145 #endif
    146 }
    147 
    148 void UIMachineWindow::prepareConsoleConnections()
    149 {
    150     QObject::connect(machineLogic()->uisession(), SIGNAL(sigStateChange(KMachineState)),
    151                      machineWindow(), SLOT(sltMachineStateChanged(KMachineState)));
    152 }
    153 
    154 void UIMachineWindow::loadWindowSettings()
    155 {
    156 #ifdef Q_WS_MAC
    157     QString testStr = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled).toLower();
    158     /* Default to true if it is an empty value */
    159     bool bIsDockIconEnabled = testStr.isEmpty() || testStr == "true";
    160     if (machineView())
    161     {
    162         machineView()->setDockIconEnabled(bIsDockIconEnabled);
    163         machineView()->updateDockOverlay();
    164     }
    165117#endif
    166118}
     
    271223                    /* Disable auto closure because we want to have a chance to show
    272224                     * the error dialog on save state / power off failure. */
    273                     // TODO: process for multiple windows!
    274                     //m_bNoAutoClose = true;
     225                    machineLogic()->setPreventAutoClose(true);
    275226
    276227                    CConsole console = session().GetConsole();
     
    377328            }
    378329
    379             // TODO: process for multiple windows!
    380             //m_bNoAutoClose = false;
     330            machineLogic()->setPreventAutoClose(false);
    381331
    382332            if (machineLogic()->machineState() == KMachineState_PoweredOff ||
     
    421371        /* Notify all the top-level dialogs about closing */
    422372        // TODO: Notify about closing!
    423         // emit closing();
    424     }
    425 }
    426 
    427 CSession UIMachineWindow::session()
    428 {
    429     return m_pMachineLogic->uisession()->session();
     373        //emit closing();
     374    }
     375}
     376
     377void UIMachineWindow::prepareWindowIcon()
     378{
     379#if !(defined (Q_WS_WIN) || defined (Q_WS_MAC))
     380    /* The default application icon (will be changed to VM-specific icon little bit later):
     381     * 1. On Win32, it's built-in to the executable;
     382     * 2. On Mac OS X the icon referenced in info.plist is used. */
     383    machineWindow()->setWindowIcon(QIcon(":/VirtualBox_48px.png"));
     384#endif
     385
     386#ifndef Q_WS_MAC
     387    /* Set the VM-specific application icon except Mac OS X: */
     388    machineWindow()->setWindowIcon(vboxGlobal().vmGuestOSTypeIcon(session().GetMachine().GetOSTypeId()));
     389#endif
     390}
     391
     392void UIMachineWindow::prepareConsoleConnections()
     393{
     394    /* Machine state-change updater: */
     395    QObject::connect(machineLogic()->uisession(), SIGNAL(sigStateChange(KMachineState)),
     396                     machineWindow(), SLOT(sltMachineStateChanged(KMachineState)));
     397}
     398
     399void UIMachineWindow::loadWindowSettings()
     400{
     401#ifdef Q_WS_MAC
     402    QString testStr = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled).toLower();
     403    /* Default to true if it is an empty value */
     404    bool bIsDockIconEnabled = testStr.isEmpty() || testStr == "true";
     405    if (machineView())
     406    {
     407        machineView()->setDockIconEnabled(bIsDockIconEnabled);
     408        machineView()->updateDockOverlay();
     409    }
     410#endif
     411}
     412
     413void UIMachineWindow::updateAppearanceOf(int iElement)
     414{
     415    CMachine machine = session().GetMachine();
     416
     417    if (iElement & UIVisualElement_WindowCaption)
     418    {
     419        QString strSnapshotName;
     420        if (machine.GetSnapshotCount() > 0)
     421        {
     422            CSnapshot snapshot = machine.GetCurrentSnapshot();
     423            strSnapshotName = " (" + snapshot.GetName() + ")";
     424        }
     425        QString strMachineName = machine.GetName() + strSnapshotName;
     426        if (machineLogic()->machineState() != KMachineState_Null)
     427            strMachineName += " [" + vboxGlobal().toString(machineLogic()->machineState()) + "] - ";
     428        strMachineName += m_strWindowTitlePrefix;
     429        machineWindow()->setWindowTitle(strMachineName);
     430
     431        // TODO: Move that to fullscreen/seamless update routine:
     432        //mMiniToolBar->setDisplayText(machine.GetName() + strSnapshotName);
     433    }
    430434}
    431435
     
    435439}
    436440
     441void UIMachineWindow::sltPrepareMenuMachine()
     442{
     443    QMenu *menu = machineLogic()->actionsPool()->action(UIActionIndex_Menu_Machine)->menu();
     444
     445    menu->clear();
     446
     447    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Fullscreen));
     448    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Seamless));
     449    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize));
     450    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_AdjustWindow));
     451    menu->addSeparator();
     452    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_MouseIntegration));
     453    menu->addSeparator();
     454    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TypeCAD));
     455#ifdef Q_WS_X11
     456    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TypeCABS));
     457#endif
     458    menu->addSeparator();
     459    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TakeSnapshot));
     460    menu->addSeparator();
     461    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_InformationDialog));
     462    menu->addSeparator();
     463    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Pause));
     464    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Reset));
     465    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Shutdown));
     466#ifndef Q_WS_MAC
     467    menu->addSeparator();
     468#endif /* Q_WS_MAC */
     469    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Close));
     470}
     471
     472void UIMachineWindow::sltPrepareMenuDevices()
     473{
     474    QMenu *menu = machineLogic()->actionsPool()->action(UIActionIndex_Menu_Devices)->menu();
     475
     476    menu->clear();
     477
     478    /* Devices submenu */
     479    menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->menu());
     480    menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->menu());
     481    menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu());
     482    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_NetworkAdaptersDialog));
     483    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_SharedFoldersDialog));
     484    menu->addSeparator();
     485    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_VRDP));
     486    menu->addSeparator();
     487    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_InstallGuestTools));
     488}
     489
     490#ifdef VBOX_WITH_DEBUGGER_GUI
     491void UIMachineWindow::sltPrepareMenuDebug()
     492{
     493    QMenu *menu = machineLogic()->actionsPool()->action(UIActionIndex_Menu_Debug)->menu();
     494
     495    menu->clear();
     496
     497    /* Debug submenu */
     498    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Statistics));
     499    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_CommandLine));
     500    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Logging));
     501}
     502#endif /* VBOX_WITH_DEBUGGER_GUI */
     503
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r26709 r26773  
    5454protected:
    5555
    56     /* Common machine window constructor: */
     56    /* Machine window constructor/destructor: */
    5757    UIMachineWindow(UIMachineLogic *pMachineLogic);
    5858    virtual ~UIMachineWindow();
     59
     60    /* Protected getters: */
     61    CSession session();
     62    const QString& defaultWindowTitle() const { return m_strWindowTitlePrefix; }
    5963
    6064    /* Translate routine: */
    6165    virtual void retranslateUi();
    6266
    63     /* Update routines: */
    64     virtual void updateAppearanceOf(int iElement);
     67    /* Common machine window event handlers: */
     68    void closeEvent(QCloseEvent *pEvent);
    6569
    6670    /* Prepare helpers: */
     
    7074
    7175    /* Cleanup helpers: */
    72     //virtual void saveWindowSettings();
    73     //virtual void cleanupConsoleConnections();
    74     //virtual void cleanupWindowIcon();
     76    virtual void saveWindowSettings() {}
     77    virtual void cleanupConsoleConnections() {}
     78    virtual void cleanupWindowIcon() {}
    7579
    76     /* Common machine window event handlers: */
    77     void closeEvent(QCloseEvent *pEvent);
     80    /* Update routines: */
     81    virtual void updateAppearanceOf(int iElement);
    7882
    79     /* Protected getters: */
    80     CSession session();
    81     const QString& defaultWindowTitle() const { return m_strWindowTitlePrefix; }
    82 
    83     /* Protected signals: */
     83    /* Protected slots: */
    8484    void sltMachineStateChanged(KMachineState machineState);
     85    void sltPrepareMenuMachine();
     86    void sltPrepareMenuDevices();
     87#ifdef VBOX_WITH_DEBUGGER_GUI
     88    void sltPrepareMenuDebug();
     89#endif
    8590
    8691    /* Protected variables: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r26709 r26773  
    5555    prepareRequiredFeatures();
    5656
     57    /* Load common logic settings: */
     58    loadLogicSettings();
     59
    5760    /* Prepare normal machine window: */
    5861    prepareMachineWindow();
    59 
    60     /* Load common logic settings: */
    61     loadLogicSettings();
    6262}
    6363
    6464UIMachineLogicNormal::~UIMachineLogicNormal()
    6565{
     66    /* Cleanup normal machine window: */
     67    cleanupMachineWindow();
     68
    6669    /* Save common logic settings: */
    6770    saveLogicSettings();
    68 
    69     /* Cleanup normal machine window: */
    70     cleanupMachineWindow();
    7171}
    7272
     
    7474{
    7575    QMenu *menu = qobject_cast<QMenu*>(sender());
    76     AssertMsg(menu, ("This slot should be called only on Network Adapters Menu show!\n"));
     76    AssertMsg(menu, ("This slot should be called only on Network Adapters menu show!\n"));
    7777    menu->clear();
    7878    menu->addAction(actionsPool()->action(UIActionIndex_Simple_NetworkAdaptersDialog));
     
    8282{
    8383    QMenu *menu = qobject_cast<QMenu*>(sender());
    84     AssertMsg(menu, ("This slot should be called only on Shared Folders Menu show!\n"));
     84    AssertMsg(menu, ("This slot should be called only on Shared Folders menu show!\n"));
    8585    menu->clear();
    8686    menu->addAction(actionsPool()->action(UIActionIndex_Simple_SharedFoldersDialog));
     
    9797void UIMachineLogicNormal::prepareActionConnections()
    9898{
    99     /* Parent class connections: */
     99    /* Base-class connections: */
    100100    UIMachineLogic::prepareActionConnections();
    101101
     
    122122
    123123    /* Create machine window: */
    124     m_pMachineWindowContainer = UIMachineWindow::create(this, visualStateType());
    125 
    126     /* Get the correct initial machineState() value */
    127     setMachineState(session().GetConsole().GetState());
     124    setMachineWindowWrapper(UIMachineWindow::create(this, visualStateType()));
    128125
    129126    bool bIsSaved = machineState() == KMachineState_Saved;
     
    222219#endif
    223220    }
    224 
    225     /* Configure view connections: */
    226     if (machineWindowWrapper()->machineView())
    227     {
    228         connect(machineWindowWrapper()->machineView(), SIGNAL(mouseStateChanged(int)),
    229                 this, SLOT(sltMouseStateChanged(int)));
    230     }
    231 
    232     /* Set what view opened: */
    233     setOpenViewFinished(true);
    234221}
    235222
     
    241228
    242229    /* Cleanup machine window: */
    243     UIMachineWindow::destroy(m_pMachineWindowContainer);
    244     m_pMachineWindowContainer = 0;
    245 }
    246 
     230    UIMachineWindow::destroy(machineWindowWrapper());
     231    setMachineWindowWrapper(0);
     232}
     233
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h

    r26709 r26773  
    5454    void prepareActionConnections();
    5555    void prepareMachineWindow();
    56     //void loadLogicSettings();
    5756
    5857    /* Cleanup helpers: */
    59     //void saveLogicSettings();
    6058    void cleanupMachineWindow();
    61     //void cleanupActionConnections();
     59    void cleanupActionConnections() {}
    6260
    6361    /* Friend classes: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r26754 r26773  
    7373}
    7474
    75 void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition /* = false */)
    76 {
    77     /* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized */
    78     if (machineWindowWrapper()->machineWindow()->isMaximized())
    79         return;
    80 
    81     QWidget *pTopLevelWidget = window();
    82 
    83     /* calculate client window offsets */
    84     QRect fr = pTopLevelWidget->frameGeometry();
    85     QRect r = pTopLevelWidget->geometry();
    86     int dl = r.left() - fr.left();
    87     int dt = r.top() - fr.top();
    88     int dr = fr.right() - r.right();
    89     int db = fr.bottom() - r.bottom();
    90 
    91     /* get the best size w/o scroll bars */
    92     QSize s = pTopLevelWidget->sizeHint();
    93 
    94     /* resize the frame to fit the contents */
    95     s -= pTopLevelWidget->size();
    96     fr.setRight(fr.right() + s.width());
    97     fr.setBottom(fr.bottom() + s.height());
    98 
    99     if (bAdjustPosition)
    100     {
    101         QRegion ar;
    102         QDesktopWidget *dwt = QApplication::desktop();
    103         if (dwt->isVirtualDesktop())
    104             /* Compose complex available region */
    105             for (int i = 0; i < dwt->numScreens(); ++ i)
    106                 ar += dwt->availableGeometry(i);
    107         else
    108             /* Get just a simple available rectangle */
    109             ar = dwt->availableGeometry(pTopLevelWidget->pos());
    110 
    111         fr = VBoxGlobal::normalizeGeometry(fr, ar, mode() != VBoxDefs::SDLMode /* canResize */);
    112     }
    113 
    114 #if 0
    115     /* Center the frame on the desktop: */
    116     fr.moveCenter(ar.center());
    117 #endif
    118 
    119     /* Finally, set the frame geometry */
    120     pTopLevelWidget->setGeometry(fr.left() + dl, fr.top() + dt, fr.width() - dl - dr, fr.height() - dt - db);
    121 }
    122 
    123 void UIMachineViewNormal::maybeRestrictMinimumSize()
    124 {
    125     /* Sets the minimum size restriction depending on the auto-resize feature state and the current rendering mode.
    126      * Currently, the restriction is set only in SDL mode and only when the auto-resize feature is inactive.
    127      * We need to do that because we cannot correctly draw in a scrolled window in SDL mode.
    128      * In all other modes, or when auto-resize is in force, this function does nothing. */
    129     if (mode() == VBoxDefs::SDLMode)
    130     {
    131         if (!isGuestSupportsGraphics() || !m_bIsGuestAutoresizeEnabled)
    132             setMinimumSize(sizeHint());
    133         else
    134             setMinimumSize(0, 0);
    135     }
    136 }
    137 
    138 void UIMachineViewNormal::doResizeHint(const QSize & /*toSize*/)
     75void UIMachineViewNormal::sltPerformGuestResize(const QSize & /* toSize */)
    13976{
    14077#if 0 // TODO: fix that logic!
     
    171108}
    172109
    173 /* If the desktop geometry is set automatically, this will update it. */
    174 void UIMachineViewNormal::doResizeDesktop(int)
    175 {
    176     calculateDesktopGeometry();
    177 }
    178 
    179 void UIMachineViewNormal::sltToggleGuestAutoresize(bool bOn)
    180 {
    181     if (m_bIsGuestAutoresizeEnabled != bOn)
    182     {
    183         m_bIsGuestAutoresizeEnabled = bOn;
    184 
    185         maybeRestrictMinimumSize();
    186 
    187         if (isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled)
    188             doResizeHint();
    189     }
    190 }
    191 
    192 void UIMachineViewNormal::sltAdditionsStateChanged(const QString & /* strVersion */, bool /* bIsActive */,
    193                                                    bool /* bIsSeamlessSupported */, bool bIsGraphicsSupported)
    194 {
     110void UIMachineViewNormal::sltAdditionsStateChanged()
     111{
     112    /* Base-class additions state-change-handler: */
     113    UIMachineView::sltAdditionsStateChanged();
     114
    195115    /* Enable/Disable guest auto-resizing depending on advanced graphics availablability: */
    196     sltToggleGuestAutoresize(bIsGraphicsSupported && m_bIsGuestAutoresizeEnabled);
     116    setGuestAutoresizeEnabled(isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled);
    197117}
    198118
    199119void UIMachineViewNormal::prepareFilters()
    200120{
    201     /* Parent class filters: */
     121    /* Prepare base-class filters: */
    202122    UIMachineView::prepareFilters();
    203123
     
    206126}
    207127
     128void UIMachineViewNormal::setGuestAutoresizeEnabled(bool fEnabled)
     129{
     130    if (m_bIsGuestAutoresizeEnabled != fEnabled)
     131    {
     132        m_bIsGuestAutoresizeEnabled = fEnabled;
     133
     134        maybeRestrictMinimumSize();
     135
     136        if (isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled)
     137            sltPerformGuestResize();
     138    }
     139}
     140
     141void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition /* = false */)
     142{
     143    QWidget *pTopLevelWidget = window();
     144
     145    /* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized: */
     146    if (pTopLevelWidget->isMaximized())
     147        return;
     148
     149    /* Calculate client window offsets: */
     150    QRect frameGeo = pTopLevelWidget->frameGeometry();
     151    QRect geo = pTopLevelWidget->geometry();
     152    int dl = geo.left() - frameGeo.left();
     153    int dt = geo.top() - frameGeo.top();
     154    int dr = frameGeo.right() - geo.right();
     155    int db = frameGeo.bottom() - geo.bottom();
     156
     157    /* Get the best size w/o scroll bars: */
     158    QSize s = pTopLevelWidget->sizeHint();
     159
     160    /* Resize the frame to fit the contents: */
     161    s -= pTopLevelWidget->size();
     162    frameGeo.setRight(frameGeo.right() + s.width());
     163    frameGeo.setBottom(frameGeo.bottom() + s.height());
     164
     165    if (bAdjustPosition)
     166    {
     167        QRegion availableGeo;
     168        QDesktopWidget *dwt = QApplication::desktop();
     169        if (dwt->isVirtualDesktop())
     170            /* Compose complex available region */
     171            for (int i = 0; i < dwt->numScreens(); ++ i)
     172                availableGeo += dwt->availableGeometry(i);
     173        else
     174            /* Get just a simple available rectangle */
     175            availableGeo = dwt->availableGeometry(pTopLevelWidget->pos());
     176
     177        frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo, mode() != VBoxDefs::SDLMode /* canResize */);
     178    }
     179
     180#if 0
     181    /* Center the frame on the desktop: */
     182    frameGeo.moveCenter(availableGeo.center());
     183#endif
     184
     185    /* Finally, set the frame geometry */
     186    pTopLevelWidget->setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, frameGeo.width() - dl - dr, frameGeo.height() - dt - db);
     187}
     188
     189void UIMachineViewNormal::maybeRestrictMinimumSize()
     190{
     191    /* Sets the minimum size restriction depending on the auto-resize feature state and the current rendering mode.
     192     * Currently, the restriction is set only in SDL mode and only when the auto-resize feature is inactive.
     193     * We need to do that because we cannot correctly draw in a scrolled window in SDL mode.
     194     * In all other modes, or when auto-resize is in force, this function does nothing. */
     195    if (mode() == VBoxDefs::SDLMode)
     196    {
     197        if (!isGuestSupportsGraphics() || !m_bIsGuestAutoresizeEnabled)
     198            setMinimumSize(sizeHint());
     199        else
     200            setMinimumSize(0, 0);
     201    }
     202}
     203
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h

    r26754 r26773  
    3333protected:
    3434
     35    /* Normal machine view constructor/destructor: */
    3536    UIMachineViewNormal(  UIMachineWindow *pMachineWindow
    3637                        , VBoxDefs::RenderMode renderMode
     
    4142    virtual ~UIMachineViewNormal();
    4243
    43     void normalizeGeometry(bool bAdjustPosition = false);
    44 
    45     void maybeRestrictMinimumSize();
    46 
    4744private slots:
    4845
    49     void doResizeHint(const QSize &aSize = QSize());
     46    /* Console callback handlers: */
     47    void sltAdditionsStateChanged();
    5048
    51     void doResizeDesktop(int);
     49    /* Slot to perform guest resize: */
     50    void sltPerformGuestResize(const QSize &aSize = QSize());
    5251
    53     void sltToggleGuestAutoresize(bool bOn);
    54 
    55     void sltAdditionsStateChanged(const QString &strVersion, bool bIsActive,
    56                                   bool bIsSeamlessSupported, bool bIsGraphicsSupported);
    5752private:
    5853
     
    6055    void prepareFilters();
    6156
     57    /* Private setters: */
     58    void setGuestAutoresizeEnabled(bool bEnabled);
     59
     60    /* Private helpers: */
     61    void normalizeGeometry(bool bAdjustPosition = false);
     62    void maybeRestrictMinimumSize();
     63
     64    /* Private members: */
    6265    bool m_bIsGuestAutoresizeEnabled : 1;
    6366
     67    /* Friend classes: */
    6468    friend class UIMachineView;
    6569};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r26758 r26773  
    6868    prepareConnections();
    6969
     70    /* Load normal window settings: */
     71    loadWindowSettings();
     72
     73    /* Retranslate normal window finally: */
     74    retranslateUi();
     75
    7076    /* Prepare normal machine view: */
    7177    prepareMachineView();
    7278
    73     /* Load normal window settings: */
    74     loadWindowSettings();
    75 
    76     /* Retranslate normal window finally: */
    77     retranslateUi();
    78 
    7979    /* Update all the elements: */
    8080    updateAppearanceOf(UIVisualElement_AllStuff);
     
    9393}
    9494
    95 void UIMachineWindowNormal::sltTryClose()
    96 {
    97     UIMachineWindow::sltTryClose();
    98 }
    99 
    10095void UIMachineWindowNormal::sltMachineStateChanged(KMachineState machineState)
    10196{
     
    106101{
    107102    KDeviceType type = attachment.GetType();
    108     Assert(type == KDeviceType_DVD || type == KDeviceType_Floppy);
    109     updateAppearanceOf(type == KDeviceType_DVD ? UIVisualElement_CDStuff :
    110                        type == KDeviceType_Floppy ? UIVisualElement_FDStuff :
    111                        UIVisualElement_AllStuff);
     103    if (type == KDeviceType_HardDisk)
     104        updateAppearanceOf(UIVisualElement_HDStuff);
     105    if (type == KDeviceType_DVD)
     106        updateAppearanceOf(UIVisualElement_CDStuff);
     107    if (type == KDeviceType_Floppy)
     108        updateAppearanceOf(UIVisualElement_FDStuff);
    112109}
    113110
     
    134131void UIMachineWindowNormal::sltPrepareMenuMachine()
    135132{
    136     QMenu *menu = qobject_cast<QMenu*>(sender());
    137     AssertMsg(menu == machineLogic()->actionsPool()->action(UIActionIndex_Menu_Machine)->menu(),
    138               ("This slot should only be called on 'Machine' menu hovering!\n"));
    139 
    140     menu->clear();
    141 
    142     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Fullscreen));
    143     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Seamless));
    144     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize));
    145     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_AdjustWindow));
    146     menu->addSeparator();
    147     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_MouseIntegration));
    148     menu->addSeparator();
    149     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TypeCAD));
    150 #ifdef Q_WS_X11
    151     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TypeCABS));
    152 #endif
    153     menu->addSeparator();
    154     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TakeSnapshot));
    155     menu->addSeparator();
    156     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_InformationDialog));
    157     menu->addSeparator();
    158     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Pause));
    159     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Reset));
    160     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Shutdown));
    161 #ifndef Q_WS_MAC
    162     menu->addSeparator();
    163 #endif /* Q_WS_MAC */
    164     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Close));
     133    UIMachineWindow::sltPrepareMenuMachine();
    165134}
    166135
    167136void UIMachineWindowNormal::sltPrepareMenuDevices()
    168137{
    169     QMenu *menu = qobject_cast<QMenu*>(sender());
    170     AssertMsg(menu == machineLogic()->actionsPool()->action(UIActionIndex_Menu_Devices)->menu(),
    171               ("This slot should only be called on 'Devices' menu hovering!\n"));
    172 
    173     menu->clear();
    174 
    175     /* Devices submenu */
    176     menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->menu());
    177     menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->menu());
    178     menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu());
    179     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_NetworkAdaptersDialog));
    180     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_SharedFoldersDialog));
    181     menu->addSeparator();
    182     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_VRDP));
    183     menu->addSeparator();
    184     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_InstallGuestTools));
     138    UIMachineWindow::sltPrepareMenuDevices();
    185139}
    186140
     
    188142void UIMachineWindowNormal::sltPrepareMenuDebug()
    189143{
    190     QMenu *menu = qobject_cast<QMenu*>(sender());
    191     AssertMsg(menu == machineLogic()->actionsPool()->action(UIActionIndex_Menu_Debug)->menu(),
    192               ("This slot should only be called on 'Debug' menu hovering!\n"));
    193 
    194     menu->clear();
    195 
    196     /* Debug submenu */
    197     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Statistics));
    198     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_CommandLine));
    199     menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Logging));
    200 }
    201 #endif /* VBOX_WITH_DEBUGGER_GUI */
     144    UIMachineWindow::sltPrepareMenuDebug();
     145}
     146#endif
     147
     148void UIMachineWindowNormal::sltTryClose()
     149{
     150    UIMachineWindow::sltTryClose();
     151}
    202152
    203153void UIMachineWindowNormal::sltUpdateIndicators()
     
    275225{
    276226    m_pNameHostkey->setText(QIHotKeyEdit::keyName(vboxGlobal().settings().hostKey()));
    277 }
    278 
    279 void UIMachineWindowNormal::sltUpdateMouseState(int iState)
    280 {
    281     if ((iState & UIMouseStateType_MouseAbsoluteDisabled) &&
    282         (iState & UIMouseStateType_MouseAbsolute) &&
    283         !(iState & UIMouseStateType_MouseCaptured))
    284     {
    285         indicatorsPool()->indicator(UIIndicatorIndex_Mouse)->setState(4);
    286     }
    287     else
    288     {
    289         indicatorsPool()->indicator(UIIndicatorIndex_Mouse)->setState(
    290             iState & (UIMouseStateType_MouseAbsolute | UIMouseStateType_MouseCaptured));
    291     }
    292227}
    293228
     
    322257    if (iElement & UIVisualElement_CDStuff)
    323258        indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks)->updateAppearance();
    324 #if 0 /* TODO: Allow to setup status-bar! */
    325     if (iElement & UIVisualElement_FDStuff)
    326         indicatorsPool()->indicator(UIIndicatorIndex_FloppyDisks)->updateAppearance();
    327 #endif
    328     if (    iElement & UIVisualElement_USBStuff
    329         && !indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->isHidden())
    330             indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->updateAppearance();
     259    if (iElement & UIVisualElement_USBStuff &&
     260        !indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->isHidden())
     261        indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->updateAppearance();
    331262    if (iElement & UIVisualElement_NetworkStuff)
    332263        indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters)->updateAppearance();
    333264    if (iElement & UIVisualElement_SharedFolderStuff)
    334265        indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders)->updateAppearance();
    335 #if 0 /* TODO: Allow to setup status-bar! */
    336     if (iElement & UIVisualElement_VRDPStuff)
    337         indicatorsPool()->indicator(UIIndicatorIndex_VRDP)->updateAppearance();
    338 #endif
    339266    if (iElement & UIVisualElement_VirtualizationStuff)
    340267        indicatorsPool()->indicator(UIIndicatorIndex_Virtualization)->updateAppearance();
     
    347274        case QEvent::Resize:
    348275        {
    349             QResizeEvent *pResizeEvent = (QResizeEvent*)pEvent;
    350 
     276            QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
    351277            if (!isMaximized())
    352278            {
     
    406332void UIMachineWindowNormal::prepareConsoleConnections()
    407333{
    408     /* Parent class connections: */
     334    /* Base-class connections: */
    409335    UIMachineWindow::prepareConsoleConnections();
    410     /* Other console connections: */
     336
     337    /* Medium change updater: */
    411338    connect(machineLogic()->uisession(), SIGNAL(sigMediumChange(const CMediumAttachment &)),
    412339            this, SLOT(sltMediumChange(const CMediumAttachment &)));
     340
     341    /* USB controller change updater: */
    413342    connect(machineLogic()->uisession(), SIGNAL(sigUSBControllerChange()),
    414343            this, SLOT(sltUSBControllerChange()));
     344
     345    /* USB device state-change updater: */
    415346    connect(machineLogic()->uisession(), SIGNAL(sigUSBDeviceStateChange(const CUSBDevice &, bool, const CVirtualBoxErrorInfo &)),
    416347            this, SLOT(sltUSBDeviceStateChange()));
     348
     349    /* Network adapter change updater: */
    417350    connect(machineLogic()->uisession(), SIGNAL(sigNetworkAdapterChange(const CNetworkAdapter &)),
    418351            this, SLOT(sltNetworkAdapterChange()));
     352
     353    /* Shared folder change updater: */
    419354    connect(machineLogic()->uisession(), SIGNAL(sigSharedFolderChange()),
    420355            this, SLOT(sltSharedFolderChange()));
     
    519454void UIMachineWindowNormal::prepareConnections()
    520455{
    521     /* Setup global settings <-> indicators connections: */
     456    /* Setup global settings change updater: */
    522457    connect(&vboxGlobal().settings(), SIGNAL(propertyChanged(const char *, const char *)),
    523458            this, SLOT(sltProcessGlobalSettingChange(const char *, const char *)));
     
    540475                                           , machineLogic()->visualStateType());
    541476
    542     //qobject_cast<QGridLayout*>(centralWidget()->layout())->addWidget(m_pMachineView, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);
    543477    setCentralWidget(m_pMachineView);
    544478
    545     /* Setup machine view <-> indicators connections: */
    546     connect(machineView(), SIGNAL(keyboardStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Hostkey), SLOT(setState(int)));
    547     connect(machineView(), SIGNAL(mouseStateChanged(int)), this, SLOT(sltUpdateMouseState(int)));
     479    /* Setup machine view connections: */
     480    if (machineView())
     481    {
     482        /* Keyboard state-change updater: */
     483        connect(machineView(), SIGNAL(keyboardStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Hostkey), SLOT(setState(int)));
     484
     485        /* Mouse state-change updater: */
     486        connect(machineView(), SIGNAL(mouseStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Mouse), SLOT(setState(int)));
     487
     488        /* Early initialize required connections: */
     489        indicatorsPool()->indicator(UIIndicatorIndex_Hostkey)->setState(machineView()->keyboardState());
     490        indicatorsPool()->indicator(UIIndicatorIndex_Mouse)->setState(machineView()->mouseState());
     491    }
    548492}
    549493
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h

    r26709 r26773  
    4646protected:
    4747
     48    /* Normal machine window constructor/destructor: */
    4849    UIMachineWindowNormal(UIMachineLogic *pMachineLogic);
    4950    virtual ~UIMachineWindowNormal();
     
    5152private slots:
    5253
    53     void sltTryClose();
    54 
     54    /* Console callback handlers: */
    5555    void sltMachineStateChanged(KMachineState machineState);
    5656    void sltMediumChange(const CMediumAttachment &attachment);
     
    6060    void sltSharedFolderChange();
    6161
     62    /* Runtime menus: */
    6263    void sltPrepareMenuMachine();
    6364    void sltPrepareMenuDevices();
     
    6667#endif
    6768
     69    /* LED connections: */
    6870    void sltUpdateIndicators();
    6971    void sltShowIndicatorsContextMenu(QIStateIndicator *pIndicator, QContextMenuEvent *pEvent);
    70 
    7172    void sltProcessGlobalSettingChange(const char *aPublicName, const char *aName);
    7273
    73     void sltUpdateMouseState(int iState);
     74    /* Close window reimplementation: */
     75    void sltTryClose();
    7476
    7577private:
     
    9698    void prepareStatusBar();
    9799    void prepareConnections();
     100    void loadWindowSettings();
    98101    void prepareMachineView();
    99     void loadWindowSettings();
    100102
    101103    /* Cleanup helpers: */
     104    void cleanupMachineView() {}
    102105    void saveWindowSettings();
    103     //void cleanupMachineView();
    104     //void cleanupConnections();
     106    void cleanupConnections() {}
    105107    void cleanupStatusBar();
    106     //void cleanupMenu();
    107     void cleanupConsoleConnections();
     108    void cleanupMenu() {}
     109    void cleanupConsoleConnections() {}
    108110
    109111    /* Indicators pool: */
Note: See TracChangeset for help on using the changeset viewer.

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