VirtualBox

Changeset 61965 in vbox


Ignore:
Timestamp:
Jun 30, 2016 5:20:40 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
108411
Message:

FE/Qt: bugref:5978: Runtime UI: Moving mini-toolbar logic code to UIMiniToolBar class.

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

Legend:

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

    r61964 r61965  
    363363# endif /* QT_VERSION < 0x050000 */
    364364
    365     /* If there is a mini-toolbar: */
    366     if (m_pMiniToolBar)
    367     {
    368 # if QT_VERSION >= 0x050000
    369         /* Map mini-toolbar onto required screen: */
    370         m_pMiniToolBar->windowHandle()->setScreen(qApp->screens().at(iHostScreen));
    371 # endif /* QT_VERSION >= 0x050000 */
    372         /* Set appropriate mini-toolbar size: */
    373         m_pMiniToolBar->resize(workingArea.size());
    374 # if QT_VERSION < 0x050000
    375         /* Move mini-toolbar onto required screen: */
    376         m_pMiniToolBar->move(workingArea.topLeft());
    377 # endif /* QT_VERSION < 0x050000 */
    378     }
    379 
    380365#elif defined(VBOX_WS_X11)
    381366
     
    387372        /* Tell recent window managers which host-screen this window should be mapped to: */
    388373        VBoxGlobal::setFullScreenMonitorX11(this, pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId));
    389 
    390         /* If there is a mini-toolbar: */
    391         if (m_pMiniToolBar)
    392         {
    393             /* Tell recent window managers which host-screen this mini-toolbar should be mapped to: */
    394             VBoxGlobal::setFullScreenMonitorX11(m_pMiniToolBar, pFullscreenLogic->hostScreenForGuestScreen(m_uScreenId));
    395         }
    396     }
    397 
    398     /* Set appropriate geometry for window: */
     374    }
     375
     376    /* Set appropriate window geometry: */
    399377    resize(workingArea.size());
    400378    move(workingArea.topLeft());
    401 
    402     /* If there is a mini-toolbar: */
    403     if (m_pMiniToolBar)
    404     {
    405         /* Set appropriate geometry for mini-toolbar: */
    406         m_pMiniToolBar->resize(workingArea.size());
    407         m_pMiniToolBar->move(workingArea.topLeft());
    408     }
    409379
    410380#else
     
    462432        setWindowState(Qt::WindowNoState);
    463433        hide();
    464 
    465         /* If there is mini-toolbar: */
    466         if (m_pMiniToolBar)
    467         {
    468             /* Hide mini-toolbar and reset it's state to NONE: */
    469             m_pMiniToolBar->setWindowState(Qt::WindowNoState);
    470             m_pMiniToolBar->hide();
    471         }
    472434    }
    473435    /* If window should be shown and mapped to some host-screen: */
     
    480442        /* Make sure window have appropriate geometry: */
    481443        placeOnScreen();
    482 
    483         /* If there is mini-toolbar: */
    484         if (m_pMiniToolBar)
    485         {
    486             /* Show mini-toolbar: */
    487             m_pMiniToolBar->showFullScreen();
    488         }
    489444
    490445        /* Show window: */
     
    518473        setWindowState(Qt::WindowNoState);
    519474        hide();
    520 
    521         /* If there is mini-toolbar: */
    522         if (m_pMiniToolBar)
    523         {
    524             /* Hide mini-toolbar and reset it's state to NONE: */
    525             m_pMiniToolBar->setWindowState(Qt::WindowNoState);
    526             m_pMiniToolBar->hide();
    527         }
    528475    }
    529476    /* If window should be shown and mapped to some host-screen: */
     
    536483        /* Show window: */
    537484        showFullScreen();
    538 
    539         /* If there is mini-toolbar: */
    540         if (m_pMiniToolBar)
    541         {
    542             /* Show mini-toolbar: */
    543             m_pMiniToolBar->showFullScreen();
    544         }
    545485
    546486        /* Make sure window have appropriate geometry: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp

    r61884 r61965  
    3030# include <QStateMachine>
    3131# include <QPainter>
     32# include <QDesktopWidget>
     33# ifdef VBOX_WS_WIN
     34#  include <QWindow>
     35# endif /* VBOX_WS_WIN */
    3236
    3337/* GUI includes: */
     
    3640# include "UIIconPool.h"
    3741# include "VBoxGlobal.h"
     42# ifdef VBOX_WS_X11
     43#  include "UIExtraDataManager.h"
     44# endif /* VBOX_WS_X11 */
    3845
    3946#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    555562}
    556563
     564void UIMiniToolBar::sltHide()
     565{
     566    LogRel2(("GUI: UIMiniToolBar::sltHide\n"));
     567
     568#if defined(VBOX_WS_MAC)
     569
     570    // Nothing
     571
     572#elif defined(VBOX_WS_WIN)
     573
     574    /* Reset window state to NONE and hide it: */
     575    setWindowState(Qt::WindowNoState);
     576    hide();
     577
     578#elif defined(VBOX_WS_X11)
     579
     580    /* Just hide window: */
     581    hide();
     582
     583#else
     584
     585# warning "port me"
     586
     587#endif
     588}
     589
     590void UIMiniToolBar::sltShow()
     591{
     592    LogRel2(("GUI: UIMiniToolBar::sltShow\n"));
     593
     594#if defined(VBOX_WS_MAC)
     595
     596    // Nothing
     597
     598#elif defined(VBOX_WS_WIN)
     599
     600    /* Adjust window before showing full-screen: */
     601    sltAdjust();
     602    showFullScreen();
     603
     604#elif defined(VBOX_WS_X11)
     605
     606    /* Show window full-screen before adjusting: */
     607    showFullScreen();
     608    sltAdjust();
     609
     610#else
     611
     612# warning "port me"
     613
     614#endif
     615}
     616
     617void UIMiniToolBar::sltAdjust()
     618{
     619    LogRel2(("GUI: UIMiniToolBar::sltAdjust\n"));
     620
     621    /* Get corresponding host-screen: */
     622    const int iHostScreen = QApplication::desktop()->screenNumber(parentWidget());
     623    Q_UNUSED(iHostScreen);
     624    /* And corresponding working area: */
     625    const QRect workingArea = vboxGlobal().screenGeometry(iHostScreen);
     626    Q_UNUSED(workingArea);
     627
     628#if defined(VBOX_WS_MAC)
     629
     630    // Nothing
     631
     632#elif defined(VBOX_WS_WIN)
     633
     634# if QT_VERSION >= 0x050000
     635    /* Map window onto required screen: */
     636    Assert(iHostScreen < qApp->screens().size());
     637    windowHandle()->setScreen(qApp->screens().at(iHostScreen));
     638# endif /* QT_VERSION >= 0x050000 */
     639    /* Set appropriate window size: */
     640    resize(workingArea.size());
     641# if QT_VERSION < 0x050000
     642    /* Move window onto required screen: */
     643    move(workingArea.topLeft());
     644# endif /* QT_VERSION < 0x050000 */
     645
     646#elif defined(VBOX_WS_X11)
     647
     648    /* Determine whether we should use the native full-screen mode: */
     649    const bool fUseNativeFullScreen = VBoxGlobal::supportsFullScreenMonitorsProtocolX11() &&
     650                                      !gEDataManager->legacyFullscreenModeRequested();
     651    if (fUseNativeFullScreen)
     652    {
     653        /* Tell recent window managers which host-screen this window should be mapped to: */
     654        VBoxGlobal::setFullScreenMonitorX11(this, iHostScreen);
     655    }
     656
     657    /* Set appropriate window geometry: */
     658    resize(workingArea.size());
     659    move(workingArea.topLeft());
     660
     661    /* Re-apply the full-screen state lost on above move(): */
     662    setWindowState(Qt::WindowFullScreen);
     663
     664#else
     665
     666# warning "port me"
     667
     668#endif
     669}
     670
    557671void UIMiniToolBar::prepare()
    558672{
    559     /* Install own event-filter
    560      * to handle window activation stealing: */
     673    /* Install event-filters: */
    561674    installEventFilter(this);
     675    parent()->installEventFilter(this);
    562676
    563677#if   defined(VBOX_WS_WIN)
     
    719833    }
    720834
     835    /* If that's parent window event: */
     836    if (pWatched == parent())
     837    {
     838        switch (pEvent->type())
     839        {
     840            case QEvent::Hide:
     841            {
     842                /* Asynchronously call for sltHide(): */
     843                LogRel2(("GUI: UIMiniToolBar::eventFilter: Parent hide event\n"));
     844                QMetaObject::invokeMethod(this, "sltHide", Qt::QueuedConnection);
     845                break;
     846            }
     847            case QEvent::Show:
     848            {
     849                /* Asynchronously call for sltShow(): */
     850                LogRel2(("GUI: UIMiniToolBar::eventFilter: Parent show event\n"));
     851                QMetaObject::invokeMethod(this, "sltShow", Qt::QueuedConnection);
     852                break;
     853            }
     854            case QEvent::Move:
     855            case QEvent::Resize:
     856            {
     857                /* Skip if parent or we are invisible: */
     858                if (   !parentWidget()->isVisible()
     859                    || !isVisible())
     860                    break;
     861
     862#if   defined(VBOX_WS_MAC)
     863                // Nothing
     864#elif defined(VBOX_WS_WIN)
     865                /* Asynchronously call for sltShow() to adjust and expose both: */
     866                LogRel2(("GUI: UIMiniToolBar::eventFilter: Parent move/resize event\n"));
     867                QMetaObject::invokeMethod(this, "sltShow", Qt::QueuedConnection);
     868#elif defined(VBOX_WS_X11)
     869                /* Asynchronously call for just sltAdjust() because it's enough: */
     870                LogRel2(("GUI: UIMiniToolBar::eventFilter: Parent move/resize event\n"));
     871                QMetaObject::invokeMethod(this, "sltAdjust", Qt::QueuedConnection);
     872#else
     873# warning "port me"
     874#endif
     875                break;
     876            }
     877            default:
     878                break;
     879        }
     880    }
     881
    721882    /* Call to base-class: */
    722883    return QWidget::eventFilter(pWatched, pEvent);
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.h

    r61884 r61965  
    115115    void sltNotifyAboutWindowActivationStolen() { emit sigNotifyAboutWindowActivationStolen(); }
    116116
     117    /** Hides window. */
     118    void sltHide();
     119    /** Shows and adjusts window according to parent. */
     120    void sltShow();
     121    /** Adjusts window according to parent. */
     122    void sltAdjust();
     123
    117124private:
    118125
Note: See TracChangeset for help on using the changeset viewer.

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