VirtualBox

Changeset 41114 in vbox


Ignore:
Timestamp:
May 2, 2012 1:07:55 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: General machine-window refactoring/cleanup.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineDefs.h

    r30753 r41114  
    3535enum UIVisualElement
    3636{
    37     UIVisualElement_WindowCaption         = RT_BIT(0),
     37    UIVisualElement_WindowTitle           = RT_BIT(0),
    3838    UIVisualElement_MouseIntegrationStuff = RT_BIT(1),
    3939    UIVisualElement_PauseStuff            = RT_BIT(2),
     
    4646    UIVisualElement_SharedFolderStuff     = RT_BIT(9),
    4747    UIVisualElement_VirtualizationStuff   = RT_BIT(10),
     48    UIVisualElement_MiniToolBar           = RT_BIT(11),
    4849    UIVisualElement_AllStuff              = 0xFFFF
    4950};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r41107 r41114  
    1818 */
    1919
    20 /* Global includes */
     20/* Global includes: */
    2121#include <QCloseEvent>
    2222#include <QTimer>
    23 
    2423#include <VBox/version.h>
    2524#ifdef VBOX_BLEEDING_EDGE
     
    2726#endif /* VBOX_BLEEDING_EDGE */
    2827
    29 /* Local includes */
     28/* Local includes: */
    3029#include "COMDefs.h"
    3130#include "VBoxGlobal.h"
    3231#include "UIMessageCenter.h"
    33 
    3432#include "UIKeyboardHandler.h"
     33#include "UIMachineWindow.h"
    3534#include "UIMachineLogic.h"
    3635#include "UIMachineView.h"
    37 #include "UIMachineWindow.h"
     36#include "UIMachineWindowNormal.h"
    3837#include "UIMachineWindowFullscreen.h"
    39 #include "UIMachineWindowNormal.h"
     38#include "UIMachineWindowSeamless.h"
    4039#include "UIMachineWindowScale.h"
    41 #include "UIMachineWindowSeamless.h"
    4240#include "UIMouseHandler.h"
    4341#include "UISession.h"
    4442#include "UIVMCloseDialog.h"
    45 
    4643#ifdef Q_WS_X11
    4744# include <X11/Xlib.h>
    48 #endif
    49 
    50 UIMachineWindow* UIMachineWindow::create(UIMachineLogic *pMachineLogic, UIVisualStateType visualStateType, ulong uScreenId)
    51 {
    52     UIMachineWindow *window = 0;
    53     switch (visualStateType)
     45#endif /* Q_WS_X11 */
     46
     47/* static */
     48UIMachineWindow* UIMachineWindow::create(UIMachineLogic *pMachineLogic, ulong uScreenId)
     49{
     50    /* Create machine-window: */
     51    UIMachineWindow *pMachineWindow = 0;
     52    switch (pMachineLogic->visualStateType())
    5453    {
    5554        case UIVisualStateType_Normal:
    56             window = new UIMachineWindowNormal(pMachineLogic, uScreenId);
     55            pMachineWindow = new UIMachineWindowNormal(pMachineLogic, uScreenId);
    5756            break;
    5857        case UIVisualStateType_Fullscreen:
    59             window = new UIMachineWindowFullscreen(pMachineLogic, uScreenId);
     58            pMachineWindow = new UIMachineWindowFullscreen(pMachineLogic, uScreenId);
    6059            break;
    6160        case UIVisualStateType_Seamless:
    62             window = new UIMachineWindowSeamless(pMachineLogic, uScreenId);
     61            pMachineWindow = new UIMachineWindowSeamless(pMachineLogic, uScreenId);
    6362            break;
    6463        case UIVisualStateType_Scale:
    65             window = new UIMachineWindowScale(pMachineLogic, uScreenId);
     64            pMachineWindow = new UIMachineWindowScale(pMachineLogic, uScreenId);
    6665            break;
    67     }
    68     return window;
    69 }
    70 
     66        default:
     67            AssertMsgFailed(("Incorrect visual state!"));
     68            break;
     69    }
     70    /* Prepare machine-window: */
     71    pMachineWindow->prepare();
     72    /* Return machine-window: */
     73    return pMachineWindow;
     74}
     75
     76/* static */
    7177void UIMachineWindow::destroy(UIMachineWindow *pWhichWindow)
    7278{
     79    /* Cleanup machine-window: */
     80    pWhichWindow->cleanup();
     81    /* Delete machine-window: */
    7382    delete pWhichWindow;
    7483}
    7584
     85void UIMachineWindow::prepare()
     86{
     87    /* Prepare session-connections: */
     88    prepareSessionConnections();
     89
     90    /* Prepare main-layout: */
     91    prepareMainLayout();
     92
     93    /* Prepare menu: */
     94    prepareMenu();
     95
     96    /* Prepare status-bar: */
     97    prepareStatusBar();
     98
     99    /* Prepare machine-view: */
     100    prepareMachineView();
     101
     102    /* Prepare visual-state: */
     103    prepareVisualState();
     104
     105    /* Prepare handlers: */
     106    prepareHandlers();
     107
     108    /* Load settings: */
     109    loadSettings();
     110
     111    /* Retranslate window: */
     112    retranslateUi();
     113
     114    /* Update all the elements: */
     115    updateAppearanceOf(UIVisualElement_AllStuff);
     116
     117    /* Show: */
     118    showInNecessaryMode();
     119}
     120
     121void UIMachineWindow::cleanup()
     122{
     123    /* Save window settings: */
     124    saveSettings();
     125
     126    /* Cleanup handlers: */
     127    cleanupHandlers();
     128
     129    /* Cleanup visual-state: */
     130    cleanupVisualState();
     131
     132    /* Cleanup machine-view: */
     133    cleanupMachineView();
     134
     135    /* Cleanup status-bar: */
     136    cleanupStatusBar();
     137
     138    /* Cleanup menu: */
     139    cleanupMenu();
     140
     141    /* Cleanup main layout: */
     142    cleanupMainLayout();
     143
     144    /* Cleanup session connections: */
     145    cleanupSessionConnections();
     146}
     147
     148void UIMachineWindow::sltMachineStateChanged()
     149{
     150    /* Update window-title: */
     151    updateAppearanceOf(UIVisualElement_WindowTitle);
     152}
     153
     154void UIMachineWindow::sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect /* screenGeo */)
     155{
     156    /* Ignore change events for other screens: */
     157    if (uScreenId != m_uScreenId)
     158        return;
     159    /* Ignore KGuestMonitorChangedEventType_NewOrigin change event: */
     160    if (changeType == KGuestMonitorChangedEventType_NewOrigin)
     161        return;
     162
     163    /* Process KGuestMonitorChangedEventType_Enabled change event: */
     164    if (isHidden() && changeType == KGuestMonitorChangedEventType_Enabled)
     165        showInNecessaryMode();
     166    /* Process KGuestMonitorChangedEventType_Disabled change event: */
     167    else if (!isHidden() && changeType == KGuestMonitorChangedEventType_Disabled)
     168        hide();
     169}
     170
    76171void UIMachineWindow::sltTryClose()
    77172{
    78     /* Do not try to close if restricted: */
     173    /* Do not try to close window if restricted: */
    79174    if (machineLogic()->isPreventAutoClose())
    80175        return;
    81176
    82     /* First close any open modal & popup widgets.
     177#if 0
     178    // TODO: Is that really needed?
     179    /* This thing here is from Qt3.
     180     * First close any open modal & popup widgets.
    83181     * Use a single shot with timeout 0 to allow the widgets to cleanly close and test then again.
    84182     * If all open widgets are closed destroy ourself: */
    85     QWidget *widget = QApplication::activeModalWidget() ?
    86                       QApplication::activeModalWidget() :
    87                       QApplication::activePopupWidget() ?
    88                       QApplication::activePopupWidget() : 0;
    89     if (widget)
    90     {
    91         widget->close();
     183    QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() :
     184                       QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0;
     185    if (pWidget)
     186    {
     187        pWidget->close();
    92188        QTimer::singleShot(0, this, SLOT(sltTryClose()));
    93189    }
    94190    else
    95         close();
     191#endif
     192
     193    close();
    96194}
    97195
     
    99197    : QIWithRetranslateUI2<QMainWindow>(0, windowFlags(pMachineLogic->visualStateType()))
    100198    , m_pMachineLogic(pMachineLogic)
     199    , m_pMachineView(0)
    101200    , m_uScreenId(uScreenId)
    102     , m_pMachineViewContainer(0)
     201    , m_pMainLayout(0)
    103202    , m_pTopSpacer(0)
    104203    , m_pBottomSpacer(0)
    105204    , m_pLeftSpacer(0)
    106205    , m_pRightSpacer(0)
    107     , m_pMachineView(0)
    108 {
     206{
     207#ifndef Q_WS_MAC
     208    /* On Mac OS X application icon referenced in info.plist is used. */
     209
     210    /* Set default application icon (will be changed to VM-specific icon little bit later): */
     211    setWindowIcon(QIcon(":/VirtualBox_48px.png"));
     212
     213    /* Set VM-specific application icon: */
     214    setWindowIcon(vboxGlobal().vmGuestOSTypeIcon(machine().GetOSTypeId()));
     215#endif /* !Q_WS_MAC */
     216
     217    /* Set the main application window for VBoxGlobal: */
     218    if (m_uScreenId == 0)
     219        vboxGlobal().setMainWindow(this);
    109220}
    110221
    111222UIMachineWindow::~UIMachineWindow()
    112223{
    113     /* Close any opened modal & popup widgets: */
     224#if 0
     225    // TODO: Is that really needed?
     226    /* This thing here is from Qt3.
     227     * Close any opened modal & popup widgets: */
    114228    while (QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() :
    115229                              QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0)
     
    126240        pWidget->deleteLater();
    127241    }
     242#endif
    128243}
    129244
     
    138253}
    139254
     255CMachine UIMachineWindow::machine() const
     256{
     257    return session().GetMachine();
     258}
     259
    140260void UIMachineWindow::retranslateUi()
    141261{
     262    /* Compose window-title prefix: */
    142263    m_strWindowTitlePrefix = VBOX_PRODUCT;
    143264#ifdef VBOX_BLEEDING_EDGE
    144     m_strWindowTitlePrefix += UIMachineLogic::tr(" EXPERIMENTAL build %1r%2 - %3")
     265    m_strWindowTitlePrefix += UIMachineWindow::tr(" EXPERIMENTAL build %1r%2 - %3")
    145266                              .arg(RTBldCfgVersion())
    146267                              .arg(RTBldCfgRevisionStr())
    147268                              .arg(VBOX_BLEEDING_EDGE);
    148 #endif
    149     updateAppearanceOf(UIVisualElement_WindowCaption);
     269#endif /* VBOX_BLEEDING_EDGE */
     270    /* Update appearance of the window-title: */
     271    updateAppearanceOf(UIVisualElement_WindowTitle);
    150272}
    151273
     
    153275bool UIMachineWindow::x11Event(XEvent *pEvent)
    154276{
    155     // TODO: Check if that is still required!
     277    // TODO: Is that really needed?
    156278    /* Qt bug: when the machine-view grabs the keyboard,
    157279     * FocusIn, FocusOut, WindowActivate and WindowDeactivate Qt events are
     
    171293    return false;
    172294}
    173 #endif
     295#endif /* Q_WS_X11 */
    174296
    175297void UIMachineWindow::closeEvent(QCloseEvent *pEvent)
    176298{
    177     /* Always ignore close event: */
     299    /* Always ignore close-event: */
    178300    pEvent->ignore();
    179301
    180302    /* Should we close application? */
    181303    bool fCloseApplication = false;
    182 
    183304    switch (uisession()->machineState())
    184305    {
     
    191312        {
    192313            /* Get the machine: */
    193             CMachine machine = session().GetMachine();
     314            CMachine m = machine();
    194315
    195316            /* Check if there is a close hock script defined. */
    196             const QString& strScript = machine.GetExtraData(VBoxDefs::GUI_CloseActionHook);
     317            const QString& strScript = m.GetExtraData(VBoxDefs::GUI_CloseActionHook);
    197318            if (!strScript.isEmpty())
    198319            {
    199                 QProcess::startDetached(strScript, QStringList() << machine.GetId());
     320                QProcess::startDetached(strScript, QStringList() << m.GetId());
    200321                return;
    201322            }
    202             /* Prepare close dialog: */
     323
     324            /* Prepare close-dialog: */
    203325            UIVMCloseDialog dlg(this);
    204326
    205327            /* Assign close-dialog pixmap: */
    206             dlg.pmIcon->setPixmap(vboxGlobal().vmGuestOSTypeIcon(machine.GetOSTypeId()));
     328            dlg.pmIcon->setPixmap(vboxGlobal().vmGuestOSTypeIcon(m.GetOSTypeId()));
    207329
    208330            /* Check which close actions are disallowed: */
    209             QStringList restictedActionsList = machine.GetExtraData(VBoxDefs::GUI_RestrictedCloseActions).split(',');
     331            QStringList restictedActionsList = m.GetExtraData(VBoxDefs::GUI_RestrictedCloseActions).split(',');
    210332            bool fIsStateSavingAllowed = !restictedActionsList.contains("SaveState", Qt::CaseInsensitive);
    211333            bool fIsACPIShutdownAllowed = !restictedActionsList.contains("Shutdown", Qt::CaseInsensitive);
     
    231353
    232354            /* Make the Restore Snapshot checkbox visible/hidden depending on snapshots count & restrictions: */
    233             dlg.mCbDiscardCurState->setVisible(fIsPowerOffAndRestoreAllowed && machine.GetSnapshotCount() > 0);
    234             if (!machine.GetCurrentSnapshot().isNull())
    235                 dlg.mCbDiscardCurState->setText(dlg.mCbDiscardCurState->text().arg(machine.GetCurrentSnapshot().GetName()));
     355            dlg.mCbDiscardCurState->setVisible(fIsPowerOffAndRestoreAllowed && m.GetSnapshotCount() > 0);
     356            if (!m.GetCurrentSnapshot().isNull())
     357                dlg.mCbDiscardCurState->setText(dlg.mCbDiscardCurState->text().arg(m.GetCurrentSnapshot().GetName()));
    236358
    237359            /* Choice string tags for close-dialog: */
     
    242364
    243365            /* Read the last user's choice for the given VM: */
    244             QStringList lastAction = machine.GetExtraData(VBoxDefs::GUI_LastCloseAction).split(',');
     366            QStringList lastAction = m.GetExtraData(VBoxDefs::GUI_LastCloseAction).split(',');
    245367
    246368            /* Check which button should be initially chosen: */
     
    288410
    289411            /* This flag will keep the status of every further logical operation: */
    290             bool success = true;
     412            bool fSuccess = true;
    291413
    292414            /* Pause before showing dialog if necessary: */
    293415            bool fWasPaused = uisession()->isPaused() || uisession()->machineState() == KMachineState_Stuck;
    294416            if (!fWasPaused)
    295                 success = uisession()->pause();
    296 
    297             if (success)
     417                fSuccess = uisession()->pause();
     418
     419            if (fSuccess)
    298420            {
    299421                /* Preventing auto-closure: */
    300422                machineLogic()->setPreventAutoClose(true);
    301423
    302                 /* If close dialog accepted: */
     424                /* If close-dialog accepted: */
    303425                if (dlg.exec() == QDialog::Accepted)
    304426                {
     
    306428                    CConsole console = session().GetConsole();
    307429
    308                     success = false;
     430                    fSuccess = false;
    309431
    310432                    if (dlg.mRbSave->isChecked())
     
    317439                        {
    318440                            /* Show the "VM saving" progress dialog: */
    319                             msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_save_90px.png", 0, true);
     441                            msgCenter().showModalProgressDialog(progress, m.GetName(), ":/progress_state_save_90px.png", 0, true);
    320442                            if (progress.GetResultCode() != 0)
    321443                                msgCenter().cannotSaveMachineState(progress);
    322444                            else
    323                                 success = true;
     445                                fSuccess = true;
    324446                        }
    325447
    326                         if (success)
     448                        if (fSuccess)
    327449                            fCloseApplication = true;
    328450                    }
     
    338460                            msgCenter().cannotACPIShutdownMachine(console);
    339461                        else
    340                             success = true;
     462                            fSuccess = true;
    341463                    }
    342464                    else if (dlg.mRbPowerOff->isChecked())
     
    349471                        {
    350472                            /* Show the power down progress dialog: */
    351                             msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_poweroff_90px.png", 0, true);
     473                            msgCenter().showModalProgressDialog(progress, m.GetName(), ":/progress_poweroff_90px.png", 0, true);
    352474                            if (progress.GetResultCode() != 0)
    353475                                msgCenter().cannotStopMachine(progress);
    354476                            else
    355                                 success = true;
     477                                fSuccess = true;
    356478                        }
    357479
    358                         if (success)
     480                        if (fSuccess)
    359481                        {
    360482                            /* Discard the current state if requested: */
    361483                            if (dlg.mCbDiscardCurState->isChecked() && dlg.mCbDiscardCurState->isVisibleTo(&dlg))
    362484                            {
    363                                 CSnapshot snapshot = machine.GetCurrentSnapshot();
     485                                CSnapshot snapshot = m.GetCurrentSnapshot();
    364486                                CProgress progress = console.RestoreSnapshot(snapshot);
    365487                                if (!console.isOk())
     
    368490                                {
    369491                                    /* Show the progress dialog: */
    370                                     msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png", 0, true);
     492                                    msgCenter().showModalProgressDialog(progress, m.GetName(), ":/progress_snapshot_discard_90px.png", 0, true);
    371493                                    if (progress.GetResultCode() != 0)
    372494                                        msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName());
     
    375497                        }
    376498
    377                         if (success)
     499                        if (fSuccess)
    378500                            fCloseApplication = true;
    379501                    }
    380502
    381                     if (success)
     503                    if (fSuccess)
    382504                    {
    383505                        /* Read the last user's choice for the given VM: */
    384                         QStringList prevAction = machine.GetExtraData(VBoxDefs::GUI_LastCloseAction).split(',');
     506                        QStringList prevAction = m.GetExtraData(VBoxDefs::GUI_LastCloseAction).split(',');
    385507                        /* Memorize the last user's choice for the given VM: */
    386508                        QString lastAction = strPowerOff;
     
    396518                        if (dlg.mCbDiscardCurState->isChecked())
    397519                            (lastAction += ",") += strDiscardCurState;
    398                         machine.SetExtraData(VBoxDefs::GUI_LastCloseAction, lastAction);
     520                        m.SetExtraData(VBoxDefs::GUI_LastCloseAction, lastAction);
    399521                    }
    400522                }
    401523
    402524                /* Restore the running state if needed: */
    403                 if (success && !fCloseApplication && !fWasPaused && uisession()->machineState() == KMachineState_Paused)
     525                if (fSuccess && !fCloseApplication && !fWasPaused && uisession()->machineState() == KMachineState_Paused)
    404526                    uisession()->unpause();
    405527
     
    407529                machineLogic()->setPreventAutoClose(false);
    408530            }
    409 
    410531            break;
    411532        }
    412 
    413533        default:
    414534            break;
    415535    }
    416 
    417536    if (fCloseApplication)
    418537    {
    419         /* VM has been powered off or saved. We must *safely* close the VM window(s): */
     538        /* VM has been powered off or saved. We must *safely* close VM window(s): */
    420539        QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession()));
    421540    }
    422541}
    423542
    424 void UIMachineWindow::prepareWindowIcon()
    425 {
    426 #if !(defined (Q_WS_WIN) || defined (Q_WS_MAC))
    427     /* The default application icon (will be changed to VM-specific icon little bit later):
    428      * 1. On Win32, it's built-in to the executable;
    429      * 2. On Mac OS X the icon referenced in info.plist is used. */
    430     setWindowIcon(QIcon(":/VirtualBox_48px.png"));
    431 #endif
    432 
    433 #ifndef Q_WS_MAC
    434     /* Set the VM-specific application icon except Mac OS X: */
    435     setWindowIcon(vboxGlobal().vmGuestOSTypeIcon(session().GetMachine().GetOSTypeId()));
    436 #endif
    437 }
    438 
    439 void UIMachineWindow::prepareConsoleConnections()
     543void UIMachineWindow::prepareSessionConnections()
    440544{
    441545    /* Machine state-change updater: */
    442546    connect(uisession(), SIGNAL(sigMachineStateChange()), this, SLOT(sltMachineStateChanged()));
    443547
    444     /* Guest monitor change updater: */
     548    /* Guest monitor-change updater: */
    445549    connect(uisession(), SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)),
    446550            this, SLOT(sltGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)));
    447551}
    448552
    449 void UIMachineWindow::prepareMachineViewContainer()
    450 {
    451     /* Create view container.
    452      * After it will be passed to parent widget of some mode,
    453      * there will be no need to delete it, so no need to cleanup: */
    454     m_pMachineViewContainer = new QGridLayout();
    455     m_pMachineViewContainer->setMargin(0);
    456     m_pMachineViewContainer->setSpacing(0);
    457 
    458     /* Create and add shifting spacers.
    459      * After they will be inserted into layout, it will get the parentness
    460      * of those spacers, so there will be no need to cleanup them. */
     553void UIMachineWindow::prepareMainLayout()
     554{
     555    /* Create central-widget: */
     556    setCentralWidget(new QWidget);
     557
     558    /* Create main-layout: */
     559    m_pMainLayout = new QGridLayout(centralWidget());
     560    m_pMainLayout->setMargin(0);
     561    m_pMainLayout->setSpacing(0);
     562
     563    /* Create shifting-spacers: */
    461564    m_pTopSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
    462565    m_pBottomSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
     
    464567    m_pRightSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed);
    465568
    466     m_pMachineViewContainer->addItem(m_pTopSpacer, 0, 1);
    467     m_pMachineViewContainer->addItem(m_pBottomSpacer, 2, 1);
    468     m_pMachineViewContainer->addItem(m_pLeftSpacer, 1, 0);
    469     m_pMachineViewContainer->addItem(m_pRightSpacer, 1, 2);
     569    /* Add shifting-spacers into main-layout: */
     570    m_pMainLayout->addItem(m_pTopSpacer, 0, 1);
     571    m_pMainLayout->addItem(m_pBottomSpacer, 2, 1);
     572    m_pMainLayout->addItem(m_pLeftSpacer, 1, 0);
     573    m_pMainLayout->addItem(m_pRightSpacer, 1, 2);
     574}
     575
     576void UIMachineWindow::prepareMachineView()
     577{
     578#ifdef VBOX_WITH_VIDEOHWACCEL
     579    /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled: */
     580    bool bAccelerate2DVideo = machine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();
     581#endif /* VBOX_WITH_VIDEOHWACCEL */
     582
     583    /* Get visual-state type: */
     584    UIVisualStateType visualStateType = machineLogic()->visualStateType();
     585
     586    /* Create machine-view: */
     587    m_pMachineView = UIMachineView::create(  this
     588                                           , m_uScreenId
     589                                           , visualStateType
     590#ifdef VBOX_WITH_VIDEOHWACCEL
     591                                           , bAccelerate2DVideo
     592#endif /* VBOX_WITH_VIDEOHWACCEL */
     593                                           );
     594
     595    /* Add machine-view into main-layout: */
     596    m_pMainLayout->addWidget(m_pMachineView, 1, 1, viewAlignment(visualStateType));
    470597}
    471598
     
    488615}
    489616
     617void UIMachineWindow::cleanupMachineView()
     618{
     619    /* Destroy machine-view: */
     620    UIMachineView::destroy(m_pMachineView);
     621    m_pMachineView = 0;
     622}
     623
    490624void UIMachineWindow::updateAppearanceOf(int iElement)
    491625{
    492     CMachine machine = session().GetMachine();
    493 
    494     if (iElement & UIVisualElement_WindowCaption)
    495     {
     626    /* Update window title: */
     627    if (iElement & UIVisualElement_WindowTitle)
     628    {
     629        /* Get machine: */
     630        const CMachine &m = machine();
    496631        /* Get machine state: */
    497632        KMachineState state = uisession()->machineState();
    498633        /* Prepare full name: */
    499634        QString strSnapshotName;
    500         if (machine.GetSnapshotCount() > 0)
     635        if (m.GetSnapshotCount() > 0)
    501636        {
    502             CSnapshot snapshot = machine.GetCurrentSnapshot();
     637            CSnapshot snapshot = m.GetCurrentSnapshot();
    503638            strSnapshotName = " (" + snapshot.GetName() + ")";
    504639        }
    505         QString strMachineName = machine.GetName() + strSnapshotName;
     640        QString strMachineName = m.GetName() + strSnapshotName;
    506641        if (state != KMachineState_Null)
    507642            strMachineName += " [" + vboxGlobal().toString(state) + "]";
    508643        /* Unusual on the Mac. */
    509644#ifndef Q_WS_MAC
    510         strMachineName += " - " + m_strWindowTitlePrefix;
    511 #endif /* Q_WS_MAC */
    512         if (machine.GetMonitorCount() > 1)
     645        strMachineName += " - " + defaultWindowTitle();
     646#endif /* !Q_WS_MAC */
     647        if (m.GetMonitorCount() > 1)
    513648            strMachineName += QString(" : %1").arg(m_uScreenId + 1);
    514649        setWindowTitle(strMachineName);
     
    525660#endif /* VBOX_WITH_DEBUGGER_GUI */
    526661
    527 void UIMachineWindow::sltMachineStateChanged()
    528 {
    529     updateAppearanceOf(UIVisualElement_WindowCaption);
    530 }
    531 
    532 void UIMachineWindow::sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect /* screenGeo */)
    533 {
    534     /* Ignore change events for other screens: */
    535     if (uScreenId != m_uScreenId)
    536         return;
    537 
    538     /* Ignore KGuestMonitorChangedEventType_NewOrigin change event: */
    539     if (changeType == KGuestMonitorChangedEventType_NewOrigin)
    540         return;
    541 
    542     /* Process KGuestMonitorChangedEventType_Enabled change event: */
    543     if (isHidden() && changeType == KGuestMonitorChangedEventType_Enabled)
    544         showInNecessaryMode();
    545     /* Process KGuestMonitorChangedEventType_Disabled change event: */
    546     else if (!isHidden() && changeType == KGuestMonitorChangedEventType_Disabled)
    547         hide();
    548 }
    549 
     662/* static */
    550663Qt::WindowFlags UIMachineWindow::windowFlags(UIVisualStateType visualStateType)
    551664{
     
    561674}
    562675
     676/* static */
     677Qt::Alignment UIMachineWindow::viewAlignment(UIVisualStateType visualStateType)
     678{
     679    switch (visualStateType)
     680    {
     681        case UIVisualStateType_Normal: return 0;
     682        case UIVisualStateType_Fullscreen: return Qt::AlignVCenter | Qt::AlignHCenter;
     683        case UIVisualStateType_Seamless: return 0;
     684        case UIVisualStateType_Scale: return 0;
     685    }
     686    AssertMsgFailed(("Incorrect visual state!"));
     687    return 0;
     688}
     689
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r41107 r41114  
    2020#define __UIMachineWindow_h__
    2121
    22 /* Global includes */
     22/* Global includes: */
    2323#include <QMainWindow>
    2424
    25 /* Local includes */
     25/* Local includes: */
    2626#include "QIWithRetranslateUI.h"
    2727#include "UIMachineDefs.h"
    2828#include "COMDefs.h"
    2929
    30 /* Global forwards */
    31 class QWidget;
     30/* Forward declarations: */
    3231class QGridLayout;
    3332class QSpacerItem;
    3433class QCloseEvent;
    35 
    36 /* Local forwards */
    3734class CSession;
    3835class UISession;
     
    4037class UIMachineView;
    4138
     39/* Machine-window interface: */
    4240class UIMachineWindow : public QIWithRetranslateUI2<QMainWindow>
    4341{
     
    4644public:
    4745
    48     /* Factory function to create required machine window child: */
    49     static UIMachineWindow* create(UIMachineLogic *pMachineLogic, UIVisualStateType visualStateType, ulong uScreenId = 0);
     46    /* Factory functions to create/destroy machine-window: */
     47    static UIMachineWindow* create(UIMachineLogic *pMachineLogic, ulong uScreenId = 0);
    5048    static void destroy(UIMachineWindow *pWhichWindow);
    5149
     50    /* Prepare/cleanup machine-window: */
     51    void prepare();
     52    void cleanup();
     53
    5254    /* Public getters: */
    53     virtual UIMachineLogic* machineLogic() const { return m_pMachineLogic; }
    54     virtual UIMachineView* machineView() const { return m_pMachineView; }
     55    UIMachineView* machineView() const { return m_pMachineView; }
     56    UIMachineLogic* machineLogic() const { return m_pMachineLogic; }
    5557    UISession* uisession() const;
    5658    CSession& session() const;
     59    CMachine machine() const;
    5760
    5861protected slots:
     
    6265    virtual void sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo);
    6366
    64     /* Slot to safe close machine-window: */
     67    /* Slot to close machine-window: */
    6568    void sltTryClose();
    6669
    6770protected:
    6871
    69     /* Machine window constructor/destructor: */
     72    /* Constructor/destructor: */
    7073    UIMachineWindow(UIMachineLogic *pMachineLogic, ulong uScreenId);
    71     virtual ~UIMachineWindow();
     74    ~UIMachineWindow();
    7275
    73     /* Protected getters: */
    74     const QString& defaultWindowTitle() const { return m_strWindowTitlePrefix; }
     76    /* Show stuff: */
     77    virtual void showInNecessaryMode() = 0;
    7578
    76     /* Translate routine: */
    77     virtual void retranslateUi();
     79    /* Translate stuff: */
     80    void retranslateUi();
    7881
    79     /* Common machine window event handlers: */
     82    /* Event handlers: */
    8083#ifdef Q_WS_X11
    8184    bool x11Event(XEvent *pEvent);
    82 #endif
     85#endif /* Q_WS_X11 */
    8386    void closeEvent(QCloseEvent *pEvent);
    8487
    8588    /* Prepare helpers: */
    86     virtual void prepareWindowIcon();
    87     virtual void prepareConsoleConnections();
    88     virtual void prepareMachineViewContainer();
    89     //virtual void loadWindowSettings() {}
     89    virtual void prepareSessionConnections();
     90    virtual void prepareMainLayout();
     91    virtual void prepareMenu() {}
     92    virtual void prepareStatusBar() {}
     93    virtual void prepareMachineView();
     94    virtual void prepareVisualState() {}
    9095    virtual void prepareHandlers();
     96    virtual void loadSettings() {}
    9197
    9298    /* Cleanup helpers: */
     99    virtual void saveSettings() {}
    93100    virtual void cleanupHandlers();
    94     //virtual void saveWindowSettings() {}
    95     //virtual void cleanupMachineViewContainer() {}
    96     //virtual void cleanupConsoleConnections() {}
    97     //virtual void cleanupWindowIcon() {}
     101    virtual void cleanupVisualState() {}
     102    virtual void cleanupMachineView();
     103    virtual void cleanupStatusBar() {}
     104    virtual void cleanupMenu() {}
     105    virtual void cleanupMainLayout() {}
     106    virtual void cleanupSessionConnections() {}
    98107
    99     /* Update routines: */
     108    /* Update stuff: */
    100109    virtual void updateAppearanceOf(int iElement);
    101110#ifdef VBOX_WITH_DEBUGGER_GUI
    102     virtual void updateDbgWindows();
     111    void updateDbgWindows();
    103112#endif /* VBOX_WITH_DEBUGGER_GUI */
    104113
    105114    /* Helpers: */
    106     Qt::WindowFlags windowFlags(UIVisualStateType visualStateType);
     115    const QString& defaultWindowTitle() const { return m_strWindowTitlePrefix; }
     116    static Qt::WindowFlags windowFlags(UIVisualStateType visualStateType);
     117    static Qt::Alignment viewAlignment(UIVisualStateType visualStateType);
    107118
    108     /* Show routine: */
    109     virtual void showInNecessaryMode() = 0;
    110 
    111     /* Protected variables: */
     119    /* Variables: */
    112120    UIMachineLogic *m_pMachineLogic;
    113 
    114     /* Virtual screen number: */
     121    UIMachineView *m_pMachineView;
     122    QString m_strWindowTitlePrefix;
    115123    ulong m_uScreenId;
    116 
    117     QGridLayout *m_pMachineViewContainer;
     124    QGridLayout *m_pMainLayout;
    118125    QSpacerItem *m_pTopSpacer;
    119126    QSpacerItem *m_pBottomSpacer;
     
    121128    QSpacerItem *m_pRightSpacer;
    122129
    123     UIMachineView *m_pMachineView;
    124     QString m_strWindowTitlePrefix;
    125 
     130    /* Friend classes: */
    126131    friend class UIMachineLogic;
    127132};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r41064 r41114  
    147147    /* Create machine window(s): */
    148148    for (int cScreenId = 0; cScreenId < m_pScreenLayout->guestScreenCount(); ++cScreenId)
    149         addMachineWindow(UIMachineWindow::create(this, visualStateType(), cScreenId));
     149        addMachineWindow(UIMachineWindow::create(this, cScreenId));
    150150
    151151    /* Connect screen-layout change handler: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r41107 r41114  
    1818 */
    1919
    20 /* Global includes */
     20/* Global includes: */
    2121#include <QDesktopWidget>
    2222#include <QTimer>
     
    2525#endif /* Q_WS_MAC */
    2626
    27 /* Local includes */
    28 #include "VBoxGlobal.h"
     27/* Local includes: */
    2928#include "VBoxMiniToolBar.h"
    30 
    3129#include "UISession.h"
    3230#include "UIActionPoolRuntime.h"
    3331#include "UIMachineLogicFullscreen.h"
    3432#include "UIMachineWindowFullscreen.h"
    35 #include "UIMachineView.h"
    3633
    3734UIMachineWindowFullscreen::UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId)
     
    4037    , m_pMiniToolBar(0)
    4138{
    42     /* Set the main window in VBoxGlobal: */
    43     if (uScreenId == 0)
    44         vboxGlobal().setMainWindow(this);
    45 
    46     /* Prepare fullscreen window icon: */
    47     prepareWindowIcon();
    48 
    49     /* Prepare console connections: */
    50     prepareConsoleConnections();
    51 
    52     /* Prepare fullscreen menu: */
    53     prepareMenu();
    54 
    55     /* Prepare machine view container: */
    56     prepareMachineViewContainer();
    57 
    58     /* Prepare fullscreen machine view: */
    59     prepareMachineView();
    60 
    61     /* Prepare handlers: */
    62     prepareHandlers();
    63 
    64     /* Prepare mini tool-bar: */
    65     prepareMiniToolBar();
    66 
    67     /* Retranslate fullscreen window finally: */
    68     retranslateUi();
    69 
    70     /* Update all the elements: */
    71     updateAppearanceOf(UIVisualElement_AllStuff);
    72 
    73     /* Show fullscreen window: */
    74     showInNecessaryMode();
    75 }
    76 
    77 UIMachineWindowFullscreen::~UIMachineWindowFullscreen()
    78 {
    79     /* Save window settings: */
    80     saveWindowSettings();
    81 
    82     /* Cleanup mini tool-bar: */
    83     cleanupMiniToolBar();
    84 
    85     /* Prepare handlers: */
    86     cleanupHandlers();
    87 
    88     /* Cleanup machine view: */
    89     cleanupMachineView();
    90 
    91     /* Cleanup menu: */
    92     cleanupMenu();
     39}
     40
     41void UIMachineWindowFullscreen::sltMachineStateChanged()
     42{
     43    /* Call to base-class: */
     44    UIMachineWindow::sltMachineStateChanged();
     45
     46    /* Update mini-toolbar: */
     47    updateAppearanceOf(UIVisualElement_MiniToolBar);
    9348}
    9449
     
    9651{
    9752    /* Get corresponding screen: */
    98     int iScreen = static_cast<UIMachineLogicFullscreen*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId);
     53    int iScreen = qobject_cast<UIMachineLogicFullscreen*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId);
    9954    /* Calculate working area: */
    10055    QRect workingArea = QApplication::desktop()->screenGeometry(iScreen);
     
    10964void UIMachineWindowFullscreen::sltPopupMainMenu()
    11065{
    111     /* Popup main menu if present: */
     66    /* Popup main-menu if present: */
    11267    if (m_pMainMenu && !m_pMainMenu->isEmpty())
    11368    {
     
    11974void UIMachineWindowFullscreen::prepareMenu()
    12075{
     76    /* Call to base-class: */
     77    UIMachineWindow::prepareMenu();
     78
     79    /* Prepare menu: */
    12180#ifdef Q_WS_MAC
    12281    setMenuBar(uisession()->newMenuBar());
     
    12584}
    12685
    127 void UIMachineWindowFullscreen::prepareMiniToolBar()
    128 {
    129     /* Get current machine: */
    130     CMachine machine = session().GetConsole().GetMachine();
    131     /* Check if mini tool-bar should present: */
    132     bool fIsActive = machine.GetExtraData(VBoxDefs::GUI_ShowMiniToolBar) != "no";
    133     if (fIsActive)
    134     {
    135         /* Get the mini tool-bar alignment: */
    136         bool fIsAtTop = machine.GetExtraData(VBoxDefs::GUI_MiniToolBarAlignment) == "top";
    137         /* Get the mini tool-bar auto-hide feature availability: */
    138         bool fIsAutoHide = machine.GetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide) != "off";
    139         m_pMiniToolBar = new VBoxMiniToolBar(centralWidget(),
    140                                              fIsAtTop ? VBoxMiniToolBar::AlignTop : VBoxMiniToolBar::AlignBottom,
    141                                              true, fIsAutoHide);
    142         m_pMiniToolBar->updateDisplay(true, true);
    143         QList<QMenu*> menus;
    144         QList<QAction*> actions = uisession()->newMenu()->actions();
    145         for (int i=0; i < actions.size(); ++i)
    146             menus << actions.at(i)->menu();
    147         *m_pMiniToolBar << menus;
    148         connect(m_pMiniToolBar, SIGNAL(minimizeAction()), this, SLOT(showMinimized()));
    149         connect(m_pMiniToolBar, SIGNAL(exitAction()),
    150                 gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen), SLOT(trigger()));
    151         connect(m_pMiniToolBar, SIGNAL(closeAction()),
    152                 gActionPool->action(UIActionIndexRuntime_Simple_Close), SLOT(trigger()));
    153     }
    154 }
    155 
    156 void UIMachineWindowFullscreen::prepareMachineView()
    157 {
    158 #ifdef VBOX_WITH_VIDEOHWACCEL
    159     /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled: */
    160     bool bAccelerate2DVideo = session().GetMachine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();
    161 #endif
    162 
    163     /* Set central widget: */
    164     setCentralWidget(new QWidget);
    165 
    166     /* Set central widget layout: */
    167     centralWidget()->setLayout(m_pMachineViewContainer);
    168 
    169     m_pMachineView = UIMachineView::create(  this
    170                                            , m_uScreenId
    171                                            , machineLogic()->visualStateType()
    172 #ifdef VBOX_WITH_VIDEOHWACCEL
    173                                            , bAccelerate2DVideo
    174 #endif
    175                                            );
    176 
    177     /* Add machine view into layout: */
    178     m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);
     86void UIMachineWindowFullscreen::prepareVisualState()
     87{
     88    /* Call to base-class: */
     89    UIMachineWindow::prepareVisualState();
    17990
    18091    /* The background has to go black: */
     
    18495    centralWidget()->setAutoFillBackground(true);
    18596    setAutoFillBackground(true);
    186 }
    187 
    188 void UIMachineWindowFullscreen::saveWindowSettings()
     97
     98    /* Prepare mini-toolbar: */
     99    prepareMiniToolbar();
     100}
     101
     102void UIMachineWindowFullscreen::prepareMiniToolbar()
    189103{
    190104    /* Get machine: */
    191     CMachine machine = session().GetConsole().GetMachine();
    192 
    193     /* Save extra-data settings: */
    194     {
    195         /* Save mini tool-bar settings: */
    196         if (m_pMiniToolBar)
    197             machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide, m_pMiniToolBar->isAutoHide() ? QString() : "off");
    198     }
    199 }
    200 
    201 void UIMachineWindowFullscreen::cleanupMachineView()
    202 {
    203     /* Do not cleanup machine view if it is not present: */
    204     if (!machineView())
     105    CMachine m = machine();
     106
     107    /* Make sure mini-toolbar is necessary: */
     108    bool fIsActive = m.GetExtraData(VBoxDefs::GUI_ShowMiniToolBar) != "no";
     109    if (!fIsActive)
    205110        return;
    206111
    207     UIMachineView::destroy(m_pMachineView);
    208     m_pMachineView = 0;
    209 }
    210 
    211 void UIMachineWindowFullscreen::cleanupMiniToolBar()
    212 {
    213     if (m_pMiniToolBar)
    214     {
    215         delete m_pMiniToolBar;
    216         m_pMiniToolBar = 0;
    217     }
     112    /* Get the mini-toolbar alignment: */
     113    bool fIsAtTop = m.GetExtraData(VBoxDefs::GUI_MiniToolBarAlignment) == "top";
     114    /* Get the mini-toolbar auto-hide feature availability: */
     115    bool fIsAutoHide = m.GetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide) != "off";
     116    m_pMiniToolBar = new VBoxMiniToolBar(centralWidget(),
     117                                         fIsAtTop ? VBoxMiniToolBar::AlignTop : VBoxMiniToolBar::AlignBottom,
     118                                         true, fIsAutoHide);
     119    m_pMiniToolBar->updateDisplay(true, true);
     120    QList<QMenu*> menus;
     121    QList<QAction*> actions = uisession()->newMenu()->actions();
     122    for (int i=0; i < actions.size(); ++i)
     123        menus << actions.at(i)->menu();
     124    *m_pMiniToolBar << menus;
     125    connect(m_pMiniToolBar, SIGNAL(minimizeAction()), this, SLOT(showMinimized()));
     126    connect(m_pMiniToolBar, SIGNAL(exitAction()),
     127            gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen), SLOT(trigger()));
     128    connect(m_pMiniToolBar, SIGNAL(closeAction()),
     129            gActionPool->action(UIActionIndexRuntime_Simple_Close), SLOT(trigger()));
     130}
     131
     132void UIMachineWindowFullscreen::cleanupMiniToolbar()
     133{
     134    /* Make sure mini-toolbar was created: */
     135    if (!m_pMiniToolBar)
     136        return;
     137
     138    /* Save mini-toolbar settings: */
     139    machine().SetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide, m_pMiniToolBar->isAutoHide() ? QString() : "off");
     140    /* Delete mini-toolbar: */
     141    delete m_pMiniToolBar;
     142    m_pMiniToolBar = 0;
     143}
     144
     145void UIMachineWindowFullscreen::cleanupVisualState()
     146{
     147    /* Cleanup mini-toolbar: */
     148    cleanupMiniToolbar();
     149
     150    /* Call to base-class: */
     151    UIMachineWindow::cleanupVisualState();
    218152}
    219153
    220154void UIMachineWindowFullscreen::cleanupMenu()
    221155{
     156    /* Cleanup menu: */
    222157    delete m_pMainMenu;
    223158    m_pMainMenu = 0;
    224 }
    225 
    226 void UIMachineWindowFullscreen::updateAppearanceOf(int iElement)
    227 {
    228     /* Base class update: */
    229     UIMachineWindow::updateAppearanceOf(iElement);
    230 
    231     /* If mini tool-bar is present: */
    232     if (m_pMiniToolBar)
    233     {
    234         /* Get machine: */
    235         CMachine machine = session().GetConsole().GetMachine();
    236         /* Get snapshot(s): */
    237         QString strSnapshotName;
    238         if (machine.GetSnapshotCount() > 0)
    239         {
    240             CSnapshot snapshot = machine.GetCurrentSnapshot();
    241             strSnapshotName = " (" + snapshot.GetName() + ")";
    242         }
    243         /* Update mini tool-bar text: */
    244         m_pMiniToolBar->setDisplayText(machine.GetName() + strSnapshotName);
    245     }
     159
     160    /* Call to base-class: */
     161    UIMachineWindow::cleanupMenu();
    246162}
    247163
     
    251167    BOOL fEnabled = true;
    252168    ULONG guestOriginX = 0, guestOriginY = 0, guestWidth = 0, guestHeight = 0;
    253     session().GetMachine().QuerySavedGuestScreenInfo(m_uScreenId, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
     169    machine().QuerySavedGuestScreenInfo(m_uScreenId, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
    254170    if (fEnabled)
    255171    {
     
    268184#ifdef Q_WS_MAC
    269185        /* Make sure it is really on the right place (especially on the Mac): */
    270         QRect r = QApplication::desktop()->screenGeometry(static_cast<UIMachineLogicFullscreen*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId));
     186        QRect r = QApplication::desktop()->screenGeometry(qobject_cast<UIMachineLogicFullscreen*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId));
    271187        move(r.topLeft());
    272188#endif /* Q_WS_MAC */
     
    274190}
    275191
     192void UIMachineWindowFullscreen::updateAppearanceOf(int iElement)
     193{
     194    /* Call to base-class: */
     195    UIMachineWindow::updateAppearanceOf(iElement);
     196
     197    /* Update mini-toolbar: */
     198    if (iElement & UIVisualElement_MiniToolBar)
     199    {
     200        if (m_pMiniToolBar)
     201        {
     202            /* Get machine: */
     203            const CMachine &m = machine();
     204            /* Get snapshot(s): */
     205            QString strSnapshotName;
     206            if (m.GetSnapshotCount() > 0)
     207            {
     208                CSnapshot snapshot = m.GetCurrentSnapshot();
     209                strSnapshotName = " (" + snapshot.GetName() + ")";
     210            }
     211            /* Update mini-toolbar text: */
     212            m_pMiniToolBar->setDisplayText(m.GetName() + strSnapshotName);
     213        }
     214    }
     215}
     216
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h

    r41107 r41114  
    2020#define __UIMachineWindowFullscreen_h__
    2121
    22 /* Local includes */
     22/* Local includes: */
    2323#include "UIMachineWindow.h"
    2424
    25 /* Local forwards */
     25/* Forward declarations: */
    2626class VBoxMiniToolBar;
    2727
     28/* Fullscreen machine-window implementation: */
    2829class UIMachineWindowFullscreen : public UIMachineWindow
    2930{
    3031    Q_OBJECT;
    3132
    32 public slots:
    33 
    34     void sltPlaceOnScreen();
    35 
    3633protected:
    3734
    38     /* Fullscreen machine window constructor/destructor: */
     35    /* Constructor: */
    3936    UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId);
    40     virtual ~UIMachineWindowFullscreen();
    4137
    4238private slots:
    4339
    44     /* Popup main menu: */
     40    /* Session event-handlers: */
     41    void sltMachineStateChanged();
     42
     43    /* Places window on screen: */
     44    void sltPlaceOnScreen();
     45
     46    /* Popup main-menu: */
    4547    void sltPopupMainMenu();
    4648
     
    4951    /* Prepare helpers: */
    5052    void prepareMenu();
    51     void prepareMiniToolBar();
    52     void prepareMachineView();
    53     //void loadWindowSettings() {}
     53    void prepareVisualState();
     54    void prepareMiniToolbar();
    5455
    5556    /* Cleanup helpers: */
    56     void saveWindowSettings();
    57     void cleanupMachineView();
    58     void cleanupMiniToolBar();
     57    void cleanupMiniToolbar();
     58    void cleanupVisualState();
    5959    void cleanupMenu();
    6060
    61     /* Update routines: */
     61    /* Show stuff: */
     62    void showInNecessaryMode();
     63
     64    /* Update stuff: */
    6265    void updateAppearanceOf(int iElement);
    6366
    64     /* Other members: */
    65     void showInNecessaryMode();
    66 
    67     /* Private variables: */
     67    /* Widgets: */
    6868    QMenu *m_pMainMenu;
    6969    VBoxMiniToolBar *m_pMiniToolBar;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r41107 r41114  
    101101    /* Create machine window(s): */
    102102    for (ulong uScreenId = 0; uScreenId < uMonitorCount; ++ uScreenId)
    103         addMachineWindow(UIMachineWindow::create(this, visualStateType(), uScreenId));
     103        addMachineWindow(UIMachineWindow::create(this, uScreenId));
    104104    /* Order machine window(s): */
    105105    for (ulong uScreenId = uMonitorCount; uScreenId > 0; -- uScreenId)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r41107 r41114  
    1818 */
    1919
    20 /* Global includes */
     20/* Global includes: */
    2121#include <QDesktopWidget>
    2222#include <QMenuBar>
     
    2424#include <QContextMenuEvent>
    2525
    26 /* Local includes */
     26/* Local includes: */
    2727#include "VBoxGlobal.h"
    2828#include "UIMessageCenter.h"
    2929#include "VBoxUtils.h"
    30 
    3130#include "UISession.h"
    3231#include "UIActionPoolRuntime.h"
     
    4443# include "UIImageTools.h"
    4544#endif /* Q_WS_MAC */
    46 
    4745#include "QIStatusBar.h"
    4846#include "QIStateIndicator.h"
     
    5452    , m_pIdleTimer(0)
    5553{
    56     /* Set the main window in VBoxGlobal */
    57     if (uScreenId == 0)
    58         vboxGlobal().setMainWindow(this);
    59 
    60     /* Prepare window icon: */
    61     prepareWindowIcon();
    62 
    63     /* Prepare console connections: */
    64     prepareConsoleConnections();
    65 
    66     /* Prepare menu: */
    67     prepareMenu();
    68 
    69     /* Prepare status bar: */
    70     prepareStatusBar();
    71 
    72     /* Prepare connections: */
    73     prepareConnections();
    74 
    75     /* Retranslate normal window finally: */
    76     retranslateUi();
    77 
    78     /* Prepare normal machine view container: */
    79     prepareMachineViewContainer();
    80 
    81     /* Prepare normal machine view: */
    82     prepareMachineView();
    83 
    84     /* Prepare handlers: */
    85     prepareHandlers();
    86 
    87     /* Load normal window settings: */
    88     loadWindowSettings();
    89 
    90     /* Update all the elements: */
    91     updateAppearanceOf(UIVisualElement_AllStuff);
    92 
    93 #ifdef Q_WS_MAC
    94     /* Beta label? */
    95     if (vboxGlobal().isBeta())
    96     {
    97         QPixmap betaLabel = ::betaLabel(QSize(100, 16));
    98         ::darwinLabelWindow(this, &betaLabel, true);
    99     }
    100 #endif /* Q_WS_MAC */
    101 
    102     /* Show normal window: */
    103     showInNecessaryMode();
    104 }
    105 
    106 UIMachineWindowNormal::~UIMachineWindowNormal()
    107 {
    108     /* Save normal window settings: */
    109     saveWindowSettings();
    110 
    111     /* Prepare handlers: */
    112     cleanupHandlers();
    113 
    114     /* Cleanup normal machine view: */
    115     cleanupMachineView();
    116 
    117     /* Cleanup status-bar: */
    118     cleanupStatusBar();
    11954}
    12055
    12156void UIMachineWindowNormal::sltMachineStateChanged()
    12257{
     58    /* Call to base-class: */
    12359    UIMachineWindow::sltMachineStateChanged();
     60
     61    /* Update pause and virtualization stuff: */
    12462    updateAppearanceOf(UIVisualElement_PauseStuff | UIVisualElement_VirtualizationStuff);
    12563}
     
    12765void UIMachineWindowNormal::sltMediumChange(const CMediumAttachment &attachment)
    12866{
     67    /* Update corresponding medium stuff: */
    12968    KDeviceType type = attachment.GetType();
    13069    if (type == KDeviceType_HardDisk)
     
    13877void UIMachineWindowNormal::sltUSBControllerChange()
    13978{
     79    /* Update USB stuff: */
    14080    updateAppearanceOf(UIVisualElement_USBStuff);
    14181}
     
    14383void UIMachineWindowNormal::sltUSBDeviceStateChange()
    14484{
     85    /* Update USB stuff: */
    14586    updateAppearanceOf(UIVisualElement_USBStuff);
    14687}
     
    14889void UIMachineWindowNormal::sltNetworkAdapterChange()
    14990{
     91    /* Update network stuff: */
    15092    updateAppearanceOf(UIVisualElement_NetworkStuff);
    15193}
     
    15395void UIMachineWindowNormal::sltSharedFolderChange()
    15496{
     97    /* Update shared-folders stuff: */
    15598    updateAppearanceOf(UIVisualElement_SharedFolderStuff);
    15699}
     
    158101void UIMachineWindowNormal::sltCPUExecutionCapChange()
    159102{
     103    /* Update virtualization stuff: */
    160104    updateAppearanceOf(UIVisualElement_VirtualizationStuff);
    161105}
     
    163107void UIMachineWindowNormal::sltUpdateIndicators()
    164108{
     109    /* Update LEDs: */
    165110    updateIndicatorState(indicatorsPool()->indicator(UIIndicatorIndex_HardDisks), KDeviceType_HardDisk);
    166111    updateIndicatorState(indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks), KDeviceType_DVD);
     
    173118void UIMachineWindowNormal::sltShowIndicatorsContextMenu(QIStateIndicator *pIndicator, QContextMenuEvent *pEvent)
    174119{
     120    /* Show CD/DVD device LED context menu: */
    175121    if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks))
    176122    {
     
    178124            gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices)->menu()->exec(pEvent->globalPos());
    179125    }
     126    /* Show floppy drive LED context menu: */
    180127    else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_FloppyDisks))
    181128    {
     
    183130            gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices)->menu()->exec(pEvent->globalPos());
    184131    }
     132    /* Show USB device LED context menu: */
    185133    else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_USBDevices))
    186134    {
     
    188136            gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)->menu()->exec(pEvent->globalPos());
    189137    }
     138    /* Show network adapter LED context menu: */
    190139    else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters))
    191140    {
     
    193142            gActionPool->action(UIActionIndexRuntime_Menu_NetworkAdapters)->menu()->exec(pEvent->globalPos());
    194143    }
     144    /* Show shared-folders LED context menu: */
    195145    else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders))
    196146    {
     
    198148            gActionPool->action(UIActionIndexRuntime_Menu_SharedFolders)->menu()->exec(pEvent->globalPos());
    199149    }
     150    /* Show mouse LED context menu: */
    200151    else if (pIndicator == indicatorsPool()->indicator(UIIndicatorIndex_Mouse))
    201152    {
     
    207158void UIMachineWindowNormal::sltProcessGlobalSettingChange(const char * /* aPublicName */, const char * /* aName */)
    208159{
     160    /* Update host-combination LED: */
    209161    m_pNameHostkey->setText(UIHotKeyCombination::toReadableString(vboxGlobal().settings().hostCombo()));
    210162}
    211163
    212 void UIMachineWindowNormal::retranslateUi()
    213 {
    214     /* Translate parent class: */
    215     UIMachineWindow::retranslateUi();
    216 
    217     m_pNameHostkey->setToolTip(
    218         QApplication::translate("UIMachineWindowNormal", "Shows the currently assigned Host key.<br>"
    219            "This key, when pressed alone, toggles the keyboard and mouse "
    220            "capture state. It can also be used in combination with other keys "
    221            "to quickly perform actions from the main menu."));
    222     m_pNameHostkey->setText(UIHotKeyCombination::toReadableString(vboxGlobal().settings().hostCombo()));
    223 }
    224 
    225 void UIMachineWindowNormal::updateAppearanceOf(int iElement)
    226 {
    227     /* Update parent-class window: */
    228     UIMachineWindow::updateAppearanceOf(iElement);
    229 
    230     /* Update that machine window: */
    231     if (iElement & UIVisualElement_PauseStuff)
    232     {
    233         if (!statusBar()->isHidden())
    234         {
    235             if (uisession()->isPaused() && m_pIdleTimer->isActive())
    236                 m_pIdleTimer->stop();
    237             else if (uisession()->isRunning() && !m_pIdleTimer->isActive())
    238                 m_pIdleTimer->start(100);
    239             sltUpdateIndicators();
    240         }
    241     }
    242     if (iElement & UIVisualElement_HDStuff)
    243         indicatorsPool()->indicator(UIIndicatorIndex_HardDisks)->updateAppearance();
    244     if (iElement & UIVisualElement_CDStuff)
    245         indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks)->updateAppearance();
    246     if (iElement & UIVisualElement_FDStuff)
    247         indicatorsPool()->indicator(UIIndicatorIndex_FloppyDisks)->updateAppearance();
    248     if (iElement & UIVisualElement_USBStuff &&
    249         !indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->isHidden())
    250         indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->updateAppearance();
    251     if (iElement & UIVisualElement_NetworkStuff)
    252         indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters)->updateAppearance();
    253     if (iElement & UIVisualElement_SharedFolderStuff)
    254         indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders)->updateAppearance();
    255     if (iElement & UIVisualElement_VirtualizationStuff)
    256         indicatorsPool()->indicator(UIIndicatorIndex_Virtualization)->updateAppearance();
    257 }
    258 
    259 bool UIMachineWindowNormal::event(QEvent *pEvent)
    260 {
    261     switch (pEvent->type())
    262     {
    263         case QEvent::Resize:
    264         {
    265             QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
    266             if (!isMaximizedChecked())
    267             {
    268                 m_normalGeometry.setSize(pResizeEvent->size());
    269 #ifdef VBOX_WITH_DEBUGGER_GUI
    270                 /* Update debugger window position */
    271                 updateDbgWindows();
    272 #endif
    273             }
    274             break;
    275         }
    276         case QEvent::Move:
    277         {
    278             if (!isMaximizedChecked())
    279             {
    280                 m_normalGeometry.moveTo(geometry().x(), geometry().y());
    281 #ifdef VBOX_WITH_DEBUGGER_GUI
    282                 /* Update debugger window position */
    283                 updateDbgWindows();
    284 #endif
    285             }
    286             break;
    287         }
    288         default:
    289             break;
    290     }
    291     return QIWithRetranslateUI2<QMainWindow>::event(pEvent);
    292 }
    293 
    294 void UIMachineWindowNormal::prepareConsoleConnections()
    295 {
    296     /* Base-class connections: */
    297     UIMachineWindow::prepareConsoleConnections();
     164void UIMachineWindowNormal::prepareSessionConnections()
     165{
     166    /* Call to base-class: */
     167    UIMachineWindow::prepareSessionConnections();
    298168
    299169    /* Medium change updater: */
     
    324194void UIMachineWindowNormal::prepareMenu()
    325195{
     196    /* Call to base-class: */
     197    UIMachineWindow::prepareMenu();
     198
     199    /* Prepare menu-bar: */
    326200    setMenuBar(uisession()->newMenuBar());
    327201}
     
    329203void UIMachineWindowNormal::prepareStatusBar()
    330204{
    331     /* Common setup: */
     205    /* Call to base-class: */
     206    UIMachineWindow::prepareStatusBar();
     207
     208    /* Setup: */
    332209    setStatusBar(new QIStatusBar(this));
    333210    QWidget *pIndicatorBox = new QWidget;
     
    393270    pHostkeyLedContainerLayout->addWidget(m_pNameHostkey);
    394271
    395     /* Add to statusbar: */
     272    /* Add to status-bar: */
    396273    statusBar()->addPermanentWidget(pIndicatorBox, 0);
    397274
     
    402279
    403280#ifdef Q_WS_MAC
    404     /* For the status bar on Cocoa: */
     281    /* For the status-bar on Cocoa: */
    405282    setUnifiedTitleAndToolBarOnMac(true);
    406 #endif
    407 }
    408 
    409 void UIMachineWindowNormal::prepareConnections()
    410 {
    411     /* Setup global settings change updater: */
    412     connect(&vboxGlobal().settings(), SIGNAL(propertyChanged(const char *, const char *)),
    413             this, SLOT(sltProcessGlobalSettingChange(const char *, const char *)));
    414 }
    415 
    416 void UIMachineWindowNormal::prepareMachineView()
    417 {
    418 #ifdef VBOX_WITH_VIDEOHWACCEL
    419     /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled: */
    420     bool bAccelerate2DVideo = session().GetMachine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();
    421 #endif
    422 
    423     /* Set central widget: */
    424     setCentralWidget(new QWidget);
    425 
    426     /* Set central widget layout: */
    427     centralWidget()->setLayout(m_pMachineViewContainer);
    428 
    429     m_pMachineView = UIMachineView::create(  this
    430                                            , m_uScreenId
    431                                            , machineLogic()->visualStateType()
    432 #ifdef VBOX_WITH_VIDEOHWACCEL
    433                                            , bAccelerate2DVideo
    434 #endif
    435                                            );
    436 
    437     /* Add machine view into layout: */
    438     m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1);
    439 
    440     /* Setup machine view connections: */
    441     if (machineView())
    442     {
    443         /* Keyboard state-change updater: */
    444         connect(machineLogic()->keyboardHandler(), SIGNAL(keyboardStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Hostkey), SLOT(setState(int)));
    445 
    446         /* Mouse state-change updater: */
    447         connect(machineLogic()->mouseHandler(), SIGNAL(mouseStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Mouse), SLOT(setState(int)));
    448 
    449         /* Early initialize required connections: */
    450         indicatorsPool()->indicator(UIIndicatorIndex_Hostkey)->setState(machineLogic()->keyboardHandler()->keyboardState());
    451         indicatorsPool()->indicator(UIIndicatorIndex_Mouse)->setState(machineLogic()->mouseHandler()->mouseState());
    452     }
     283#endif /* Q_WS_MAC */
     284}
     285
     286void UIMachineWindowNormal::prepareVisualState()
     287{
     288    /* Call to base-class: */
     289    UIMachineWindow::prepareVisualState();
    453290
    454291#ifdef VBOX_GUI_WITH_CUSTOMIZATIONS1
     
    460297    setAutoFillBackground(true);
    461298#endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */
    462 }
    463 
    464 void UIMachineWindowNormal::loadWindowSettings()
    465 {
    466     /* Load normal window settings: */
    467     CMachine machine = session().GetMachine();
     299
     300    /* Make sure host-combination LED will be updated: */
     301    connect(&vboxGlobal().settings(), SIGNAL(propertyChanged(const char *, const char *)),
     302            this, SLOT(sltProcessGlobalSettingChange(const char *, const char *)));
     303
     304#ifdef Q_WS_MAC
     305    /* Beta label? */
     306    if (vboxGlobal().isBeta())
     307    {
     308        QPixmap betaLabel = ::betaLabel(QSize(100, 16));
     309        ::darwinLabelWindow(this, &betaLabel, true);
     310    }
     311#endif /* Q_WS_MAC */
     312}
     313
     314void UIMachineWindowNormal::prepareHandlers()
     315{
     316    /* Call to base-class: */
     317    UIMachineWindow::prepareHandlers();
     318
     319    /* Keyboard state-change updater: */
     320    connect(machineLogic()->keyboardHandler(), SIGNAL(keyboardStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Hostkey), SLOT(setState(int)));
     321    /* Mouse state-change updater: */
     322    connect(machineLogic()->mouseHandler(), SIGNAL(mouseStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Mouse), SLOT(setState(int)));
     323    /* Early initialize required connections: */
     324    indicatorsPool()->indicator(UIIndicatorIndex_Hostkey)->setState(machineLogic()->keyboardHandler()->keyboardState());
     325    indicatorsPool()->indicator(UIIndicatorIndex_Mouse)->setState(machineLogic()->mouseHandler()->mouseState());
     326}
     327
     328void UIMachineWindowNormal::loadSettings()
     329{
     330    /* Call to base-class: */
     331    UIMachineWindow::loadSettings();
     332
     333    /* Get machine: */
     334    CMachine m = machine();
    468335
    469336    /* Load extra-data settings: */
    470337    {
     338        /* Load window position settings: */
    471339        QString strPositionAddress = m_uScreenId == 0 ? QString("%1").arg(VBoxDefs::GUI_LastNormalWindowPosition) :
    472340                                     QString("%1%2").arg(VBoxDefs::GUI_LastNormalWindowPosition).arg(m_uScreenId);
    473         QStringList strPositionSettings = machine.GetExtraDataStringList(strPositionAddress);
    474 
     341        QStringList strPositionSettings = m.GetExtraDataStringList(strPositionAddress);
    475342        bool ok = !strPositionSettings.isEmpty(), max = false;
    476343        int x = 0, y = 0, w = 0, h = 0;
    477 
    478344        if (ok && strPositionSettings.size() > 0)
    479345            x = strPositionSettings[0].toInt(&ok);
     
    490356        if (ok && strPositionSettings.size() > 4)
    491357            max = strPositionSettings[4] == VBoxDefs::GUI_LastWindowState_Max;
    492 
    493358        QRect ar = ok ? QApplication::desktop()->availableGeometry(QPoint(x, y)) :
    494359                        QApplication::desktop()->availableGeometry(this);
     
    498363        {
    499364            /* If previous machine state is SAVED: */
    500             if (machine.GetState() == KMachineState_Saved)
     365            if (m.GetState() == KMachineState_Saved)
    501366            {
    502367                /* Restore window size and position: */
     
    504369                setGeometry(m_normalGeometry);
    505370            }
    506             /* If previous machine state is not SAVED: */
     371            /* If previous machine state was not SAVED: */
    507372            else
    508373            {
     
    511376                setGeometry(m_normalGeometry);
    512377                if (machineView())
    513                     machineView()->normalizeGeometry(false /* adjust position? */);
     378                    machineView()->normalizeGeometry(false);
    514379            }
    515380            /* Maximize if needed: */
     
    521386            /* Normalize view early to the optimal size: */
    522387            if (machineView())
    523                 machineView()->normalizeGeometry(true /* adjust position? */);
     388                machineView()->normalizeGeometry(true);
    524389            /* Move newly created window to the screen center: */
    525390            m_normalGeometry = geometry();
     
    528393        }
    529394
    530         /* Normalize view to the optimal size:
    531          * Note: Cause of the async behavior of X11 (at least GNOME) we have to delay this a little bit.
    532          * On Mac OS X and MS Windows this is not necessary and create even wrong resize events.
    533          * So there we set the geometry immediately. */
     395        /* Normalize view to the optimal size: */
    534396        if (machineView())
    535 #ifdef Q_WS_X11
    536             QTimer::singleShot(0, machineView(), SLOT(sltNormalizeGeometry()));
    537 #else /* Q_WS_X11 */
    538397            machineView()->normalizeGeometry(true);
    539 #endif /* !Q_WS_X11 */
    540398    }
    541399
     
    543401    {
    544402        /* USB Stuff: */
    545         const CUSBController &usbController = machine.GetUSBController();
     403        const CUSBController &usbController = m.GetUSBController();
    546404        if (    usbController.isNull()
    547405            || !usbController.GetEnabled()
    548406            || !usbController.GetProxyAvailable())
    549407        {
    550             /* Hide USB Menu: */
     408            /* Hide USB menu: */
    551409            indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->setHidden(true);
    552410        }
     
    569427}
    570428
    571 void UIMachineWindowNormal::saveWindowSettings()
    572 {
    573     CMachine machine = session().GetMachine();
     429void UIMachineWindowNormal::saveSettings()
     430{
     431    /* Get machine: */
     432    CMachine m = machine();
    574433
    575434    /* Save extra-data settings: */
     
    582441        QString strPositionAddress = m_uScreenId == 0 ? QString("%1").arg(VBoxDefs::GUI_LastNormalWindowPosition) :
    583442                                     QString("%1%2").arg(VBoxDefs::GUI_LastNormalWindowPosition).arg(m_uScreenId);
    584         machine.SetExtraData(strPositionAddress, strWindowPosition);
    585     }
    586 }
    587 
    588 void UIMachineWindowNormal::cleanupMachineView()
    589 {
    590     /* Do not cleanup machine view if it is not present: */
    591     if (!machineView())
    592         return;
    593 
    594     UIMachineView::destroy(m_pMachineView);
    595     m_pMachineView = 0;
     443        m.SetExtraData(strPositionAddress, strWindowPosition);
     444    }
     445
     446    /* Call to base-class: */
     447    UIMachineWindow::saveSettings();
    596448}
    597449
     
    601453    m_pIdleTimer->stop();
    602454    m_pIdleTimer->disconnect(SIGNAL(timeout()), this, SLOT(sltUpdateIndicators()));
     455
     456    /* Call to base-class: */
     457    UIMachineWindow::cleanupStatusBar();
     458}
     459
     460void UIMachineWindowNormal::retranslateUi()
     461{
     462    /* Call to base-class: */
     463    UIMachineWindow::retranslateUi();
     464
     465    /* Translate host-combo LED: */
     466    m_pNameHostkey->setToolTip(
     467        QApplication::translate("UIMachineWindowNormal", "Shows the currently assigned Host key.<br>"
     468           "This key, when pressed alone, toggles the keyboard and mouse "
     469           "capture state. It can also be used in combination with other keys "
     470           "to quickly perform actions from the main menu."));
     471    m_pNameHostkey->setText(UIHotKeyCombination::toReadableString(vboxGlobal().settings().hostCombo()));
     472}
     473
     474bool UIMachineWindowNormal::event(QEvent *pEvent)
     475{
     476    switch (pEvent->type())
     477    {
     478        case QEvent::Resize:
     479        {
     480            QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
     481            if (!isMaximizedChecked())
     482            {
     483                m_normalGeometry.setSize(pResizeEvent->size());
     484#ifdef VBOX_WITH_DEBUGGER_GUI
     485                /* Update debugger window position: */
     486                updateDbgWindows();
     487#endif /* VBOX_WITH_DEBUGGER_GUI */
     488            }
     489            break;
     490        }
     491        case QEvent::Move:
     492        {
     493            if (!isMaximizedChecked())
     494            {
     495                m_normalGeometry.moveTo(geometry().x(), geometry().y());
     496#ifdef VBOX_WITH_DEBUGGER_GUI
     497                /* Update debugger window position: */
     498                updateDbgWindows();
     499#endif /* VBOX_WITH_DEBUGGER_GUI */
     500            }
     501            break;
     502        }
     503        default:
     504            break;
     505    }
     506    return UIMachineWindow::event(pEvent);
    603507}
    604508
     
    608512    BOOL fEnabled = true;
    609513    ULONG guestOriginX = 0, guestOriginY = 0, guestWidth = 0, guestHeight = 0;
    610     session().GetMachine().QuerySavedGuestScreenInfo(m_uScreenId, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
     514    machine().QuerySavedGuestScreenInfo(m_uScreenId, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
    611515    if (fEnabled)
    612516        show();
     517}
     518
     519void UIMachineWindowNormal::updateAppearanceOf(int iElement)
     520{
     521    /* Call to base-class: */
     522    UIMachineWindow::updateAppearanceOf(iElement);
     523
     524    /* Update machine window content: */
     525    if (iElement & UIVisualElement_PauseStuff)
     526    {
     527        if (!statusBar()->isHidden())
     528        {
     529            if (uisession()->isPaused() && m_pIdleTimer->isActive())
     530                m_pIdleTimer->stop();
     531            else if (uisession()->isRunning() && !m_pIdleTimer->isActive())
     532                m_pIdleTimer->start(100);
     533            sltUpdateIndicators();
     534        }
     535    }
     536    if (iElement & UIVisualElement_HDStuff)
     537        indicatorsPool()->indicator(UIIndicatorIndex_HardDisks)->updateAppearance();
     538    if (iElement & UIVisualElement_CDStuff)
     539        indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks)->updateAppearance();
     540    if (iElement & UIVisualElement_FDStuff)
     541        indicatorsPool()->indicator(UIIndicatorIndex_FloppyDisks)->updateAppearance();
     542    if (iElement & UIVisualElement_NetworkStuff)
     543        indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters)->updateAppearance();
     544    if (iElement & UIVisualElement_USBStuff &&
     545        !indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->isHidden())
     546        indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->updateAppearance();
     547    if (iElement & UIVisualElement_SharedFolderStuff)
     548        indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders)->updateAppearance();
     549    if (iElement & UIVisualElement_VirtualizationStuff)
     550        indicatorsPool()->indicator(UIIndicatorIndex_Virtualization)->updateAppearance();
    613551}
    614552
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h

    r41107 r41114  
    2020#define __UIMachineWindowNormal_h__
    2121
    22 /* Global includes */
     22/* Global includes: */
    2323#include <QLabel>
    2424
    25 /* Local includes */
     25/* Local includes: */
    2626#include "UIMachineWindow.h"
    2727
    28 /* Local forwards */
     28/* Forward declarations: */
    2929class CMediumAttachment;
    3030class UIIndicatorsPool;
    3131class QIStateIndicator;
    3232
     33/* Normal machine-window implementation: */
    3334class UIMachineWindowNormal : public UIMachineWindow
    3435{
     
    3738protected:
    3839
    39     /* Normal machine window constructor/destructor: */
     40    /* Constructor: */
    4041    UIMachineWindowNormal(UIMachineLogic *pMachineLogic, ulong uScreenId);
    41     virtual ~UIMachineWindowNormal();
    4242
    4343private slots:
    4444
    45     /* Console callback handlers: */
     45    /* Session event-handlers: */
    4646    void sltMachineStateChanged();
    4747    void sltMediumChange(const CMediumAttachment &attachment);
     
    5959private:
    6060
    61     /* Translate routine: */
    62     void retranslateUi();
    63 
    64     /* Update routines: */
    65     void updateAppearanceOf(int aElement);
    66 
    67     /* Event handlers: */
    68     bool event(QEvent *pEvent);
    69 
    70     /* Private getters: */
    71     UIIndicatorsPool* indicatorsPool() { return m_pIndicatorsPool; }
    72 
    7361    /* Prepare helpers: */
    74     void prepareConsoleConnections();
     62    void prepareSessionConnections();
    7563    void prepareMenu();
    7664    void prepareStatusBar();
    77     void prepareConnections();
    78     void prepareMachineView();
    79     void loadWindowSettings();
     65    void prepareVisualState();
     66    void prepareHandlers();
     67    void loadSettings();
    8068
    8169    /* Cleanup helpers: */
    82     void saveWindowSettings();
    83     void cleanupMachineView();
    84     //void cleanupConnections() {}
     70    void saveSettings();
     71    //void cleanupHandlers() {}
     72    //coid cleanupVisualState() {}
    8573    void cleanupStatusBar();
    8674    //void cleanupMenu() {}
    8775    //void cleanupConsoleConnections() {}
    8876
    89     /* Other members: */
     77    /* Translate stuff: */
     78    void retranslateUi();
     79
     80    /* Show stuff: */
    9081    void showInNecessaryMode();
     82
     83    /* Update stuff: */
     84    void updateAppearanceOf(int aElement);
     85
     86    /* Event handler: */
     87    bool event(QEvent *pEvent);
     88
     89    /* Helpers: */
     90    UIIndicatorsPool* indicatorsPool() { return m_pIndicatorsPool; }
    9191    bool isMaximizedChecked();
    9292    void updateIndicatorState(QIStateIndicator *pIndicator, KDeviceType deviceType);
    9393
    94     /* Indicators pool: */
     94    /* Widgets: */
    9595    UIIndicatorsPool *m_pIndicatorsPool;
    96     /* Other QWidgets: */
    9796    QWidget *m_pCntHostkey;
    9897    QLabel *m_pNameHostkey;
    99     /* Other QObjects: */
     98
     99    /* Variables: */
    100100    QTimer *m_pIdleTimer;
    101     /* Other members: */
    102101    QRect m_normalGeometry;
    103102
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineLogicScale.cpp

    r41107 r41114  
    8181    /* Create machine window(s): */
    8282    for (ulong uScreenId = 0; uScreenId < uMonitorCount; ++ uScreenId)
    83         addMachineWindow(UIMachineWindow::create(this, visualStateType(), uScreenId));
     83        addMachineWindow(UIMachineWindow::create(this, uScreenId));
    8484    /* Order machine window(s): */
    8585    for (ulong uScreenId = uMonitorCount; uScreenId > 0; -- uScreenId)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.cpp

    r41107 r41114  
    1818 */
    1919
    20 /* Global includes */
     20/* Global includes: */
    2121#include <QDesktopWidget>
    22 #include <QMenuBar>
    2322#include <QTimer>
    2423#include <QContextMenuEvent>
    25 
    26 /* Local includes */
     24#ifdef Q_WS_MAC
     25# include <QMenuBar>
     26#endif /* Q_WS_MAC */
     27
     28/* Local includes: */
    2729#include "VBoxGlobal.h"
    2830#include "UIMessageCenter.h"
    2931#include "VBoxUtils.h"
    30 
    3132#include "UISession.h"
    3233#include "UIMachineLogic.h"
     
    4142    , m_pMainMenu(0)
    4243{
    43     /* Set the main window in VBoxGlobal */
    44     if (uScreenId == 0)
    45         vboxGlobal().setMainWindow(this);
    46 
    47     /* Prepare window icon: */
    48     prepareWindowIcon();
    49 
    50     /* Prepare console connections: */
    51     prepareConsoleConnections();
    52 
    53     /* Prepare menu: */
    54     prepareMenu();
    55 
    56     /* Retranslate normal window finally: */
    57     retranslateUi();
    58 
    59     /* Prepare normal machine view container: */
    60     prepareMachineViewContainer();
    61 
    62     /* Prepare normal machine view: */
    63     prepareMachineView();
    64 
    65     /* Prepare handlers: */
    66     prepareHandlers();
    67 
    68     /* Load normal window settings: */
    69     loadWindowSettings();
    70 
    71     /* Update all the elements: */
    72     updateAppearanceOf(UIVisualElement_AllStuff);
    73 
    74 #ifdef Q_WS_MAC
    75     /* Install the resize delegate for keeping the aspect ratio. */
    76     ::darwinInstallResizeDelegate(this);
    77     /* Beta label? */
    78     if (vboxGlobal().isBeta())
    79     {
    80         QPixmap betaLabel = ::betaLabel(QSize(100, 16));
    81         ::darwinLabelWindow(this, &betaLabel, true);
    82     }
    83 #endif /* Q_WS_MAC */
    84 
    85     /* Show scaled window: */
    86     showInNecessaryMode();
    87 }
    88 
    89 UIMachineWindowScale::~UIMachineWindowScale()
    90 {
    91 #ifdef Q_WS_MAC
    92     /* Uninstall the resize delegate for keeping the aspect ratio. */
    93     ::darwinUninstallResizeDelegate(this);
    94 #endif /* Q_WS_MAC */
    95 
    96     /* Save normal window settings: */
    97     saveWindowSettings();
    98 
    99     /* Prepare handlers: */
    100     cleanupHandlers();
    101 
    102     /* Cleanup normal machine view: */
    103     cleanupMachineView();
    10444}
    10545
    10646void UIMachineWindowScale::sltPopupMainMenu()
    10747{
    108     /* Popup main menu if present: */
     48    /* Popup main-menu if present: */
    10949    if (m_pMainMenu && !m_pMainMenu->isEmpty())
    11050    {
     
    11454}
    11555
    116 bool UIMachineWindowScale::event(QEvent *pEvent)
    117 {
    118     switch (pEvent->type())
    119     {
    120         case QEvent::Resize:
    121         {
    122             QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
    123             if (!isMaximizedChecked())
    124             {
    125                 m_normalGeometry.setSize(pResizeEvent->size());
    126 #ifdef VBOX_WITH_DEBUGGER_GUI
    127                 /* Update debugger window position */
    128                 updateDbgWindows();
    129 #endif
    130             }
    131             break;
    132         }
    133         case QEvent::Move:
    134         {
    135             if (!isMaximizedChecked())
    136             {
    137                 m_normalGeometry.moveTo(geometry().x(), geometry().y());
    138 #ifdef VBOX_WITH_DEBUGGER_GUI
    139                 /* Update debugger window position */
    140                 updateDbgWindows();
    141 #endif
    142             }
    143             break;
    144         }
    145         default:
    146             break;
    147     }
    148     return QIWithRetranslateUI2<QMainWindow>::event(pEvent);
    149 }
    150 
    151 #ifdef Q_WS_WIN
    152 bool UIMachineWindowScale::winEvent(MSG *pMessage, long *pResult)
    153 {
    154     /* Try to keep aspect ratio during window resize if:
    155      * 1. machine view exists and 2. event-type is WM_SIZING and 3. shift key is NOT pressed: */
    156     if (machineView() && pMessage->message == WM_SIZING && !(QApplication::keyboardModifiers() & Qt::ShiftModifier))
    157     {
    158         if (double dAspectRatio = machineView()->aspectRatio())
    159         {
    160             RECT *pRect = reinterpret_cast<RECT*>(pMessage->lParam);
    161             switch (pMessage->wParam)
    162             {
    163                 case WMSZ_LEFT:
    164                 case WMSZ_RIGHT:
    165                 {
    166                     pRect->bottom = pRect->top + (double)(pRect->right - pRect->left) / dAspectRatio;
    167                     break;
    168                 }
    169                 case WMSZ_TOP:
    170                 case WMSZ_BOTTOM:
    171                 {
    172                     pRect->right = pRect->left + (double)(pRect->bottom - pRect->top) * dAspectRatio;
    173                     break;
    174                 }
    175                 case WMSZ_BOTTOMLEFT:
    176                 case WMSZ_BOTTOMRIGHT:
    177                 {
    178                     pRect->bottom = pRect->top + (double)(pRect->right - pRect->left) / dAspectRatio;
    179                     break;
    180                 }
    181                 case WMSZ_TOPLEFT:
    182                 case WMSZ_TOPRIGHT:
    183                 {
    184                     pRect->top = pRect->bottom - (double)(pRect->right - pRect->left) / dAspectRatio;
    185                     break;
    186                 }
    187                 default:
    188                     break;
    189             }
    190         }
    191     }
    192     /* Pass event to base-class: */
    193     return QMainWindow::winEvent(pMessage, pResult);
    194 }
    195 #endif /* Q_WS_WIN */
    196 
    197 void UIMachineWindowScale::prepareMenu()
    198 {
    199 #ifdef Q_WS_MAC
    200     setMenuBar(uisession()->newMenuBar());
    201 #endif /* Q_WS_MAC */
    202     m_pMainMenu = uisession()->newMenu();
    203 }
    204 
    205 void UIMachineWindowScale::prepareMachineViewContainer()
    206 {
    207     /* Call to base-class: */
    208     UIMachineWindow::prepareMachineViewContainer();
     56void UIMachineWindowScale::prepareMainLayout()
     57{
     58    /* Call to base-class: */
     59    UIMachineWindow::prepareMainLayout();
    20960
    21061    /* Strict spacers to hide them, they are not necessary for scale-mode: */
     
    21566}
    21667
    217 void UIMachineWindowScale::prepareMachineView()
    218 {
    219 #ifdef VBOX_WITH_VIDEOHWACCEL
    220     /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled: */
    221     bool bAccelerate2DVideo = session().GetMachine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();
    222 #endif
    223 
    224     /* Set central widget: */
    225     setCentralWidget(new QWidget);
    226 
    227     /* Set central widget layout: */
    228     centralWidget()->setLayout(m_pMachineViewContainer);
    229 
    230     m_pMachineView = UIMachineView::create(  this
    231                                            , m_uScreenId
    232                                            , machineLogic()->visualStateType()
    233 #ifdef VBOX_WITH_VIDEOHWACCEL
    234                                            , bAccelerate2DVideo
    235 #endif
    236                                            );
    237 
    238     /* Add machine view into layout: */
    239     m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1);
    240 }
    241 
    242 void UIMachineWindowScale::loadWindowSettings()
    243 {
     68void UIMachineWindowScale::prepareMenu()
     69{
     70    /* Call to base-class: */
     71    UIMachineWindow::prepareMenu();
     72
     73#ifdef Q_WS_MAC
     74    setMenuBar(uisession()->newMenuBar());
     75#endif /* Q_WS_MAC */
     76    m_pMainMenu = uisession()->newMenu();
     77}
     78
     79#ifdef Q_WS_MAC
     80void UIMachineWindowScale::prepareVisualState()
     81{
     82    /* Call to base-class: */
     83    UIMachineWindow::prepareVisualState();
     84
     85    /* Install the resize delegate for keeping the aspect ratio. */
     86    ::darwinInstallResizeDelegate(this);
     87    /* Beta label? */
     88    if (vboxGlobal().isBeta())
     89    {
     90        QPixmap betaLabel = ::betaLabel(QSize(100, 16));
     91        ::darwinLabelWindow(this, &betaLabel, true);
     92    }
     93}
     94#endif /* Q_WS_MAC */
     95
     96void UIMachineWindowScale::loadSettings()
     97{
     98    /* Call to base-class: */
     99    UIMachineWindow::loadSettings();
     100
    244101    /* Load scale window settings: */
    245     CMachine machine = session().GetMachine();
     102    CMachine m = machine();
    246103
    247104    /* Load extra-data settings: */
     
    249106        QString strPositionAddress = m_uScreenId == 0 ? QString("%1").arg(VBoxDefs::GUI_LastScaleWindowPosition) :
    250107                                     QString("%1%2").arg(VBoxDefs::GUI_LastScaleWindowPosition).arg(m_uScreenId);
    251         QStringList strPositionSettings = machine.GetExtraDataStringList(strPositionAddress);
     108        QStringList strPositionSettings = m.GetExtraDataStringList(strPositionAddress);
    252109
    253110        bool ok = !strPositionSettings.isEmpty(), max = false;
     
    295152}
    296153
    297 void UIMachineWindowScale::saveWindowSettings()
    298 {
    299     CMachine machine = session().GetMachine();
     154void UIMachineWindowScale::saveSettings()
     155{
     156    /* Get machine: */
     157    CMachine m = machine();
    300158
    301159    /* Save extra-data settings: */
     
    308166        QString strPositionAddress = m_uScreenId == 0 ? QString("%1").arg(VBoxDefs::GUI_LastScaleWindowPosition) :
    309167                                     QString("%1%2").arg(VBoxDefs::GUI_LastScaleWindowPosition).arg(m_uScreenId);
    310         machine.SetExtraData(strPositionAddress, strWindowPosition);
    311     }
    312 }
    313 
    314 void UIMachineWindowScale::cleanupMachineView()
    315 {
    316     /* Do not cleanup machine view if it is not present: */
    317     if (!machineView())
    318         return;
    319 
    320     UIMachineView::destroy(m_pMachineView);
    321     m_pMachineView = 0;
    322 }
     168        m.SetExtraData(strPositionAddress, strWindowPosition);
     169    }
     170
     171    /* Call to base-class: */
     172    UIMachineWindow::saveSettings();
     173}
     174
     175#ifdef Q_WS_MAC
     176void UIMachineWindowScale::cleanupVisualState()
     177{
     178    /* Uninstall the resize delegate for keeping the aspect ratio. */
     179    ::darwinUninstallResizeDelegate(this);
     180
     181    /* Call to base-class: */
     182    UIMachineWindow::cleanupVisualState();
     183}
     184#endif /* Q_WS_MAC */
    323185
    324186void UIMachineWindowScale::cleanupMenu()
    325187{
     188    /* Cleanup menu: */
    326189    delete m_pMainMenu;
    327190    m_pMainMenu = 0;
     191
     192    /* Call to base-class: */
     193    UIMachineWindow::cleanupMenu();
    328194}
    329195
     
    333199    BOOL fEnabled = true;
    334200    ULONG guestOriginX = 0, guestOriginY = 0, guestWidth = 0, guestHeight = 0;
    335     session().GetMachine().QuerySavedGuestScreenInfo(m_uScreenId, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
     201    machine().QuerySavedGuestScreenInfo(m_uScreenId, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
    336202    if (fEnabled)
    337203        show();
    338204}
     205
     206bool UIMachineWindowScale::event(QEvent *pEvent)
     207{
     208    switch (pEvent->type())
     209    {
     210        case QEvent::Resize:
     211        {
     212            QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
     213            if (!isMaximizedChecked())
     214            {
     215                m_normalGeometry.setSize(pResizeEvent->size());
     216#ifdef VBOX_WITH_DEBUGGER_GUI
     217                /* Update debugger window position: */
     218                updateDbgWindows();
     219#endif /* VBOX_WITH_DEBUGGER_GUI */
     220            }
     221            break;
     222        }
     223        case QEvent::Move:
     224        {
     225            if (!isMaximizedChecked())
     226            {
     227                m_normalGeometry.moveTo(geometry().x(), geometry().y());
     228#ifdef VBOX_WITH_DEBUGGER_GUI
     229                /* Update debugger window position: */
     230                updateDbgWindows();
     231#endif /* VBOX_WITH_DEBUGGER_GUI */
     232            }
     233            break;
     234        }
     235        default:
     236            break;
     237    }
     238    return UIMachineWindow::event(pEvent);
     239}
     240
     241#ifdef Q_WS_WIN
     242bool UIMachineWindowScale::winEvent(MSG *pMessage, long *pResult)
     243{
     244    /* Try to keep aspect ratio during window resize if:
     245     * 1. machine view exists and 2. event-type is WM_SIZING and 3. shift key is NOT pressed: */
     246    if (machineView() && pMessage->message == WM_SIZING && !(QApplication::keyboardModifiers() & Qt::ShiftModifier))
     247    {
     248        if (double dAspectRatio = machineView()->aspectRatio())
     249        {
     250            RECT *pRect = reinterpret_cast<RECT*>(pMessage->lParam);
     251            switch (pMessage->wParam)
     252            {
     253                case WMSZ_LEFT:
     254                case WMSZ_RIGHT:
     255                {
     256                    pRect->bottom = pRect->top + (double)(pRect->right - pRect->left) / dAspectRatio;
     257                    break;
     258                }
     259                case WMSZ_TOP:
     260                case WMSZ_BOTTOM:
     261                {
     262                    pRect->right = pRect->left + (double)(pRect->bottom - pRect->top) * dAspectRatio;
     263                    break;
     264                }
     265                case WMSZ_BOTTOMLEFT:
     266                case WMSZ_BOTTOMRIGHT:
     267                {
     268                    pRect->bottom = pRect->top + (double)(pRect->right - pRect->left) / dAspectRatio;
     269                    break;
     270                }
     271                case WMSZ_TOPLEFT:
     272                case WMSZ_TOPRIGHT:
     273                {
     274                    pRect->top = pRect->bottom - (double)(pRect->right - pRect->left) / dAspectRatio;
     275                    break;
     276                }
     277                default:
     278                    break;
     279            }
     280        }
     281    }
     282    /* Call to base-class: */
     283    return UIMachineWindow::winEvent(pMessage, pResult);
     284}
     285#endif /* Q_WS_WIN */
    339286
    340287bool UIMachineWindowScale::isMaximizedChecked()
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.h

    r41107 r41114  
    2020#define __UIMachineWindowScale_h__
    2121
    22 /* Local includes */
     22/* Local includes: */
    2323#include "UIMachineWindow.h"
    2424
     25/* Scale machine-window implementation: */
    2526class UIMachineWindowScale : public UIMachineWindow
    2627{
     
    2930protected:
    3031
    31     /* Scale machine window constructor/destructor: */
     32    /* Constructor: */
    3233    UIMachineWindowScale(UIMachineLogic *pMachineLogic, ulong uScreenId);
    33     virtual ~UIMachineWindowScale();
    3434
    3535private slots:
    3636
    37     /* Popup main menu: */
     37    /* Popup main-menu: */
    3838    void sltPopupMainMenu();
    3939
    4040private:
     41
     42    /* Prepare helpers: */
     43    void prepareMainLayout();
     44    void prepareMenu();
     45#ifdef Q_WS_MAC
     46    void prepareVisualState();
     47#endif /* Q_WS_MAC */
     48    void loadSettings();
     49
     50    /* Cleanup helpers: */
     51    void saveSettings();
     52#ifdef Q_WS_MAC
     53    void cleanupVisualState();
     54#endif /* Q_WS_MAC */
     55    void cleanupMenu();
     56    //void cleanupMainLayout() {}
     57
     58    /* Show stuff: */
     59    void showInNecessaryMode();
    4160
    4261    /* Event handlers: */
     
    4463#ifdef Q_WS_WIN
    4564    bool winEvent(MSG *pMessage, long *pResult);
    46 #endif
     65#endif /* Q_WS_WIN */
    4766
    48     /* Prepare helpers: */
    49     void prepareMenu();
    50     void prepareMachineViewContainer();
    51     void prepareMachineView();
    52     void loadWindowSettings();
    53 
    54     /* Cleanup helpers: */
    55     void saveWindowSettings();
    56     void cleanupMachineView();
    57     //void cleanupMachineViewContainer() {}
    58     void cleanupMenu();
    59 
    60     /* Other members: */
    61     void showInNecessaryMode();
     67    /* Helpers: */
    6268    bool isMaximizedChecked();
    6369
    64     /* Other members: */
     70    /* Widgets: */
    6571    QMenu *m_pMainMenu;
     72
     73    /* Variables: */
    6674    QRect m_normalGeometry;
    6775
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp

    r41064 r41114  
    130130    /* Create machine window(s): */
    131131    for (int cScreenId = 0; cScreenId < m_pScreenLayout->guestScreenCount(); ++cScreenId)
    132         addMachineWindow(UIMachineWindow::create(this, visualStateType(), cScreenId));
     132        addMachineWindow(UIMachineWindow::create(this, cScreenId));
    133133
    134134    /* Connect screen-layout change handler: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r41107 r41114  
    1818 */
    1919
    20 /* Global includes */
     20/* Global includes: */
    2121#include <QDesktopWidget>
    2222#include <QTimer>
     
    2525#endif /* Q_WS_MAC */
    2626
    27 /* Local includes */
     27/* Local includes: */
    2828#include "VBoxGlobal.h"
    2929#ifndef Q_WS_MAC
    3030# include "VBoxMiniToolBar.h"
    31 #endif /* Q_WS_MAC */
    32 
     31#endif /* !Q_WS_MAC */
    3332#include "UISession.h"
    3433#include "UIActionPoolRuntime.h"
     
    3635#include "UIMachineWindowSeamless.h"
    3736#include "UIMachineViewSeamless.h"
    38 
    3937#ifdef Q_WS_MAC
    4038# include "VBoxUtils.h"
     
    4644#ifndef Q_WS_MAC
    4745    , m_pMiniToolBar(0)
    48 #endif /* Q_WS_MAC */
    49 {
    50     /* Set the main window in VBoxGlobal: */
    51     if (uScreenId == 0)
    52         vboxGlobal().setMainWindow(this);
    53 
    54     /* Prepare seamless window icon: */
    55     prepareWindowIcon();
    56 
    57     /* Prepare console connections: */
    58     prepareConsoleConnections();
    59 
    60     /* Prepare seamless window: */
    61     prepareSeamless();
    62 
    63     /* Prepare seamless menu: */
    64     prepareMenu();
    65 
    66     /* Prepare machine view container: */
    67     prepareMachineViewContainer();
    68 
    69     /* Prepare seamless machine view: */
    70     prepareMachineView();
    71 
    72     /* Prepare handlers: */
    73     prepareHandlers();
    74 
    75 #ifndef Q_WS_MAC
    76     /* Prepare mini tool-bar: */
    77     prepareMiniToolBar();
    78 #endif /* Q_WS_MAC */
    79 
    80     /* Retranslate fullscreen window finally: */
    81     retranslateUi();
    82 
    83 #ifdef Q_WS_MAC
    84     /* Load seamless window settings: */
    85     loadWindowSettings();
    86 #endif /* Q_WS_MAC */
    87 
    88     /* Update all the elements: */
    89     updateAppearanceOf(UIVisualElement_AllStuff);
    90 
    91     /* Show seamless window: */
    92     showInNecessaryMode();
    93 }
    94 
    95 UIMachineWindowSeamless::~UIMachineWindowSeamless()
    96 {
    97     /* Save window settings: */
    98     saveWindowSettings();
    99 
    100 #ifndef Q_WS_MAC
    101     /* Cleanup mini tool-bar: */
    102     cleanupMiniToolBar();
    103 #endif /* Q_WS_MAC */
    104 
    105     /* Prepare handlers: */
    106     cleanupHandlers();
    107 
    108     /* Cleanup machine view: */
    109     cleanupMachineView();
    110 
    111     /* Cleanup menu: */
    112     cleanupMenu();
    113 }
     46#endif /* !Q_WS_MAC */
     47{
     48}
     49
     50#ifndef Q_WS_MAC
     51void UIMachineWindowSeamless::sltMachineStateChanged()
     52{
     53    /* Call to base-class: */
     54    UIMachineWindow::sltMachineStateChanged();
     55
     56    /* Update mini-toolbar: */
     57    updateAppearanceOf(UIVisualElement_MiniToolBar);
     58}
     59#endif /* !Q_WS_MAC */
    11460
    11561void UIMachineWindowSeamless::sltPlaceOnScreen()
    11662{
    11763    /* Get corresponding screen: */
    118     int iScreen = static_cast<UIMachineLogicSeamless*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId);
     64    int iScreen = qobject_cast<UIMachineLogicSeamless*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId);
    11965    /* Calculate working area: */
    12066    QRect workingArea = vboxGlobal().availableGeometry(iScreen);
     
    12975void UIMachineWindowSeamless::sltPopupMainMenu()
    13076{
    131     /* Popup main menu if present: */
     77    /* Popup main-menu if present: */
    13278    if (m_pMainMenu && !m_pMainMenu->isEmpty())
    13379    {
     
    14086void UIMachineWindowSeamless::sltUpdateMiniToolBarMask()
    14187{
    142     if (m_pMiniToolBar)
     88    if (m_pMiniToolBar && machineView())
    14389        setMask(qobject_cast<UIMachineViewSeamless*>(machineView())->lastVisibleRegion());
    14490}
    145 #endif /* Q_WS_MAC */
     91#endif /* !Q_WS_MAC */
     92
     93void UIMachineWindowSeamless::prepareMenu()
     94{
     95    /* Call to base-class: */
     96    UIMachineWindow::prepareMenu();
     97
     98    /* Prepare menu: */
     99#ifdef Q_WS_MAC
     100    setMenuBar(uisession()->newMenuBar());
     101#endif /* Q_WS_MAC */
     102    m_pMainMenu = uisession()->newMenu();
     103}
     104
     105void UIMachineWindowSeamless::prepareVisualState()
     106{
     107    /* Call to base-class: */
     108    UIMachineWindow::prepareVisualState();
     109
     110    /* This might be required to correctly mask: */
     111    centralWidget()->setAutoFillBackground(false);
     112
     113#ifdef Q_WS_WIN
     114    /* Get corresponding screen: */
     115    int iScreen = qobject_cast<UIMachineLogicSeamless*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId);
     116    /* Prepare previous region: */
     117    m_prevRegion = vboxGlobal().availableGeometry(iScreen);
     118#endif /* Q_WS_WIN */
     119
     120#ifdef Q_WS_MAC
     121    /* Please note: All the stuff below has to be done after the window has
     122     * switched to fullscreen. Qt changes the winId on the fullscreen
     123     * switch and make this stuff useless with the old winId. So please be
     124     * careful on rearrangement of the method calls. */
     125    ::darwinSetShowsWindowTransparent(this, true);
     126#endif /* Q_WS_MAC */
     127
     128#ifndef Q_WS_MAC
     129    /* Prepare mini-toolbar: */
     130    prepareMiniToolbar();
     131#endif /* !Q_WS_MAC */
     132}
     133
     134#ifndef Q_WS_MAC
     135void UIMachineWindowSeamless::prepareMiniToolbar()
     136{
     137    /* Get machine: */
     138    CMachine m = machine();
     139
     140    /* Make sure mini-toolbar is necessary: */
     141    bool fIsActive = m.GetExtraData(VBoxDefs::GUI_ShowMiniToolBar) != "no";
     142    if (!fIsActive)
     143        return;
     144
     145    /* Get the mini-toolbar alignment: */
     146    bool fIsAtTop = m.GetExtraData(VBoxDefs::GUI_MiniToolBarAlignment) == "top";
     147    /* Get the mini-toolbar auto-hide feature availability: */
     148    bool fIsAutoHide = m.GetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide) != "off";
     149    m_pMiniToolBar = new VBoxMiniToolBar(centralWidget(),
     150                                         fIsAtTop ? VBoxMiniToolBar::AlignTop : VBoxMiniToolBar::AlignBottom,
     151                                         true, fIsAutoHide);
     152    m_pMiniToolBar->setSeamlessMode(true);
     153    m_pMiniToolBar->updateDisplay(true, true);
     154    QList<QMenu*> menus;
     155    QList<QAction*> actions = uisession()->newMenu()->actions();
     156    for (int i=0; i < actions.size(); ++i)
     157        menus << actions.at(i)->menu();
     158    *m_pMiniToolBar << menus;
     159    connect(m_pMiniToolBar, SIGNAL(minimizeAction()), this, SLOT(showMinimized()));
     160    connect(m_pMiniToolBar, SIGNAL(exitAction()),
     161            gActionPool->action(UIActionIndexRuntime_Toggle_Seamless), SLOT(trigger()));
     162    connect(m_pMiniToolBar, SIGNAL(closeAction()),
     163            gActionPool->action(UIActionIndexRuntime_Simple_Close), SLOT(trigger()));
     164    connect(m_pMiniToolBar, SIGNAL(geometryUpdated()), this, SLOT(sltUpdateMiniToolBarMask()));
     165}
     166#endif /* !Q_WS_MAC */
     167
     168#ifdef Q_WS_MAC
     169void UIMachineWindowSeamless::loadSettings()
     170{
     171    /* Call to base-class: */
     172    UIMachineWindow::loadSettings();
     173
     174    /* Load global settings: */
     175    {
     176        VBoxGlobalSettings settings = vboxGlobal().settings();
     177        menuBar()->setHidden(settings.isFeatureActive("noMenuBar"));
     178    }
     179}
     180#endif /* Q_WS_MAC */
     181
     182#ifndef Q_WS_MAC
     183void UIMachineWindowSeamless::cleanupMiniToolbar()
     184{
     185    /* Make sure mini-toolbar was created: */
     186    if (!m_pMiniToolBar)
     187        return;
     188
     189    /* Save mini-toolbar settings: */
     190    machine().SetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide, m_pMiniToolBar->isAutoHide() ? QString() : "off");
     191    /* Delete mini-toolbar: */
     192    delete m_pMiniToolBar;
     193    m_pMiniToolBar = 0;
     194}
     195#endif /* !Q_WS_MAC */
     196
     197void UIMachineWindowSeamless::cleanupVisualState()
     198{
     199#ifndef Q_WS_MAC
     200    /* Cleeanup mini-toolbar: */
     201    cleanupMiniToolbar();
     202#endif /* !Q_WS_MAC */
     203
     204    /* Call to base-class: */
     205    UIMachineWindow::cleanupVisualState();
     206}
     207
     208void UIMachineWindowSeamless::cleanupMenu()
     209{
     210    /* Cleanup menu: */
     211    delete m_pMainMenu;
     212    m_pMainMenu = 0;
     213
     214    /* Call to base-class: */
     215    UIMachineWindow::cleanupMenu();
     216}
     217
     218void UIMachineWindowSeamless::showInNecessaryMode()
     219{
     220    /* Make sure we really have to show window: */
     221    BOOL fEnabled = true;
     222    ULONG guestOriginX = 0, guestOriginY = 0, guestWidth = 0, guestHeight = 0;
     223    machine().QuerySavedGuestScreenInfo(m_uScreenId, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
     224    if (fEnabled)
     225    {
     226        /* Show manually maximized window: */
     227        sltPlaceOnScreen();
     228
     229        /* Show normal window: */
     230        show();
     231
     232#ifdef Q_WS_MAC
     233        /* Make sure it is really on the right place (especially on the Mac): */
     234        int iScreen = qobject_cast<UIMachineLogicSeamless*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId);
     235        QRect r = vboxGlobal().availableGeometry(iScreen);
     236        move(r.topLeft());
     237#endif /* Q_WS_MAC */
     238    }
     239}
     240
     241#ifndef Q_WS_MAC
     242void UIMachineWindowSeamless::updateAppearanceOf(int iElement)
     243{
     244    /* Call to base-class: */
     245    UIMachineWindow::updateAppearanceOf(iElement);
     246
     247    /* Update mini-toolbar: */
     248    if (iElement & UIVisualElement_MiniToolBar)
     249    {
     250        if (m_pMiniToolBar)
     251        {
     252            /* Get machine: */
     253            const CMachine &m = machine();
     254            /* Get snapshot(s): */
     255            QString strSnapshotName;
     256            if (m.GetSnapshotCount() > 0)
     257            {
     258                CSnapshot snapshot = m.GetCurrentSnapshot();
     259                strSnapshotName = " (" + snapshot.GetName() + ")";
     260            }
     261            /* Update mini-toolbar text: */
     262            m_pMiniToolBar->setDisplayText(m.GetName() + strSnapshotName);
     263        }
     264    }
     265}
     266#endif /* !Q_WS_MAC */
    146267
    147268#ifdef Q_WS_MAC
     
    159280            break;
    160281    }
    161     return QMainWindow::event(pEvent);
    162 }
    163 #endif /* Q_WS_MAC */
    164 
    165 void UIMachineWindowSeamless::prepareSeamless()
    166 {
    167 #ifdef Q_WS_WIN
    168     /* Get corresponding screen: */
    169     int iScreen = static_cast<UIMachineLogicSeamless*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId);
    170     /* Prepare previous region: */
    171     m_prevRegion = vboxGlobal().availableGeometry(iScreen);
    172 #endif
    173 
    174 #ifdef Q_WS_MAC
    175     /* Please note: All the stuff below has to be done after the window has
    176      * switched to fullscreen. Qt changes the winId on the fullscreen
    177      * switch and make this stuff useless with the old winId. So please be
    178      * careful on rearrangement of the method calls. */
    179     ::darwinSetShowsWindowTransparent(this, true);
    180 #endif
    181 }
    182 
    183 void UIMachineWindowSeamless::prepareMenu()
    184 {
    185 #ifdef Q_WS_MAC
    186     setMenuBar(uisession()->newMenuBar());
    187 #endif /* Q_WS_MAC */
    188     m_pMainMenu = uisession()->newMenu();
    189 }
    190 
    191 #ifndef Q_WS_MAC
    192 void UIMachineWindowSeamless::prepareMiniToolBar()
    193 {
    194     /* Get current machine: */
    195     CMachine machine = session().GetConsole().GetMachine();
    196     /* Check if mini tool-bar should present: */
    197     bool fIsActive = machine.GetExtraData(VBoxDefs::GUI_ShowMiniToolBar) != "no";
    198     if (fIsActive)
    199     {
    200         /* Get the mini tool-bar alignment: */
    201         bool fIsAtTop = machine.GetExtraData(VBoxDefs::GUI_MiniToolBarAlignment) == "top";
    202         /* Get the mini tool-bar auto-hide feature availability: */
    203         bool fIsAutoHide = machine.GetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide) != "off";
    204         m_pMiniToolBar = new VBoxMiniToolBar(centralWidget(),
    205                                              fIsAtTop ? VBoxMiniToolBar::AlignTop : VBoxMiniToolBar::AlignBottom,
    206                                              true, fIsAutoHide);
    207         m_pMiniToolBar->setSeamlessMode(true);
    208         m_pMiniToolBar->updateDisplay(true, true);
    209         QList<QMenu*> menus;
    210         QList<QAction*> actions = uisession()->newMenu()->actions();
    211         for (int i=0; i < actions.size(); ++i)
    212             menus << actions.at(i)->menu();
    213         *m_pMiniToolBar << menus;
    214         connect(m_pMiniToolBar, SIGNAL(minimizeAction()), this, SLOT(showMinimized()));
    215         connect(m_pMiniToolBar, SIGNAL(exitAction()),
    216                 gActionPool->action(UIActionIndexRuntime_Toggle_Seamless), SLOT(trigger()));
    217         connect(m_pMiniToolBar, SIGNAL(closeAction()),
    218                 gActionPool->action(UIActionIndexRuntime_Simple_Close), SLOT(trigger()));
    219         connect(m_pMiniToolBar, SIGNAL(geometryUpdated()), this, SLOT(sltUpdateMiniToolBarMask()));
    220     }
    221 }
    222 #endif /* Q_WS_MAC */
    223 
    224 void UIMachineWindowSeamless::prepareMachineView()
    225 {
    226 #ifdef VBOX_WITH_VIDEOHWACCEL
    227     /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled: */
    228     bool bAccelerate2DVideo = session().GetMachine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();
    229 #endif
    230 
    231     /* Set central widget: */
    232     setCentralWidget(new QWidget);
    233 
    234     /* Set central widget layout: */
    235     centralWidget()->setLayout(m_pMachineViewContainer);
    236 
    237     m_pMachineView = UIMachineView::create(  this
    238                                            , m_uScreenId
    239                                            , machineLogic()->visualStateType()
    240 #ifdef VBOX_WITH_VIDEOHWACCEL
    241                                            , bAccelerate2DVideo
    242 #endif
    243                                            );
    244 
    245     /* Add machine view into layout: */
    246     m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);
    247 
    248     /* This might be required to correctly mask: */
    249     centralWidget()->setAutoFillBackground(false);
    250 }
    251 
    252 #ifdef Q_WS_MAC
    253 void UIMachineWindowSeamless::loadWindowSettings()
    254 {
    255     /* Load global settings: */
    256     {
    257         VBoxGlobalSettings settings = vboxGlobal().settings();
    258         menuBar()->setHidden(settings.isFeatureActive("noMenuBar"));
    259     }
    260 }
    261 #endif
    262 
    263 void UIMachineWindowSeamless::saveWindowSettings()
    264 {
    265 #ifndef Q_WS_MAC
    266     /* Get machine: */
    267     CMachine machine = session().GetConsole().GetMachine();
    268 
    269     /* Save extra-data settings: */
    270     {
    271         /* Save mini tool-bar settings: */
    272         if (m_pMiniToolBar)
    273             machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide, m_pMiniToolBar->isAutoHide() ? QString() : "off");
    274     }
    275 #endif /* Q_WS_MAC */
    276 }
    277 
    278 void UIMachineWindowSeamless::cleanupMachineView()
    279 {
    280     /* Do not cleanup machine view if it is not present: */
    281     if (!machineView())
    282         return;
    283 
    284     UIMachineView::destroy(m_pMachineView);
    285     m_pMachineView = 0;
    286 }
    287 
    288 #ifndef Q_WS_MAC
    289 void UIMachineWindowSeamless::cleanupMiniToolBar()
    290 {
    291     if (m_pMiniToolBar)
    292     {
    293         delete m_pMiniToolBar;
    294         m_pMiniToolBar = 0;
    295     }
    296 }
    297 #endif /* Q_WS_MAC */
    298 
    299 void UIMachineWindowSeamless::cleanupMenu()
    300 {
    301     delete m_pMainMenu;
    302     m_pMainMenu = 0;
    303 }
    304 
    305 void UIMachineWindowSeamless::updateAppearanceOf(int iElement)
    306 {
    307     /* Base class update: */
    308     UIMachineWindow::updateAppearanceOf(iElement);
    309 
    310     /* If mini tool-bar is present: */
    311 #ifndef Q_WS_MAC
    312     if (m_pMiniToolBar)
    313     {
    314         /* Get machine: */
    315         CMachine machine = session().GetConsole().GetMachine();
    316         /* Get snapshot(s): */
    317         QString strSnapshotName;
    318         if (machine.GetSnapshotCount() > 0)
    319         {
    320             CSnapshot snapshot = machine.GetCurrentSnapshot();
    321             strSnapshotName = " (" + snapshot.GetName() + ")";
    322         }
    323         /* Update mini tool-bar text: */
    324         m_pMiniToolBar->setDisplayText(machine.GetName() + strSnapshotName);
    325     }
    326 #endif /* Q_WS_MAC */
    327 }
    328 
    329 void UIMachineWindowSeamless::showInNecessaryMode()
    330 {
    331     /* Make sure we really have to show window: */
    332     BOOL fEnabled = true;
    333     ULONG guestOriginX = 0, guestOriginY = 0, guestWidth = 0, guestHeight = 0;
    334     session().GetMachine().QuerySavedGuestScreenInfo(m_uScreenId, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
    335     if (fEnabled)
    336     {
    337         /* Show manually maximized window: */
    338         sltPlaceOnScreen();
    339 
    340         /* Show normal window: */
    341         show();
    342 
    343 #ifdef Q_WS_MAC
    344         /* Make sure it is really on the right place (especially on the Mac): */
    345         int iScreen = static_cast<UIMachineLogicSeamless*>(machineLogic())->hostScreenForGuestScreen(m_uScreenId);
    346         QRect r = vboxGlobal().availableGeometry(iScreen);
    347         move(r.topLeft());
    348 #endif /* Q_WS_MAC */
    349     }
    350 }
     282    return UIMachineWindow::event(pEvent);
     283}
     284#endif /* Q_WS_MAC */
    351285
    352286void UIMachineWindowSeamless::setMask(const QRegion &constRegion)
     
    373307        toolBarRegion.translate(QPoint(m_pMiniToolBar->x(), m_pMiniToolBar->y()));
    374308
    375         /* Including mini tool-bar mask: */
     309        /* Including mini-toolbar mask: */
    376310        region += toolBarRegion;
    377311    }
    378 #endif /* Q_WS_MAC */
     312#endif /* !Q_WS_MAC */
    379313
    380314#if 0 // TODO: Is it really needed now?
     
    405339    SetWindowRgn(winId(), newReg, FALSE);
    406340    RedrawWindow(0, 0, diffReg, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
    407     RedrawWindow(machineView()->viewport()->winId(), 0, 0, RDW_INVALIDATE);
     341    if (machineView())
     342        RedrawWindow(machineView()->viewport()->winId(), 0, 0, RDW_INVALIDATE);
    408343
    409344    m_prevRegion = region;
     
    436371        // /* Now force the reshaping of the window. This is definitely necessary. */
    437372        // ReshapeCustomWindow (reinterpret_cast <WindowPtr> (winId()));
    438         QMainWindow::setMask(region);
     373        UIMachineWindow::setMask(region);
    439374        // HIWindowInvalidateShadow (::darwinToWindowRef (mConsole->viewport()));
    440375    }
    441376#else
    442     QMainWindow::setMask(region);
     377    UIMachineWindow::setMask(region);
    443378#endif
    444379}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.h

    r41107 r41114  
    2020#define __UIMachineWindowSeamless_h__
    2121
    22 /* Local includes */
     22/* Local includes: */
    2323#include "UIMachineWindow.h"
    2424
    25 /* Local forwards */
     25/* Forward declarations: */
    2626class VBoxMiniToolBar;
    2727
     28/* Seamless machine-window implementation: */
    2829class UIMachineWindowSeamless : public UIMachineWindow
    2930{
    3031    Q_OBJECT;
    3132
    32 public slots:
    33 
    34     void sltPlaceOnScreen();
    35 
    3633protected:
    3734
    38     /* Seamless machine window constructor/destructor: */
     35    /* Constructor: */
    3936    UIMachineWindowSeamless(UIMachineLogic *pMachineLogic, ulong uScreenId);
    40     virtual ~UIMachineWindowSeamless();
    4137
    4238private slots:
     39
     40#ifndef Q_WS_MAC
     41    /* Session event-handlers: */
     42    void sltMachineStateChanged();
     43#endif /* !Q_WS_MAC */
     44
     45    /* Places window on screen: */
     46    void sltPlaceOnScreen();
    4347
    4448    /* Popup main menu: */
    4549    void sltPopupMainMenu();
    4650
    47 #ifndef RT_OS_DARWIN /* Something is *really* broken in regards of the moc here */
     51#ifndef Q_WS_MAC
    4852    /* Update mini tool-bar mask: */
    4953    void sltUpdateMiniToolBarMask();
    50 #endif /* RT_OS_DARWIN */
     54#endif /* !Q_WS_MAC */
    5155
    5256private:
    5357
     58    /* Prepare helpers: */
     59    void prepareMenu();
     60    void prepareVisualState();
     61#ifndef Q_WS_MAC
     62    void prepareMiniToolbar();
     63#endif /* !Q_WS_MAC */
     64#ifdef Q_WS_MAC
     65    void loadSettings();
     66#endif /* Q_WS_MAC */
     67
     68    /* Cleanup helpers: */
     69#ifdef Q_WS_MAC
     70    //void saveSettings() {}
     71#endif /* Q_WS_MAC */
     72#ifndef Q_WS_MAC
     73    void cleanupMiniToolbar();
     74#endif /* !Q_WS_MAC */
     75    void cleanupVisualState();
     76    void cleanupMenu();
     77
     78    /* Show stuff: */
     79    void showInNecessaryMode();
     80
     81#ifndef Q_WS_MAC
     82    /* Update routines: */
     83    void updateAppearanceOf(int iElement);
     84#endif /* !Q_WS_MAC */
     85
     86#ifdef Q_WS_MAC
    5487    /* Event handlers: */
    55 #ifdef Q_WS_MAC
    5688    bool event(QEvent *pEvent);
    5789#endif /* Q_WS_MAC */
    5890
    59     /* Prepare helpers: */
    60     void prepareSeamless();
    61     void prepareMenu();
    62 #ifndef Q_WS_MAC
    63     void prepareMiniToolBar();
    64 #endif /* Q_WS_MAC */
    65     void prepareMachineView();
    66 #ifdef Q_WS_MAC
    67     void loadWindowSettings();
    68 #endif /* Q_WS_MAC */
    69 
    70     /* Cleanup helpers: */
    71     void saveWindowSettings();
    72     void cleanupMachineView();
    73 #ifndef Q_WS_MAC
    74     void cleanupMiniToolBar();
    75 #endif /* Q_WS_MAC */
    76     void cleanupMenu();
    77     //void cleanupSeamless() {}
    78 
    79     /* Update routines: */
    80     void updateAppearanceOf(int iElement);
    81 
    82     /* Other members: */
    83     void showInNecessaryMode();
     91    /* Helpers: */
    8492    void setMask(const QRegion &region);
    8593
    86     /* Private variables: */
     94    /* Widgets: */
    8795    QMenu *m_pMainMenu;
    8896#ifndef Q_WS_MAC
    8997    VBoxMiniToolBar *m_pMiniToolBar;
    90 #endif /* Q_WS_MAC */
     98#endif /* !Q_WS_MAC */
     99
     100    /* Variables: */
    91101#ifdef Q_WS_WIN
    92102    QRegion m_prevRegion;
Note: See TracChangeset for help on using the changeset viewer.

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