VirtualBox

Changeset 28457 in vbox


Ignore:
Timestamp:
Apr 19, 2010 12:36:06 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
60230
Message:

FE/Qt: New running VM core menubar fixes: 1. Normal mode menubar now works properly under win host; 2. Fullscreen/Seamless modes menubar now highlights first menu item (as in old core).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r28406 r28457  
    420420VirtualBox_QT_MOCSRCS += \
    421421        src/runtime/UIActionsPool.cpp \
     422        src/runtime/UIMachineMenuBar.cpp \
    422423        src/runtime/UIIndicatorsPool.cpp \
    423424        src/runtime/UIMachine.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp

    r27599 r28457  
    3232#include <QMenuBar>
    3333
     34/* Helper QMenu reimplementation which allows
     35 * to highlight first menu item for popped up menu: */
     36class UIMenu : public QMenu
     37{
     38    Q_OBJECT;
     39
     40public:
     41
     42    UIMenu() : QMenu(0) {}
     43
     44private slots:
     45
     46    void sltSelectFirstAction()
     47    {
     48#ifdef Q_WS_WIN
     49        activateWindow();
     50#endif
     51        QMenu::focusNextChild();
     52    }
     53};
     54
    3455UIMachineMenuBar::UIMachineMenuBar()
    3556    /* On the Mac we add some items only the first time, cause otherwise they
     
    4263{
    4364    /* Create empty menu: */
    44     QMenu *pMenu = new QMenu;
     65    QMenu *pMenu = new UIMenu;
    4566
    4667    /* Fill menu with prepared items: */
     
    241262}
    242263
     264#include "UIMachineMenuBar.moc"
     265
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r27662 r28457  
    2424/* Global includes */
    2525#include <QDesktopWidget>
     26#include <QTimer>
    2627#ifdef Q_WS_MAC
    2728# include <QMenuBar>
     
    130131    /* Popup main menu if present: */
    131132    if (m_pMainMenu && !m_pMainMenu->isEmpty())
     133    {
    132134        m_pMainMenu->popup(machineWindow()->geometry().center());
     135        QTimer::singleShot(0, m_pMainMenu, SLOT(sltSelectFirstAction()));
     136    }
    133137}
    134138
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp

    r27538 r28457  
    175175                            pMenuBar->activeAction()->activate(QAction::Trigger);
    176176
     177#ifdef Q_WS_WIN
     178                            /* Windows host needs separate 'focus set'
     179                             * to let menubar operate while popped up: */
     180                            pMenuBar->setFocus();
     181#endif /* ifdef Q_WS_WIN */
     182
    177183                            /* Accept this event: */
    178184                            pEvent->accept();
     
    197203    QMainWindow *pMainDialog = machineWindowWrapper() && machineWindowWrapper()->machineWindow() ?
    198204                               qobject_cast<QMainWindow*>(machineWindowWrapper()->machineWindow()) : 0;
     205#ifdef Q_WS_WIN
     206    QMenuBar *pMenuBar = pMainDialog ? pMainDialog->menuBar() : 0;
     207#endif /* ifdef Q_WS_WIN */
    199208
    200209    if (pWatched != 0 && pWatched == pMainDialog)
     
    228237    }
    229238
     239#ifdef Q_WS_WIN
     240    else if (pWatched != 0 && pWatched == pMenuBar)
     241    {
     242        /* Due to windows host uses separate 'focus set' to let menubar to
     243         * operate while popped up (see UIMachineViewNormal::event() for details),
     244         * it also requires backward processing: */
     245        switch (pEvent->type())
     246        {
     247            /* If menubar gets the focus while not popped up => give it back: */
     248            case QEvent::FocusIn:
     249            {
     250                if (!QApplication::activePopupWidget())
     251                    setFocus();
     252            }
     253            default:
     254                break;
     255        }
     256    }
     257#endif /* ifdef Q_WS_WIN */
     258
    230259    return UIMachineView::eventFilter(pWatched, pEvent);
    231260}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r27662 r28457  
    2424/* Global includes */
    2525#include <QDesktopWidget>
     26#include <QTimer>
    2627#ifdef Q_WS_MAC
    2728# include <QMenuBar>
     
    127128    /* Popup main menu if present: */
    128129    if (m_pMainMenu && !m_pMainMenu->isEmpty())
     130    {
    129131        m_pMainMenu->popup(machineWindow()->geometry().center());
     132        QTimer::singleShot(0, m_pMainMenu, SLOT(sltSelectFirstAction()));
     133    }
    130134}
    131135
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