VirtualBox

Ignore:
Timestamp:
Apr 26, 2012 9:31:55 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77632
Message:

FE/Qt: Runtime UI: Machine logic refactoring/cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r41063 r41064  
    6060    ~UIVisualState()
    6161    {
    62         /* Delete machine logic if exists: */
     62        /* Cleanup/delete machine logic if exists: */
    6363        if (m_pMachineLogic)
     64        {
     65            /* Cleanup the logic object: */
     66            m_pMachineLogic->cleanup();
     67            /* Destroy the logic object: */
    6468            UIMachineLogic::destroy(m_pMachineLogic);
     69        }
    6570    }
    6671
     
    95100
    96101    /* Method to change one visual state to another: */
    97     virtual void change() = 0;
     102    virtual void change()
     103    {
     104        /* Prepare the logic object: */
     105        m_pMachineLogic->prepare();
     106    }
    98107
    99108    /* Method to finish change one visual state to another: */
     
    149158    void change()
    150159    {
     160        /* Call to base-class: */
     161        UIVisualState::change();
     162
    151163        /* Connect action handlers: */
    152164        connect(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen), SIGNAL(triggered(bool)),
     
    156168        connect(gActionPool->action(UIActionIndexRuntime_Toggle_Scale), SIGNAL(triggered(bool)),
    157169                this, SLOT(sltGoToScaleMode()), Qt::QueuedConnection);
    158 
    159         /* Initialize the logic object: */
    160         m_pMachineLogic->initialize();
    161170    }
    162171};
     
    213222    void change()
    214223    {
     224        /* Call to base-class: */
     225        UIVisualState::change();
     226
    215227        /* Connect action handlers: */
    216228        connect(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen), SIGNAL(triggered(bool)),
     
    220232        connect(gActionPool->action(UIActionIndexRuntime_Toggle_Scale), SIGNAL(triggered(bool)),
    221233                this, SLOT(sltGoToScaleMode()), Qt::QueuedConnection);
    222 
    223         /* Initialize the logic object: */
    224         m_pMachineLogic->initialize();
    225234    }
    226235};
     
    277286    void change()
    278287    {
     288        /* Call to base-class: */
     289        UIVisualState::change();
     290
    279291        /* Connect action handlers: */
    280292        connect(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless), SIGNAL(triggered(bool)),
     
    284296        connect(gActionPool->action(UIActionIndexRuntime_Toggle_Scale), SIGNAL(triggered(bool)),
    285297                this, SLOT(sltGoToScaleMode()), Qt::QueuedConnection);
    286 
    287         /* Initialize the logic object: */
    288         m_pMachineLogic->initialize();
    289298    }
    290299};
     
    341350    void change()
    342351    {
     352        /* Call to base-class: */
     353        UIVisualState::change();
     354
    343355        /* Connect action handlers: */
    344356        connect(gActionPool->action(UIActionIndexRuntime_Toggle_Scale), SIGNAL(triggered(bool)),
     
    348360        connect(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless), SIGNAL(triggered(bool)),
    349361                this, SLOT(sltGoToSeamlessMode()), Qt::QueuedConnection);
    350 
    351         /* Initialize the logic object: */
    352         m_pMachineLogic->initialize();
    353362    }
    354363};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r41063 r41064  
    110110                                       UIVisualStateType visualStateType)
    111111{
    112     UIMachineLogic *logic = 0;
     112    UIMachineLogic *pLogic = 0;
    113113    switch (visualStateType)
    114114    {
    115115        case UIVisualStateType_Normal:
    116             logic = new UIMachineLogicNormal(pParent, pSession);
     116            pLogic = new UIMachineLogicNormal(pParent, pSession);
    117117            break;
    118118        case UIVisualStateType_Fullscreen:
    119             logic = new UIMachineLogicFullscreen(pParent, pSession);
     119            pLogic = new UIMachineLogicFullscreen(pParent, pSession);
    120120            break;
    121121        case UIVisualStateType_Seamless:
    122             logic = new UIMachineLogicSeamless(pParent, pSession);
     122            pLogic = new UIMachineLogicSeamless(pParent, pSession);
    123123            break;
    124124        case UIVisualStateType_Scale:
    125             logic = new UIMachineLogicScale(pParent, pSession);
     125            pLogic = new UIMachineLogicScale(pParent, pSession);
    126126            break;
    127127    }
    128     return logic;
     128    return pLogic;
    129129}
    130130
     
    135135}
    136136
    137 bool UIMachineLogic::checkAvailability()
    138 {
    139     return true;
     137void UIMachineLogic::prepare()
     138{
     139    /* Prepare required features: */
     140    prepareRequiredFeatures();
     141
     142    /* Prepare session connections: */
     143    prepareSessionConnections();
     144
     145    /* Prepare action groups:
     146     * Note: This has to be done before prepareActionConnections
     147     * cause here actions/menus are recreated. */
     148    prepareActionGroups();
     149    /* Prepare action connections: */
     150    prepareActionConnections();
     151
     152    /* Prepare handlers: */
     153    prepareHandlers();
     154
     155    /* Prepare machine window(s): */
     156    prepareMachineWindows();
     157
     158#ifdef Q_WS_MAC
     159    /* Prepare dock: */
     160    prepareDock();
     161#endif /* Q_WS_MAC */
     162
     163#ifdef VBOX_WITH_DEBUGGER_GUI
     164    /* Prepare debugger: */
     165    prepareDebugger();
     166#endif /* VBOX_WITH_DEBUGGER_GUI */
     167
     168    /* Power up machine: */
     169    uisession()->powerUp();
     170
     171    /* Initialization: */
     172    sltMachineStateChanged();
     173    sltAdditionsStateChanged();
     174    sltMouseCapabilityChanged();
     175
     176    /* Retranslate logic part: */
     177    retranslateUi();
     178}
     179
     180void UIMachineLogic::cleanup()
     181{
     182#ifdef VBOX_WITH_DEBUGGER_GUI
     183    /* Cleanup debugger: */
     184    cleanupDebugger();
     185#endif /* VBOX_WITH_DEBUGGER_GUI */
     186
     187#ifdef Q_WS_MAC
     188    /* Cleanup dock: */
     189    cleanupDock();
     190#endif /* Q_WS_MAC */
     191
     192    /* Cleanup machine window(s): */
     193    cleanupMachineWindows();
     194
     195    /* Cleanup handlers: */
     196    cleanupHandlers();
     197
     198    /* Cleanup action groups: */
     199    cleanupActionGroups();
     200}
     201
     202CSession& UIMachineLogic::session() const
     203{
     204    return uisession()->session();
    140205}
    141206
     
    146211        return 0;
    147212
     213    /* Otherwise return first of windows: */
    148214    return machineWindows()[0];
    149215}
     
    208274#endif /* Q_WS_MAC */
    209275
    210 UIMachineLogic::UIMachineLogic(QObject *pParent,
    211                                UISession *pSession,
    212                                UIVisualStateType visualStateType)
     276void UIMachineLogic::sltMachineStateChanged()
     277{
     278    /* Get machine state: */
     279    KMachineState state = uisession()->machineState();
     280
     281    /* Update action groups: */
     282    m_pRunningActions->setEnabled(uisession()->isRunning());
     283    m_pRunningOrPausedActions->setEnabled(uisession()->isRunning() || uisession()->isPaused());
     284
     285    switch (state)
     286    {
     287        case KMachineState_Stuck: // TODO: Test it!
     288        {
     289            /* Prevent machine view from resizing: */
     290            uisession()->setGuestResizeIgnored(true);
     291
     292            /* Get console and log folder. */
     293            CConsole console = session().GetConsole();
     294            const QString &strLogFolder = console.GetMachine().GetLogFolder();
     295
     296            /* Take the screenshot for debugging purposes and save it. */
     297            takeScreenshot(strLogFolder + "/VBox.png", "png");
     298
     299            /* Warn the user about GURU: */
     300            if (msgCenter().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder)))
     301            {
     302                console.PowerDown();
     303                if (!console.isOk())
     304                    msgCenter().cannotStopMachine(console);
     305            }
     306            break;
     307        }
     308        case KMachineState_Paused:
     309        case KMachineState_TeleportingPausedVM:
     310        {
     311            QAction *pPauseAction = gActionPool->action(UIActionIndexRuntime_Toggle_Pause);
     312            if (!pPauseAction->isChecked())
     313            {
     314                /* Was paused from CSession side: */
     315                pPauseAction->blockSignals(true);
     316                pPauseAction->setChecked(true);
     317                pPauseAction->blockSignals(false);
     318            }
     319            break;
     320        }
     321        case KMachineState_Running:
     322        case KMachineState_Teleporting:
     323        case KMachineState_LiveSnapshotting:
     324        {
     325            QAction *pPauseAction = gActionPool->action(UIActionIndexRuntime_Toggle_Pause);
     326            if (pPauseAction->isChecked())
     327            {
     328                /* Was resumed from CSession side: */
     329                pPauseAction->blockSignals(true);
     330                pPauseAction->setChecked(false);
     331                pPauseAction->blockSignals(false);
     332            }
     333            break;
     334        }
     335        case KMachineState_PoweredOff:
     336        case KMachineState_Saved:
     337        case KMachineState_Teleported:
     338        case KMachineState_Aborted:
     339        {
     340            /* Close VM if it was turned off and closure allowed: */
     341            if (!isPreventAutoClose())
     342            {
     343                /* VM has been powered off, saved or aborted, no matter
     344                 * internally or externally. We must *safely* close VM window(s): */
     345                QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession()));
     346            }
     347            break;
     348        }
     349#ifdef Q_WS_X11
     350        case KMachineState_Starting:
     351        case KMachineState_Restoring:
     352        case KMachineState_TeleportingIn:
     353        {
     354            /* The keyboard handler may wish to do some release logging on startup.
     355             * Tell it that the logger is now active. */
     356            doXKeyboardLogging(QX11Info::display());
     357            break;
     358        }
     359#endif
     360        default:
     361            break;
     362    }
     363
     364#ifdef Q_WS_MAC
     365    /* Update Dock Overlay: */
     366    updateDockOverlay();
     367#endif /* Q_WS_MAC */
     368}
     369
     370void UIMachineLogic::sltAdditionsStateChanged()
     371{
     372    /* Update action states: */
     373    gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setEnabled(uisession()->isGuestSupportsGraphics());
     374    gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->setEnabled(uisession()->isGuestSupportsSeamless());
     375}
     376
     377void UIMachineLogic::sltMouseCapabilityChanged()
     378{
     379    /* Variable falgs: */
     380    bool fIsMouseSupportsAbsolute = uisession()->isMouseSupportsAbsolute();
     381    bool fIsMouseSupportsRelative = uisession()->isMouseSupportsRelative();
     382    bool fIsMouseHostCursorNeeded = uisession()->isMouseHostCursorNeeded();
     383
     384    /* Update action state: */
     385    QAction *pAction = gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration);
     386    pAction->setEnabled(fIsMouseSupportsAbsolute && fIsMouseSupportsRelative && !fIsMouseHostCursorNeeded);
     387    if (fIsMouseHostCursorNeeded)
     388        pAction->setChecked(false);
     389}
     390
     391void UIMachineLogic::sltUSBDeviceStateChange(const CUSBDevice &device, bool fIsAttached, const CVirtualBoxErrorInfo &error)
     392{
     393    /* Check if USB device have anything to tell us: */
     394    if (!error.isNull())
     395    {
     396        if (fIsAttached)
     397            msgCenter().cannotAttachUSBDevice(session().GetConsole(), vboxGlobal().details(device), error);
     398        else
     399            msgCenter().cannotDetachUSBDevice(session().GetConsole(), vboxGlobal().details(device), error);
     400    }
     401}
     402
     403void UIMachineLogic::sltRuntimeError(bool fIsFatal, const QString &strErrorId, const QString &strMessage)
     404{
     405    msgCenter().showRuntimeError(session().GetConsole(), fIsFatal, strErrorId, strMessage);
     406}
     407
     408#ifdef Q_WS_MAC
     409void UIMachineLogic::sltShowWindows()
     410{
     411    for (int i=0; i < m_machineWindowsList.size(); ++i)
     412    {
     413        UIMachineWindow *pMachineWindow = m_machineWindowsList.at(i);
     414        /* Dunno what Qt thinks a window that has minimized to the dock
     415         * should be - it is not hidden, neither is it minimized. OTOH it is
     416         * marked shown and visible, but not activated. This latter isn't of
     417         * much help though, since at this point nothing is marked activated.
     418         * I might have overlooked something, but I'm buggered what if I know
     419         * what. So, I'll just always show & activate the stupid window to
     420         * make it get out of the dock when the user wishes to show a VM. */
     421        pMachineWindow->machineWindow()->raise();
     422        pMachineWindow->machineWindow()->activateWindow();
     423    }
     424}
     425#endif /* Q_WS_MAC */
     426
     427UIMachineLogic::UIMachineLogic(QObject *pParent, UISession *pSession, UIVisualStateType visualStateType)
    213428    : QIWithRetranslateUI3<QObject>(pParent)
    214429    , m_pSession(pSession)
     
    233448}
    234449
    235 UIMachineLogic::~UIMachineLogic()
    236 {
    237 #ifdef VBOX_WITH_DEBUGGER_GUI
    238     /* Close debugger: */
    239     dbgDestroy();
    240 #endif /* VBOX_WITH_DEBUGGER_GUI */
    241 }
    242 
    243 CSession& UIMachineLogic::session() const
    244 {
    245     return uisession()->session();
    246 }
    247 
    248450void UIMachineLogic::addMachineWindow(UIMachineWindow *pMachineWindow)
    249451{
     
    300502#endif /* Q_WS_MAC */
    301503
     504void UIMachineLogic::prepareRequiredFeatures()
     505{
     506#ifdef Q_WS_MAC
     507# ifdef VBOX_WITH_ICHAT_THEATER
     508    /* Init shared AV manager: */
     509    initSharedAVManager();
     510# endif /* VBOX_WITH_ICHAT_THEATER */
     511#endif /* Q_WS_MAC */
     512}
     513
    302514void UIMachineLogic::prepareSessionConnections()
    303515{
    304     /* Machine power-up notifier: */
     516    /* We should check for entering/exiting requested modes: */
    305517    connect(uisession(), SIGNAL(sigMachineStarted()), this, SLOT(sltCheckRequestedModes()));
     518    connect(uisession(), SIGNAL(sigAdditionsStateChange()), this, SLOT(sltCheckRequestedModes()));
    306519
    307520    /* Machine state-change updater: */
     
    324537#ifdef Q_WS_MAC
    325538    /* Show windows: */
    326     connect(uisession(), SIGNAL(sigShowWindows()),
    327             this, SLOT(sltShowWindows()));
     539    connect(uisession(), SIGNAL(sigShowWindows()), this, SLOT(sltShowWindows()));
    328540#endif /* Q_WS_MAC */
     541}
     542
     543void UIMachineLogic::prepareActionGroups()
     544{
     545#ifdef Q_WS_MAC
     546    /* On Mac OS X, all QMenu's are consumed by Qt after they are added to
     547     * another QMenu or a QMenuBar. This means we have to recreate all QMenus
     548     * when creating a new QMenuBar. */
     549    gActionPool->recreateMenus();
     550#endif /* Q_WS_MAC */
     551
     552    /* Create group for all actions that are enabled only when the VM is running.
     553     * Note that only actions whose enabled state depends exclusively on the
     554     * execution state of the VM are added to this group. */
     555    m_pRunningActions = new QActionGroup(this);
     556    m_pRunningActions->setExclusive(false);
     557
     558    /* Create group for all actions that are enabled when the VM is running or paused.
     559     * Note that only actions whose enabled state depends exclusively on the
     560     * execution state of the VM are added to this group. */
     561    m_pRunningOrPausedActions = new QActionGroup(this);
     562    m_pRunningOrPausedActions->setExclusive(false);
     563
     564    /* Move actions into running actions group: */
     565    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCAD));
     566#ifdef Q_WS_X11
     567    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCABS));
     568#endif
     569    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Reset));
     570    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Shutdown));
     571    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen));
     572    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless));
     573    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Scale));
     574    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize));
     575    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow));
     576
     577    /* Move actions into running-n-paused actions group: */
     578    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog));
     579    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot));
     580    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot));
     581    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog));
     582    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_MouseIntegration));
     583    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration));
     584    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Pause));
     585    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices));
     586    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices));
     587    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_USBDevices));
     588    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_NetworkAdapters));
     589    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_NetworkAdaptersDialog));
     590    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_SharedFolders));
     591    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SharedFoldersDialog));
     592    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_VRDEServer));
     593    m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InstallGuestTools));
    329594}
    330595
     
    394659}
    395660
    396 void UIMachineLogic::prepareActionGroups()
    397 {
    398 #ifdef Q_WS_MAC
    399     /* On Mac OS X, all QMenu's are consumed by Qt after they are added to
    400      * another QMenu or a QMenuBar. This means we have to recreate all QMenus
    401      * when creating a new QMenuBar. */
    402     gActionPool->recreateMenus();
    403 #endif /* Q_WS_MAC */
    404 
    405     /* Create group for all actions that are enabled only when the VM is running.
    406      * Note that only actions whose enabled state depends exclusively on the
    407      * execution state of the VM are added to this group. */
    408     m_pRunningActions = new QActionGroup(this);
    409     m_pRunningActions->setExclusive(false);
    410 
    411     /* Create group for all actions that are enabled when the VM is running or paused.
    412      * Note that only actions whose enabled state depends exclusively on the
    413      * execution state of the VM are added to this group. */
    414     m_pRunningOrPausedActions = new QActionGroup(this);
    415     m_pRunningOrPausedActions->setExclusive(false);
    416 
    417     /* Move actions into running actions group: */
    418     m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCAD));
    419 #ifdef Q_WS_X11
    420     m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCABS));
    421 #endif
    422     m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Reset));
    423     m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Shutdown));
    424     m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen));
    425     m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless));
    426     m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Scale));
    427     m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize));
    428     m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow));
    429 
    430     /* Move actions into running-n-paused actions group: */
    431     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog));
    432     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot));
    433     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot));
    434     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog));
    435     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_MouseIntegration));
    436     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration));
    437     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Pause));
    438     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices));
    439     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices));
    440     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_USBDevices));
    441     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_NetworkAdapters));
    442     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_NetworkAdaptersDialog));
    443     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_SharedFolders));
    444     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SharedFoldersDialog));
    445     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_VRDEServer));
    446     m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InstallGuestTools));
    447 }
    448 
    449661void UIMachineLogic::prepareHandlers()
    450662{
     
    529741#endif /* Q_WS_MAC */
    530742
    531 void UIMachineLogic::prepareRequiredFeatures()
    532 {
    533 #ifdef Q_WS_MAC
    534 # ifdef VBOX_WITH_ICHAT_THEATER
    535     /* Init shared AV manager: */
    536     initSharedAVManager();
    537 # endif
    538 #endif
    539 }
    540 
    541743#ifdef VBOX_WITH_DEBUGGER_GUI
    542744void UIMachineLogic::prepareDebugger()
     
    563765#endif /* VBOX_WITH_DEBUGGER_GUI */
    564766
     767#ifdef VBOX_WITH_DEBUGGER_GUI
     768void UIMachineLogic::cleanupDebugger()
     769{
     770    /* Close debugger: */
     771    dbgDestroy();
     772}
     773#endif /* VBOX_WITH_DEBUGGER_GUI */
     774
    565775#ifdef Q_WS_MAC
    566776void UIMachineLogic::cleanupDock()
     
    583793}
    584794
    585 void UIMachineLogic::sltMachineStateChanged()
    586 {
    587     /* Get machine state: */
    588     KMachineState state = uisession()->machineState();
    589 
    590     /* Update action groups: */
    591     m_pRunningActions->setEnabled(uisession()->isRunning());
    592     m_pRunningOrPausedActions->setEnabled(uisession()->isRunning() || uisession()->isPaused());
    593 
    594     switch (state)
    595     {
    596         case KMachineState_Stuck: // TODO: Test it!
    597         {
    598             /* Prevent machine view from resizing: */
    599             uisession()->setGuestResizeIgnored(true);
    600 
    601             /* Get console and log folder. */
    602             CConsole console = session().GetConsole();
    603             const QString &strLogFolder = console.GetMachine().GetLogFolder();
    604 
    605             /* Take the screenshot for debugging purposes and save it. */
    606             takeScreenshot(strLogFolder + "/VBox.png", "png");
    607 
    608             /* Warn the user about GURU: */
    609             if (msgCenter().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder)))
    610             {
    611                 console.PowerDown();
    612                 if (!console.isOk())
    613                     msgCenter().cannotStopMachine(console);
    614             }
    615             break;
    616         }
    617         case KMachineState_Paused:
    618         case KMachineState_TeleportingPausedVM:
    619         {
    620             QAction *pPauseAction = gActionPool->action(UIActionIndexRuntime_Toggle_Pause);
    621             if (!pPauseAction->isChecked())
    622             {
    623                 /* Was paused from CSession side: */
    624                 pPauseAction->blockSignals(true);
    625                 pPauseAction->setChecked(true);
    626                 pPauseAction->blockSignals(false);
    627             }
    628             break;
    629         }
    630         case KMachineState_Running:
    631         case KMachineState_Teleporting:
    632         case KMachineState_LiveSnapshotting:
    633         {
    634             QAction *pPauseAction = gActionPool->action(UIActionIndexRuntime_Toggle_Pause);
    635             if (pPauseAction->isChecked())
    636             {
    637                 /* Was resumed from CSession side: */
    638                 pPauseAction->blockSignals(true);
    639                 pPauseAction->setChecked(false);
    640                 pPauseAction->blockSignals(false);
    641             }
    642             break;
    643         }
    644         case KMachineState_PoweredOff:
    645         case KMachineState_Saved:
    646         case KMachineState_Teleported:
    647         case KMachineState_Aborted:
    648         {
    649             /* Close VM if it was turned off and closure allowed: */
    650             if (!isPreventAutoClose())
    651             {
    652                 /* VM has been powered off, saved or aborted, no matter
    653                  * internally or externally. We must *safely* close VM window(s): */
    654                 QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession()));
    655             }
    656             break;
    657         }
    658 #ifdef Q_WS_X11
    659         case KMachineState_Starting:
    660         case KMachineState_Restoring:
    661         case KMachineState_TeleportingIn:
    662         {
    663             /* The keyboard handler may wish to do some release logging on startup.
    664              * Tell it that the logger is now active. */
    665             doXKeyboardLogging(QX11Info::display());
    666             break;
    667         }
    668 #endif
    669         default:
    670             break;
    671     }
    672 
    673 #ifdef Q_WS_MAC
    674     /* Update Dock Overlay: */
    675     updateDockOverlay();
    676 #endif /* Q_WS_MAC */
    677 }
    678 
    679 void UIMachineLogic::sltAdditionsStateChanged()
    680 {
    681     /* Variable flags: */
    682     bool fIsSupportsGraphics = uisession()->isGuestSupportsGraphics();
    683     bool fIsSupportsSeamless = uisession()->isGuestSupportsSeamless();
    684 
    685     /* Update action states: */
    686     gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setEnabled(fIsSupportsGraphics);
    687     gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->setEnabled(fIsSupportsSeamless);
    688 
    689     /* Check if we should enter some extended mode: */
    690     sltCheckRequestedModes();
    691 }
    692 
    693 void UIMachineLogic::sltMouseCapabilityChanged()
    694 {
    695     /* Variable falgs: */
    696     bool fIsMouseSupportsAbsolute = uisession()->isMouseSupportsAbsolute();
    697     bool fIsMouseSupportsRelative = uisession()->isMouseSupportsRelative();
    698     bool fIsMouseHostCursorNeeded = uisession()->isMouseHostCursorNeeded();
    699 
    700     /* Update action state: */
    701     QAction *pAction = gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration);
    702     pAction->setEnabled(fIsMouseSupportsAbsolute && fIsMouseSupportsRelative && !fIsMouseHostCursorNeeded);
    703     if (fIsMouseHostCursorNeeded)
    704         pAction->setChecked(false);
    705 }
    706 
    707 void UIMachineLogic::sltUSBDeviceStateChange(const CUSBDevice &device, bool fIsAttached, const CVirtualBoxErrorInfo &error)
    708 {
    709     bool fSuccess = error.isNull();
    710 
    711     if (!fSuccess)
    712     {
    713         if (fIsAttached)
    714             msgCenter().cannotAttachUSBDevice(session().GetConsole(), vboxGlobal().details(device), error);
    715         else
    716             msgCenter().cannotDetachUSBDevice(session().GetConsole(), vboxGlobal().details(device), error);
    717     }
    718 }
    719 
    720 void UIMachineLogic::sltRuntimeError(bool fIsFatal, const QString &strErrorId, const QString &strMessage)
    721 {
    722     msgCenter().showRuntimeError(session().GetConsole(), fIsFatal, strErrorId, strMessage);
    723 }
    724 
    725 #ifdef Q_WS_MAC
    726 void UIMachineLogic::sltShowWindows()
    727 {
    728     for (int i=0; i < m_machineWindowsList.size(); ++i)
    729     {
    730         UIMachineWindow *pMachineWindow = m_machineWindowsList.at(i);
    731         /* Dunno what Qt thinks a window that has minimized to the dock
    732          * should be - it is not hidden, neither is it minimized. OTOH it is
    733          * marked shown and visible, but not activated. This latter isn't of
    734          * much help though, since at this point nothing is marked activated.
    735          * I might have overlooked something, but I'm buggered what if I know
    736          * what. So, I'll just always show & activate the stupid window to
    737          * make it get out of the dock when the user wishes to show a VM. */
    738         pMachineWindow->machineWindow()->raise();
    739         pMachineWindow->machineWindow()->activateWindow();
    740     }
    741 }
    742 #endif /* Q_WS_MAC */
     795void UIMachineLogic::cleanupActionGroups()
     796{
     797}
    743798
    744799void UIMachineLogic::sltCheckRequestedModes()
     
    832887    AssertWrapperOk(keyboard);
    833888}
    834 #endif
     889#endif /* Q_WS_X11 */
    835890
    836891void UIMachineLogic::sltTakeSnapshot()
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r41063 r41064  
    2525#ifdef VBOX_WITH_DEBUGGER_GUI
    2626# include <VBox/dbggui.h>
    27 #endif
     27#endif /* VBOX_WITH_DEBUGGER_GUI */
    2828
    2929/* Global forwards */
     
    4444class UIDockIconPreview;
    4545
     46/* Machine logic interface: */
    4647class UIMachineLogic : public QIWithRetranslateUI3<QObject>
    4748{
     
    5152
    5253    /* Factory functions to create/destroy required logic sub-child: */
    53     static UIMachineLogic* create(QObject *pParent,
    54                                   UISession *pSession,
    55                                   UIVisualStateType visualStateType);
     54    static UIMachineLogic* create(QObject *pParent, UISession *pSession, UIVisualStateType visualStateType);
    5655    static void destroy(UIMachineLogic *pWhichLogic);
    5756
    58     /* Check if this mode is available: */
    59     virtual bool checkAvailability();
    60 
    61     /* Do the real initialization of the object: */
    62     virtual void initialize() = 0;
     57    /* Check if this logic is available: */
     58    virtual bool checkAvailability() = 0;
     59
     60    /* Prepare/cleanup the logic: */
     61    virtual void prepare();
     62    virtual void cleanup();
    6363
    6464    /* Main getters/setters: */
     
    8282#endif /* Q_WS_MAC */
    8383
    84 protected:
    85 
    86     /* Machine logic constructor/destructor: */
    87     UIMachineLogic(QObject *pParent,
    88                    UISession *pSession,
    89                    UIVisualStateType visualStateType);
    90     virtual ~UIMachineLogic();
    91 
    92     /* Protected getters/setters: */
    93     bool isMachineWindowsCreated() const { return m_fIsWindowsCreated; }
    94     void setMachineWindowsCreated(bool fIsWindowsCreated) { m_fIsWindowsCreated = fIsWindowsCreated; }
    95 
    96     /* Protected members: */
    97     void setKeyboardHandler(UIKeyboardHandler *pKeyboardHandler);
    98     void setMouseHandler(UIMouseHandler *pMouseHandler);
    99     void addMachineWindow(UIMachineWindow *pMachineWindow);
    100     void retranslateUi();
    101 #ifdef Q_WS_MAC
    102     bool isDockIconPreviewEnabled() const { return m_fIsDockIconEnabled; }
    103     void setDockIconPreviewEnabled(bool fIsDockIconPreviewEnabled) { m_fIsDockIconEnabled = fIsDockIconPreviewEnabled; }
    104     void updateDockOverlay();
    105 #endif /* Q_WS_MAC */
    106 
    107     /* Prepare helpers: */
    108     virtual void prepareSessionConnections();
    109     virtual void prepareActionConnections();
    110     virtual void prepareActionGroups();
    111     virtual void prepareHandlers();
    112 #ifdef Q_WS_MAC
    113     virtual void prepareDock();
    114 #endif /* Q_WS_MAC */
    115     virtual void prepareRequiredFeatures();
    116 #ifdef VBOX_WITH_DEBUGGER_GUI
    117     virtual void prepareDebugger();
    118 #endif /* VBOX_WITH_DEBUGGER_GUI */
    119 
    120     /* Cleanup helpers: */
    121     //virtual void cleanupRequiredFeatures() {}
    122 #ifdef Q_WS_MAC
    123     virtual void cleanupDock();
    124 #endif /* Q_WS_MAC */
    125     virtual void cleanupHandlers();
    126     //virtual void cleanupActionGroups() {}
    127     //virtual void cleanupActionConnections() {}
    128     //virtual void cleanupSessionConnections() {}
    129 
    13084protected slots:
    13185
     
    14094#endif /* RT_OS_DARWIN */
    14195
     96protected:
     97
     98    /* Constructor: */
     99    UIMachineLogic(QObject *pParent, UISession *pSession, UIVisualStateType visualStateType);
     100
     101    /* Protected getters/setters: */
     102    bool isMachineWindowsCreated() const { return m_fIsWindowsCreated; }
     103    void setMachineWindowsCreated(bool fIsWindowsCreated) { m_fIsWindowsCreated = fIsWindowsCreated; }
     104
     105    /* Protected members: */
     106    void setKeyboardHandler(UIKeyboardHandler *pKeyboardHandler);
     107    void setMouseHandler(UIMouseHandler *pMouseHandler);
     108    void addMachineWindow(UIMachineWindow *pMachineWindow);
     109    void retranslateUi();
     110#ifdef Q_WS_MAC
     111    bool isDockIconPreviewEnabled() const { return m_fIsDockIconEnabled; }
     112    void setDockIconPreviewEnabled(bool fIsDockIconPreviewEnabled) { m_fIsDockIconEnabled = fIsDockIconPreviewEnabled; }
     113    void updateDockOverlay();
     114#endif /* Q_WS_MAC */
     115
     116    /* Prepare helpers: */
     117    virtual void prepareRequiredFeatures();
     118    virtual void prepareSessionConnections();
     119    virtual void prepareActionGroups();
     120    virtual void prepareActionConnections();
     121    virtual void prepareHandlers();
     122    virtual void prepareMachineWindows() = 0;
     123#ifdef Q_WS_MAC
     124    virtual void prepareDock();
     125#endif /* Q_WS_MAC */
     126#ifdef VBOX_WITH_DEBUGGER_GUI
     127    virtual void prepareDebugger();
     128#endif /* VBOX_WITH_DEBUGGER_GUI */
     129
     130    /* Cleanup helpers: */
     131#ifdef VBOX_WITH_DEBUGGER_GUI
     132    virtual void cleanupDebugger();
     133#endif /* VBOX_WITH_DEBUGGER_GUI */
     134#ifdef Q_WS_MAC
     135    virtual void cleanupDock();
     136#endif /* Q_WS_MAC */
     137    virtual void cleanupMachineWindows() = 0;
     138    virtual void cleanupHandlers();
     139    //virtual void cleanupActionConnections() {}
     140    virtual void cleanupActionGroups();
     141    //virtual void cleanupSessionConnections() {}
     142    //virtual void cleanupRequiredFeatures() {}
     143
     144private slots:
     145
    142146    /* Mode request watch dog: */
    143147    void sltCheckRequestedModes();
    144148
    145 private slots:
    146 
    147     /* "Machine" menu functionality */
     149    /* "Machine" menu functionality: */
    148150    void sltToggleGuestAutoresize(bool fEnabled);
    149151    void sltAdjustWindow();
     
    152154#ifdef Q_WS_X11
    153155    void sltTypeCABS();
    154 #endif
    155 
     156#endif /* Q_WS_X11 */
    156157    void sltTakeSnapshot();
    157158    void sltTakeScreenshot();
     
    162163    void sltClose();
    163164
    164     /* "Device" menu functionality */
     165    /* "Device" menu functionality: */
    165166    void sltOpenVMSettingsDialog(const QString &strCategory = QString());
    166167    void sltOpenNetworkAdaptersDialog();
     
    175176
    176177#ifdef VBOX_WITH_DEBUGGER_GUI
     178    /* "Debug" menu functionality: */
    177179    void sltPrepareDebugMenu();
    178180    void sltShowDebugStatistics();
     
    180182    void sltLoggingToggled(bool);
    181183    void sltShowLogDialog();
    182 #endif
     184#endif /* VBOX_WITH_DEBUGGER_GUI */
    183185
    184186#ifdef RT_OS_DARWIN /* Something is *really* broken in regards of the moc here */
     
    190192private:
    191193
    192     /* Utility functions: */
    193     static int searchMaxSnapshotIndex(const CMachine &machine,
    194                                       const CSnapshot &snapshot,
    195                                       const QString &strNameTemplate);
    196 
     194    /* Helpers: */
     195    static int searchMaxSnapshotIndex(const CMachine &machine, const CSnapshot &snapshot, const QString &strNameTemplate);
    197196    void takeScreenshot(const QString &strFile, const QString &strFormat /* = "png" */) const;
    198197
     
    219218    /* The virtual method table for the debugger GUI: */
    220219    PCDBGGUIVT m_pDbgGuiVT;
    221 #endif
     220#endif /* VBOX_WITH_DEBUGGER_GUI */
    222221
    223222#ifdef Q_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r38348 r41064  
    77
    88/*
    9  * Copyright (C) 2010 Oracle Corporation
     9 * Copyright (C) 2010-2012 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1818 */
    1919
    20 /* Global includes */
     20/* Global includes: */
    2121#include <QDesktopWidget>
    2222
    23 /* Local includes */
     23/* Local includes: */
    2424#include "COMDefs.h"
    2525#include "VBoxGlobal.h"
    2626#include "UIMessageCenter.h"
    27 
    2827#include "UISession.h"
    2928#include "UIActionPoolRuntime.h"
     
    3130#include "UIMachineWindowFullscreen.h"
    3231#include "UIMultiScreenLayout.h"
    33 
    3432#ifdef Q_WS_MAC
    3533# include "UIExtraDataEventHandler.h"
     
    4139    : UIMachineLogic(pParent, pSession, UIVisualStateType_Fullscreen)
    4240{
     41    /* Create multiscreen layout: */
    4342    m_pScreenLayout = new UIMultiScreenLayout(this);
    4443}
     
    4645UIMachineLogicFullscreen::~UIMachineLogicFullscreen()
    4746{
    48 #ifdef Q_WS_MAC
    49     /* Cleanup the dock stuff before the machine window(s): */
    50     cleanupDock();
    51 #endif /* Q_WS_MAC */
    52 
    53     /* Cleanup machine window(s): */
    54     cleanupMachineWindows();
    55 
    56     /* Cleanup handlers: */
    57     cleanupHandlers();
    58 
    59     /* Cleanup action related stuff */
    60     cleanupActionGroups();
    61 
     47    /* Delete multiscreen layout: */
    6248    delete m_pScreenLayout;
    6349}
     
    6551bool UIMachineLogicFullscreen::checkAvailability()
    6652{
    67     /* Base class availability: */
    68     if (!UIMachineLogic::checkAvailability())
    69         return false;
    70 
    7153    /* Temporary get a machine object: */
    7254    const CMachine &machine = uisession()->session().GetMachine();
    7355
     56    /* Check that there are enough physical screens are connected: */
    7457    int cHostScreens = m_pScreenLayout->hostScreenCount();
    7558    int cGuestScreens = m_pScreenLayout->guestScreenCount();
    76     /* Check that there are enough physical screens are connected: */
    7759    if (cHostScreens < cGuestScreens)
    7860    {
     
    8163    }
    8264
    83     // TODO_NEW_CORE: this is how it looked in the old version
    84     // bool VBoxConsoleView::isAutoresizeGuestActive() { return mGuestSupportsGraphics && mAutoresizeGuest; }
    85 //    if (uisession()->session().GetConsole().isAutoresizeGuestActive())
     65    /* Check if there is enough physical memory to enter fullscreen: */
    8666    if (uisession()->isGuestAdditionsActive())
    8767    {
    88         quint64 availBits = machine.GetVRAMSize() /* VRAM */
    89                             * _1M /* MiB to bytes */
    90                             * 8; /* to bits */
     68        quint64 availBits = machine.GetVRAMSize() /* VRAM */ * _1M /* MiB to bytes */ * 8 /* to bits */;
    9169        quint64 usedBits = m_pScreenLayout->memoryRequirements();
    9270        if (availBits < usedBits)
    9371        {
    9472            int result = msgCenter().cannotEnterFullscreenMode(0, 0, 0,
    95                                                                  (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
     73                                                               (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
    9674            if (result == QIMessageBox::Cancel)
    9775                return false;
     
    9977    }
    10078
    101     /* Take the toggle hot key from the menu item. Since
    102      * VBoxGlobal::extractKeyFromActionText gets exactly the
    103      * linked key without the 'Host+' part we are adding it here. */
     79    /* Take the toggle hot key from the menu item.
     80     * Since VBoxGlobal::extractKeyFromActionText gets exactly
     81     * the linked key without the 'Host+' part we are adding it here. */
    10482    QString hotKey = QString("Host+%1")
    10583        .arg(VBoxGlobal::extractKeyFromActionText(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen)->text()));
     
    11391}
    11492
    115 void UIMachineLogicFullscreen::initialize()
    116 {
    117     /* Prepare required features: */
    118     prepareRequiredFeatures();
    119 
    120 #ifdef Q_WS_MAC
    121     /* Prepare common connections: */
    122     prepareCommonConnections();
    123 #endif /* Q_WS_MAC */
    124 
    125     /* Prepare console connections: */
    126     prepareSessionConnections();
    127 
    128     /* Prepare action groups:
    129      * Note: This has to be done before prepareActionConnections
    130      * cause here actions/menus are recreated. */
    131     prepareActionGroups();
    132 
    133     /* Prepare action connections: */
    134     prepareActionConnections();
    135 
    136     /* Prepare handlers: */
    137     prepareHandlers();
    138 
    139     /* Prepare machine window: */
    140     prepareMachineWindows();
    141 
    142 #ifdef Q_WS_MAC
    143     /* Prepare dock: */
    144     prepareDock();
    145 #endif /* Q_WS_MAC */
    146 
    147     /* Power up machine: */
    148     uisession()->powerUp();
    149 
    150     /* Initialization: */
    151     sltMachineStateChanged();
    152     sltAdditionsStateChanged();
    153     sltMouseCapabilityChanged();
    154 
    155 #ifdef VBOX_WITH_DEBUGGER_GUI
    156     prepareDebugger();
    157 #endif /* VBOX_WITH_DEBUGGER_GUI */
    158 
    159     /* Retranslate logic part: */
    160     retranslateUi();
     93void UIMachineLogicFullscreen::prepare()
     94{
     95    /* Call to base-class: */
     96    UIMachineLogic::prepare();
     97
     98#ifdef Q_WS_MAC
     99    /* Prepare fullscreen connections: */
     100    prepareFullscreenConnections();
     101#endif /* Q_WS_MAC */
    161102}
    162103
     
    167108
    168109#ifdef Q_WS_MAC
    169 void UIMachineLogicFullscreen::prepareCommonConnections()
    170 {
    171     /* Presentation mode connection */
     110void UIMachineLogicFullscreen::prepareFullscreenConnections()
     111{
     112    /* Presentation mode connection: */
    172113    connect(gEDataEvents, SIGNAL(sigPresentationModeChange(bool)),
    173114            this, SLOT(sltChangePresentationMode(bool)));
     
    177118void UIMachineLogicFullscreen::prepareActionGroups()
    178119{
    179     /* Base class action groups: */
     120    /* Call to base-class: */
    180121    UIMachineLogic::prepareActionGroups();
    181122
     
    186127    QMenu *pMenu = gActionPool->action(UIActionIndexRuntime_Menu_View)->menu();
    187128    m_pScreenLayout->initialize(pMenu);
     129    pMenu->setVisible(true);
    188130}
    189131
     
    242184void UIMachineLogicFullscreen::cleanupActionGroups()
    243185{
     186    /* Call to base-class: */
     187    UIMachineLogic::cleanupActionGroups();
     188
    244189    /* Reenable adjust-window action: */
    245190    gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow)->setVisible(true);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h

    r38348 r41064  
    66
    77/*
    8  * Copyright (C) 2010 Oracle Corporation
     8 * Copyright (C) 2010-2012 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020#define __UIMachineLogicFullscreen_h__
    2121
    22 /* Local includes */
     22/* Local includes: */
    2323#include "UIMachineLogic.h"
    2424
    25 /* Local forwards */
     25/* Forward declarations: */
    2626class UIMultiScreenLayout;
    2727
     28/* Fullscreen machine logic implementation: */
    2829class UIMachineLogicFullscreen : public UIMachineLogic
    2930{
     
    3233protected:
    3334
    34     /* Fullscreen machine logic constructor/destructor: */
    35     UIMachineLogicFullscreen(QObject *pParent,
    36                              UISession *pSession);
     35    /* Constructor/destructor: */
     36    UIMachineLogicFullscreen(QObject *pParent, UISession *pSession);
    3737    virtual ~UIMachineLogicFullscreen();
    3838
     39    /* Check if this logic is available: */
    3940    bool checkAvailability();
    40     void initialize();
     41
     42    /* Prepare logic: */
     43    void prepare();
    4144
    4245    int hostScreenForGuestScreen(int screenId) const;
     
    5255
    5356    /* Prepare helpers: */
    54 #ifdef Q_WS_MAC
    55     void prepareCommonConnections();
    56 #endif /* Q_WS_MAC */
    5757    void prepareActionGroups();
    5858    void prepareMachineWindows();
     59#ifdef Q_WS_MAC
     60    void prepareFullscreenConnections();
     61#endif /* Q_WS_MAC */
    5962
    6063    /* Cleanup helpers: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r39932 r41064  
    77
    88/*
    9  * Copyright (C) 2010 Oracle Corporation
     9 * Copyright (C) 2010-2012 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1818 */
    1919
    20 /* Global includes */
     20/* Global includes: */
    2121#include <QMenu>
    2222
    23 /* Local includes */
     23/* Local includes: */
    2424#include "COMDefs.h"
    2525#include "VBoxGlobal.h"
    2626#include "UIMessageCenter.h"
    27 
    2827#include "UISession.h"
    2928#include "UIActionPoolRuntime.h"
     
    3332#include "UIDownloaderUserManual.h"
    3433#include "UIDownloaderExtensionPack.h"
    35 
    3634#ifdef Q_WS_MAC
    3735#include "VBoxUtils.h"
     
    4341}
    4442
    45 UIMachineLogicNormal::~UIMachineLogicNormal()
     43bool UIMachineLogicNormal::checkAvailability()
    4644{
    47 #ifdef Q_WS_MAC
    48     /* Cleanup the dock stuff before the machine window(s): */
    49     cleanupDock();
    50 #endif /* Q_WS_MAC */
    51 
    52     /* Cleanup machine window(s): */
    53     cleanupMachineWindow();
    54 
    55     /* Cleanup handlers: */
    56     cleanupHandlers();
    57 }
    58 
    59 void UIMachineLogicNormal::initialize()
    60 {
    61     /* Prepare required features: */
    62     prepareRequiredFeatures();
    63 
    64     /* Prepare session connections: */
    65     prepareSessionConnections();
    66 
    67     /* Prepare action groups:
    68      * Note: This has to be done before prepareActionConnections
    69      * cause here actions/menus are recreated. */
    70     prepareActionGroups();
    71 
    72     /* Prepare action connections: */
    73     prepareActionConnections();
    74 
    75     /* Prepare handlers: */
    76     prepareHandlers();
    77 
    78     /* Prepare normal machine window: */
    79     prepareMachineWindows();
    80 
    81 #ifdef Q_WS_MAC
    82     /* Prepare dock: */
    83     prepareDock();
    84 #endif /* Q_WS_MAC */
    85 
    86     /* Power up machine: */
    87     uisession()->powerUp();
    88 
    89     /* Initialization: */
    90     sltMachineStateChanged();
    91     sltAdditionsStateChanged();
    92     sltMouseCapabilityChanged();
    93 
    94 #ifdef VBOX_WITH_DEBUGGER_GUI
    95     prepareDebugger();
    96 #endif /* VBOX_WITH_DEBUGGER_GUI */
    97 
    98     /* Retranslate logic part: */
    99     retranslateUi();
     45    /* Normal mode is always available: */
     46    return true;
    10047}
    10148
     
    163110}
    164111
    165 void UIMachineLogicNormal::cleanupMachineWindow()
     112void UIMachineLogicNormal::cleanupMachineWindows()
    166113{
    167114    /* Do not cleanup machine window(s) if not present: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h

    r38348 r41064  
    66
    77/*
    8  * Copyright (C) 2010 Oracle Corporation
     8 * Copyright (C) 2010-2012 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020#define __UIMachineLogicNormal_h__
    2121
    22 /* Local includes */
     22/* Local includes: */
    2323#include "UIMachineLogic.h"
    2424
     25/* Normal machine logic implementation: */
    2526class UIMachineLogicNormal : public UIMachineLogic
    2627{
     
    2930protected:
    3031
    31     /* Normal machine logic constructor/destructor: */
    32     UIMachineLogicNormal(QObject *pParent,
    33                          UISession *pSession);
    34     virtual ~UIMachineLogicNormal();
     32    /* Constructor: */
     33    UIMachineLogicNormal(QObject *pParent, UISession *pSession);
    3534
    36     void initialize();
     35    /* Check if this logic is available: */
     36    bool checkAvailability();
    3737
    3838private slots:
     
    5050
    5151    /* Cleanup helpers: */
    52     void cleanupMachineWindow();
     52    void cleanupMachineWindows();
    5353    //void cleanupActionConnections() {}
    5454
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineLogicScale.cpp

    r39932 r41064  
    77
    88/*
    9  * Copyright (C) 2010 Oracle Corporation
     9 * Copyright (C) 2010-2012 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1818 */
    1919
    20 /* Local includes */
     20/* Local includes: */
    2121#include "COMDefs.h"
    2222#include "VBoxGlobal.h"
    2323#include "UIMessageCenter.h"
    24 
    2524#include "UISession.h"
    2625#include "UIActionPoolRuntime.h"
     
    2928#include "UIDownloaderAdditions.h"
    3029#include "UIDownloaderExtensionPack.h"
    31 
    3230#ifdef Q_WS_MAC
    3331#include "VBoxUtils.h"
     
    3937}
    4038
    41 UIMachineLogicScale::~UIMachineLogicScale()
    42 {
    43 #ifdef Q_WS_MAC
    44     /* Cleanup the dock stuff before the machine window(s): */
    45     cleanupDock();
    46 #endif /* Q_WS_MAC */
    47 
    48     /* Cleanup machine window(s): */
    49     cleanupMachineWindow();
    50 
    51     /* Cleanup handlers: */
    52     cleanupHandlers();
    53 
    54     /* Cleanup actions groups: */
    55     cleanupActionGroups();
    56 }
    57 
    5839bool UIMachineLogicScale::checkAvailability()
    5940{
    60     /* Base class availability: */
    61     if (!UIMachineLogic::checkAvailability())
    62         return false;
    63 
    64     /* Take the toggle hot key from the menu item. Since
    65      * VBoxGlobal::extractKeyFromActionText gets exactly the
    66      * linked key without the 'Host+' part we are adding it here. */
     41    /* Take the toggle hot key from the menu item.
     42     * Since VBoxGlobal::extractKeyFromActionText gets exactly
     43     * the linked key without the 'Host+' part we are adding it here. */
    6744    QString strHotKey = QString("Host+%1")
    6845        .arg(VBoxGlobal::extractKeyFromActionText(gActionPool->action(UIActionIndexRuntime_Toggle_Scale)->text()));
     
    7653}
    7754
    78 void UIMachineLogicScale::initialize()
    79 {
    80     /* Prepare required features: */
    81     prepareRequiredFeatures();
    82 
    83     /* Prepare session connections: */
    84     prepareSessionConnections();
    85 
    86     /* Prepare action groups:
    87      * Note: This has to be done before prepareActionConnections
    88      * cause here actions/menus are recreated. */
    89     prepareActionGroups();
    90 
    91     /* Prepare action connections: */
    92     prepareActionConnections();
    93 
    94     /* Prepare handlers: */
    95     prepareHandlers();
    96 
    97     /* Prepare scale machine window: */
    98     prepareMachineWindows();
    99 
    100 #ifdef Q_WS_MAC
    101     /* Prepare dock: */
    102     prepareDock();
    103 #endif /* Q_WS_MAC */
    104 
    105     /* Power up machine: */
    106     uisession()->powerUp();
    107 
    108     /* Initialization: */
    109     sltMachineStateChanged();
    110     sltAdditionsStateChanged();
    111     sltMouseCapabilityChanged();
    112 
    113 #ifdef VBOX_WITH_DEBUGGER_GUI
    114     prepareDebugger();
    115 #endif /* VBOX_WITH_DEBUGGER_GUI */
    116 
    117     /* Retranslate logic part: */
    118     retranslateUi();
    119 }
    120 
    12155void UIMachineLogicScale::prepareActionGroups()
    12256{
    123     /* Base class action groups: */
     57    /* Call to base-class: */
    12458    UIMachineLogic::prepareActionGroups();
    12559
     
    15690}
    15791
    158 void UIMachineLogicScale::cleanupMachineWindow()
     92void UIMachineLogicScale::cleanupMachineWindows()
    15993{
    16094    /* Do not cleanup machine window(s) if not present: */
     
    169103void UIMachineLogicScale::cleanupActionGroups()
    170104{
     105    /* Call to base-class: */
     106    UIMachineLogic::cleanupActionGroups();
     107
    171108    /* Reenable guest-autoresize action: */
    172109    gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setVisible(true);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineLogicScale.h

    r38348 r41064  
    66
    77/*
    8  * Copyright (C) 2010 Oracle Corporation
     8 * Copyright (C) 2010-2012 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020#define __UIMachineLogicScale_h__
    2121
    22 /* Local includes */
     22/* Local includes: */
    2323#include "UIMachineLogic.h"
    2424
     25/* Scale machine logic implementation: */
    2526class UIMachineLogicScale : public UIMachineLogic
    2627{
     
    2930protected:
    3031
    31     /* Scale machine logic constructor/destructor: */
    32     UIMachineLogicScale(QObject *pParent,
    33                         UISession *pSession);
    34     virtual ~UIMachineLogicScale();
     32    /* Constructor: */
     33    UIMachineLogicScale(QObject *pParent, UISession *pSession);
    3534
     35    /* Check if this logic is available: */
    3636    bool checkAvailability();
    37     void initialize();
    3837
    3938private:
     
    4443
    4544    /* Cleanup helpers: */
    46     void cleanupMachineWindow();
     45    void cleanupMachineWindows();
    4746    void cleanupActionGroups();
    4847
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp

    r38348 r41064  
    77
    88/*
    9  * Copyright (C) 2010 Oracle Corporation
     9 * Copyright (C) 2010-2012 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1818 */
    1919
    20 /* Global includes */
     20/* Global includes: */
    2121#include <QDesktopWidget>
    2222
    23 /* Local includes */
     23/* Local includes: */
    2424#include "COMDefs.h"
    2525#include "VBoxGlobal.h"
    2626#include "UIMessageCenter.h"
    27 
    2827#include "UISession.h"
    2928#include "UIActionPoolRuntime.h"
     
    3130#include "UIMachineWindowSeamless.h"
    3231#include "UIMultiScreenLayout.h"
    33 
    3432#ifdef Q_WS_MAC
    3533# include "VBoxUtils.h"
     
    3937    : UIMachineLogic(pParent, pSession, UIVisualStateType_Seamless)
    4038{
     39    /* Create multiscreen layout: */
    4140    m_pScreenLayout = new UIMultiScreenLayout(this);
    4241}
     
    4443UIMachineLogicSeamless::~UIMachineLogicSeamless()
    4544{
    46 #ifdef Q_WS_MAC
    47     /* Cleanup the dock stuff before the machine window(s): */
    48     cleanupDock();
    49 #endif /* Q_WS_MAC */
    50 
    51     /* Cleanup machine window(s): */
    52     cleanupMachineWindows();
    53 
    54     /* Cleanup handlers: */
    55     cleanupHandlers();
    56 
    57     /* Cleanup actions groups: */
    58     cleanupActionGroups();
    59 
     45    /* Delete multiscreen layout: */
    6046    delete m_pScreenLayout;
    6147}
     
    6349bool UIMachineLogicSeamless::checkAvailability()
    6450{
    65     /* Base class availability: */
    66     if (!UIMachineLogic::checkAvailability())
    67         return false;
    68 
    6951    /* Temporary get a machine object: */
    7052    const CMachine &machine = uisession()->session().GetMachine();
    7153
     54    /* Check that there are enough physical screens are connected: */
    7255    int cHostScreens = m_pScreenLayout->hostScreenCount();
    7356    int cGuestScreens = m_pScreenLayout->guestScreenCount();
    74     /* Check that there are enough physical screens are connected: */
    7557    if (cHostScreens < cGuestScreens)
    7658    {
     
    7961    }
    8062
    81     // TODO_NEW_CORE: this is how it looked in the old version
    82     // bool VBoxConsoleView::isAutoresizeGuestActive() { return mGuestSupportsGraphics && mAutoresizeGuest; }
    83 //    if (uisession()->session().GetConsole().isAutoresizeGuestActive())
     63    /* Check if there is enough physical memory to enter seamless: */
    8464    if (uisession()->isGuestAdditionsActive())
    8565    {
    86         quint64 availBits = machine.GetVRAMSize() /* VRAM */
    87                             * _1M /* MiB to bytes */
    88                             * 8; /* to bits */
     66        quint64 availBits = machine.GetVRAMSize() /* VRAM */ * _1M /* MiB to bytes */ * 8 /* to bits */;
    8967        quint64 usedBits = m_pScreenLayout->memoryRequirements();
    9068        if (availBits < usedBits)
    9169        {
    9270            msgCenter().cannotEnterSeamlessMode(0, 0, 0,
    93                                                   (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
     71                                                (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
    9472            return false;
    9573        }
    9674    }
    9775
    98     /* Take the toggle hot key from the menu item. Since
    99      * VBoxGlobal::extractKeyFromActionText gets exactly the
    100      * linked key without the 'Host+' part we are adding it here. */
     76    /* Take the toggle hot key from the menu item.
     77     * Since VBoxGlobal::extractKeyFromActionText gets exactly
     78     * the linked key without the 'Host+' part we are adding it here. */
    10179    QString hotKey = QString("Host+%1")
    10280        .arg(VBoxGlobal::extractKeyFromActionText(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->text()));
     
    11088}
    11189
    112 void UIMachineLogicSeamless::initialize()
    113 {
    114     /* Prepare required features: */
    115     prepareRequiredFeatures();
    116 
    117     /* Prepare console connections: */
    118     prepareSessionConnections();
    119 
    120     /* Prepare action groups:
    121      * Note: This has to be done before prepareActionConnections
    122      * cause here actions/menus are recreated. */
    123     prepareActionGroups();
    124 
    125     /* Prepare action connections: */
    126     prepareActionConnections();
    127 
    128     /* Prepare handlers: */
    129     prepareHandlers();
    130 
    131     /* Prepare normal machine window: */
    132     prepareMachineWindows();
    133 
    134 #ifdef Q_WS_MAC
    135     /* Prepare dock: */
    136     prepareDock();
    137 #endif /* Q_WS_MAC */
    138 
    139     /* Power up machine: */
    140     uisession()->powerUp();
    141 
    142     /* Initialization: */
    143     sltMachineStateChanged();
    144     sltAdditionsStateChanged();
    145     sltMouseCapabilityChanged();
    146 
    147 #ifdef VBOX_WITH_DEBUGGER_GUI
    148     prepareDebugger();
    149 #endif /* VBOX_WITH_DEBUGGER_GUI */
    150 
    151     /* Retranslate logic part: */
    152     retranslateUi();
    153 }
    154 
    15590int UIMachineLogicSeamless::hostScreenForGuestScreen(int screenId) const
    15691{
     
    16095void UIMachineLogicSeamless::prepareActionGroups()
    16196{
    162     /* Base class action groups: */
     97    /* Call to base-class: */
    16398    UIMachineLogic::prepareActionGroups();
    16499
     
    219154void UIMachineLogicSeamless::cleanupActionGroups()
    220155{
     156    /* Call to base-class: */
     157    UIMachineLogic::cleanupActionGroups();
     158
    221159    /* Reenable guest-autoresize action: */
    222160    gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setVisible(true);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.h

    r38348 r41064  
    66
    77/*
    8  * Copyright (C) 2010 Oracle Corporation
     8 * Copyright (C) 2010-2012 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020#define __UIMachineLogicSeamless_h__
    2121
    22 /* Local includes */
     22/* Local includes: */
    2323#include "UIMachineLogic.h"
    2424
    25 /* Local forwards */
     25/* Forward declarations: */
    2626class UIMultiScreenLayout;
    2727
     28/* Seamless machine logic implementation: */
    2829class UIMachineLogicSeamless : public UIMachineLogic
    2930{
     
    3233protected:
    3334
    34     /* Seamless machine logic constructor/destructor: */
    35     UIMachineLogicSeamless(QObject *pParent,
    36                            UISession *pSession);
     35    /* Constructor/destructor: */
     36    UIMachineLogicSeamless(QObject *pParent, UISession *pSession);
    3737    virtual ~UIMachineLogicSeamless();
    3838
     39    /* Check if this logic is available: */
    3940    bool checkAvailability();
    40     void initialize();
    4141
    4242    int hostScreenForGuestScreen(int screenId) const;
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