VirtualBox

Ignore:
Timestamp:
Jul 1, 2016 2:32:54 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
108426
Message:

FE/Qt: bugref:5978: Runtime UI: Mini-toolbar minimization support for Qt5, especially under X11.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp

    r61965 r61979  
    3434#  include <QWindow>
    3535# endif /* VBOX_WS_WIN */
     36# if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     37#  include <QWindowStateChangeEvent>
     38# endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
    3639
    3740/* GUI includes: */
     
    422425    , m_pHoverLeaveTimer(0)
    423426    , m_pAnimation(0)
     427#if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     428    , m_fIsParentMinimized(false)
     429#endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
    424430{
    425431    /* Prepare: */
     
    833839    }
    834840
     841#if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     842    /* If that's window event: */
     843    if (pWatched == this)
     844    {
     845        switch (pEvent->type())
     846        {
     847            case QEvent::WindowStateChange:
     848            {
     849                /* Watch for window state changes: */
     850                QWindowStateChangeEvent *pChangeEvent = static_cast<QWindowStateChangeEvent*>(pEvent);
     851                LogRel2(("GUI: UIMiniToolBar::eventFilter: Window state changed from %d to %d\n",
     852                         (int)pChangeEvent->oldState(), (int)windowState()));
     853                if (   windowState() != Qt::WindowMinimized
     854                    && pChangeEvent->oldState() == Qt::WindowMinimized)
     855                {
     856                    /* Asynchronously call for sltShow(): */
     857                    LogRel2(("GUI: UIMiniToolBar::eventFilter: Window restored\n"));
     858                    QMetaObject::invokeMethod(this, "sltShow", Qt::QueuedConnection);
     859                }
     860                break;
     861            }
     862            default:
     863                break;
     864        }
     865    }
     866#endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     867
    835868    /* If that's parent window event: */
    836869    if (pWatched == parent())
     
    840873            case QEvent::Hide:
    841874            {
     875                /* Skip if parent or we are minimized: */
     876                if (   isParentMinimized()
     877                    || isMinimized())
     878                    break;
     879
    842880                /* Asynchronously call for sltHide(): */
    843881                LogRel2(("GUI: UIMiniToolBar::eventFilter: Parent hide event\n"));
     
    847885            case QEvent::Show:
    848886            {
     887                /* Skip if parent or we are minimized: */
     888                if (   isParentMinimized()
     889                    || isMinimized())
     890                    break;
     891
    849892                /* Asynchronously call for sltShow(): */
    850893                LogRel2(("GUI: UIMiniToolBar::eventFilter: Parent show event\n"));
     
    858901                if (   !parentWidget()->isVisible()
    859902                    || !isVisible())
     903                    break;
     904                /* Skip if parent or we are minimized: */
     905                if (   isParentMinimized()
     906                    || isMinimized())
    860907                    break;
    861908
     
    875922                break;
    876923            }
     924#if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     925            case QEvent::WindowStateChange:
     926            {
     927                /* Watch for parent window state changes: */
     928                QWindowStateChangeEvent *pChangeEvent = static_cast<QWindowStateChangeEvent*>(pEvent);
     929                LogRel2(("GUI: UIMiniToolBar::eventFilter: Parent window state changed from %d to %d\n",
     930                         (int)pChangeEvent->oldState(), (int)parentWidget()->windowState()));
     931                if (parentWidget()->windowState() & Qt::WindowMinimized)
     932                {
     933                    /* Mark parent window minimized, isMinimized() is not enough due to Qt5vsX11 fight: */
     934                    LogRel2(("GUI: UIMiniToolBar::eventFilter: Parent window minimized\n"));
     935                    m_fIsParentMinimized = true;
     936                }
     937                else
     938                if (parentWidget()->windowState() == Qt::WindowFullScreen)
     939                {
     940                    /* Mark parent window non-minimized, isMinimized() is not enough due to Qt5vsX11 fight: */
     941                    LogRel2(("GUI: UIMiniToolBar::eventFilter: Parent window is full-screen\n"));
     942                    m_fIsParentMinimized = false;
     943                }
     944                break;
     945            }
     946#endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
    877947            default:
    878948                break;
     
    917987}
    918988
     989bool UIMiniToolBar::isParentMinimized() const
     990{
     991#if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     992    return m_fIsParentMinimized;
     993#else /* !VBOX_WS_X11 || QT_VERSION < 0x050000 */
     994    return parentWidget()->isMinimized();
     995#endif /* !VBOX_WS_X11 || QT_VERSION < 0x050000 */
     996}
     997
    919998#include "UIMiniToolBar.moc"
    920999
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.h

    r61965 r61979  
    153153    QPoint shownToolbarPosition() const { return m_shownToolbarPosition; }
    154154
     155    /** Returns whether the parent is currently minimized. */
     156    bool isParentMinimized() const;
     157
    155158    /** Holds the geometry type. */
    156159    const GeometryType m_geometryType;
     
    180183    /** Holds the animation framework object. */
    181184    UIAnimation *m_pAnimation;
     185
     186#if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     187    /** Holds whether the parent is currently minimized.
     188      * Used to restore full-screen state when the parent restored again. */
     189    bool m_fIsParentMinimized;
     190#endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
    182191};
    183192
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