VirtualBox

Ignore:
Timestamp:
May 3, 2017 10:47:47 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
115163
Message:

FE/Qt: bugref:8849: Rework MDI-based overlay windows (sliding-toolbar and mini-toolbar) to be simple QWidget-based.

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

Legend:

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

    r66678 r66755  
    109109#include <QMainWindow>
    110110#include <QMap>
    111 #include <QMdiArea>
    112 #include <QMdiSubWindow>
    113111#include <QMenu>
    114112#include <QMenuBar>
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISlidingToolBar.cpp

    r64334 r66755  
    55
    66/*
    7  * Copyright (C) 2014-2016 Oracle Corporation
     7 * Copyright (C) 2014-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121
    2222/* Qt includes: */
    23 # include <QMdiSubWindow>
    2423# include <QHBoxLayout>
    25 # include <QMdiArea>
    2624
    2725/* GUI includes: */
     
    4543    , m_fExpanded(false)
    4644    , m_pMainLayout(0)
    47     , m_pMdiArea(0)
     45    , m_pArea(0)
    4846    , m_pWidget(pChildWidget)
    49     , m_pEmbeddedWidget(0)
    5047{
    5148    /* Prepare: */
     
    10299        m_pMainLayout->setContentsMargins(0, 0, 0, 0);
    103100        m_pMainLayout->setSpacing(0);
    104         /* Create mdi-area: */
    105         m_pMdiArea = new QMdiArea;
    106         AssertPtrReturnVoid(m_pMdiArea);
    107         {
    108             /* Configure mdi-area: */
    109             m_pMdiArea->setAcceptDrops(true);
    110             m_pMdiArea->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    111             QPalette pal1 = m_pMdiArea->palette();
     101        /* Create area: */
     102        m_pArea = new QWidget;
     103        AssertPtrReturnVoid(m_pArea);
     104        {
     105            /* Configure area: */
     106            m_pArea->setAcceptDrops(true);
     107            m_pArea->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
     108            QPalette pal1 = m_pArea->palette();
    112109            pal1.setColor(QPalette::Window, QColor(Qt::transparent));
    113             m_pMdiArea->setPalette(pal1);
    114             m_pMdiArea->setBackground(QColor(Qt::transparent));
     110            m_pArea->setPalette(pal1);
    115111            /* Make sure valid child-widget passed: */
    116112            AssertPtrReturnVoid(m_pWidget);
     
    121117                m_pWidget->setPalette(pal2);
    122118                connect(m_pWidget, SIGNAL(sigCancelClicked()), this, SLOT(close()));
    123                 /* Add child-widget into mdi-area: */
    124                 m_pEmbeddedWidget = m_pMdiArea->addSubWindow(m_pWidget, Qt::Window | Qt::FramelessWindowHint);
    125                 AssertPtrReturnVoid(m_pEmbeddedWidget);
     119                /* Add child-widget into area: */
     120                m_pWidget->setParent(m_pArea);
    126121            }
    127             /* Add mdi-area into main-layout: */
    128             m_pMainLayout->addWidget(m_pMdiArea);
     122            /* Add area into main-layout: */
     123            m_pMainLayout->addWidget(m_pArea);
    129124        }
    130125    }
     
    133128void UISlidingToolBar::prepareGeometry()
    134129{
    135     /* Prepare geometry based on parent and mdi-sub-window size-hints,
    136      * But move mdi-sub-window to initial position: */
    137     const QSize sh = m_pEmbeddedWidget->sizeHint();
     130    /* Prepare geometry based on parent and sub-window size-hints,
     131     * But move sub-window to initial position: */
     132    const QSize sh = m_pWidget->sizeHint();
    138133    switch (m_position)
    139134    {
     
    142137            VBoxGlobal::setTopLevelGeometry(this, m_parentRect.x(), m_parentRect.y()                         + m_indentRect.height(),
    143138                                                  qMax(m_parentRect.width(), sh.width()), sh.height());
    144             m_pEmbeddedWidget->setGeometry(0, -sh.height(), qMax(width(), sh.width()), sh.height());
     139            m_pWidget->setGeometry(0, -sh.height(), qMax(width(), sh.width()), sh.height());
    145140            break;
    146141        }
     
    149144            VBoxGlobal::setTopLevelGeometry(this, m_parentRect.x(), m_parentRect.y() + m_parentRect.height() - m_indentRect.height() - sh.height(),
    150145                                                  qMax(m_parentRect.width(), sh.width()), sh.height());
    151             m_pEmbeddedWidget->setGeometry(0,  sh.height(), qMax(width(), sh.width()), sh.height());
     146            m_pWidget->setGeometry(0,  sh.height(), qMax(width(), sh.width()), sh.height());
    152147            break;
    153148        }
     
    158153    {
    159154        /* Use Xshape otherwise: */
    160         setMask(m_pEmbeddedWidget->geometry());
     155        setMask(m_pWidget->geometry());
    161156    }
    162157#endif /* VBOX_WS_X11 */
     
    177172void UISlidingToolBar::prepareAnimation()
    178173{
    179     /* Prepare mdi-sub-window geometry animation itself: */
     174    /* Prepare sub-window geometry animation itself: */
    180175    connect(this, SIGNAL(sigShown()), this, SIGNAL(sigExpand()), Qt::QueuedConnection);
    181176    m_pAnimation = UIAnimation::installPropertyAnimation(this,
     
    191186void UISlidingToolBar::adjustGeometry()
    192187{
    193     /* Adjust geometry based on parent and mdi-sub-window size-hints: */
    194     const QSize sh = m_pEmbeddedWidget->sizeHint();
     188    /* Adjust geometry based on parent and sub-window size-hints: */
     189    const QSize sh = m_pWidget->sizeHint();
    195190    switch (m_position)
    196191    {
     
    208203        }
    209204    }
    210     /* And move mdi-sub-window to corresponding position: */
    211     m_pEmbeddedWidget->setGeometry(0, 0, qMax(width(), sh.width()), sh.height());
     205    /* And move sub-window to corresponding position: */
     206    m_pWidget->setGeometry(0, 0, qMax(width(), sh.width()), sh.height());
    212207
    213208#ifdef VBOX_WS_X11
     
    215210    {
    216211        /* Use Xshape otherwise: */
    217         setMask(m_pEmbeddedWidget->geometry());
     212        setMask(m_pWidget->geometry());
    218213    }
    219214#endif /* VBOX_WS_X11 */
     
    231226        return;
    232227
    233     /* Recalculate mdi-sub-window geometry animation boundaries based on size-hint: */
    234     const QSize sh = m_pEmbeddedWidget->sizeHint();
     228    /* Recalculate sub-window geometry animation boundaries based on size-hint: */
     229    const QSize sh = m_pWidget->sizeHint();
    235230    switch (m_position)
    236231    {
     
    300295void UISlidingToolBar::setWidgetGeometry(const QRect &rect)
    301296{
    302     /* Apply mdi-sub-window geometry: */
    303     m_pEmbeddedWidget->setGeometry(rect);
     297    /* Apply sub-window geometry: */
     298    m_pWidget->setGeometry(rect);
    304299
    305300#ifdef VBOX_WS_X11
     
    307302    {
    308303        /* Use Xshape otherwise: */
    309         setMask(m_pEmbeddedWidget->geometry());
     304        setMask(m_pWidget->geometry());
    310305    }
    311306#endif /* VBOX_WS_X11 */
     
    314309QRect UISlidingToolBar::widgetGeometry() const
    315310{
    316     /* Return mdi-sub-window geometry: */
    317     return m_pEmbeddedWidget->geometry();
    318 }
    319 
     311    /* Return sub-window geometry: */
     312    return m_pWidget->geometry();
     313}
     314
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISlidingToolBar.h

    r62493 r66755  
    55
    66/*
    7  * Copyright (C) 2014-2016 Oracle Corporation
     7 * Copyright (C) 2014-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2323
    2424/* Forward declarations: */
    25 class QMdiArea;
    26 class QMdiSubWindow;
    2725class QHBoxLayout;
    2826class UIAnimation;
     
    9997#endif /* VBOX_WS_MAC */
    10098
    101     /** Defines mdi-sub-window geometry. */
     99    /** Defines sub-window geometry. */
    102100    void setWidgetGeometry(const QRect &rect);
    103     /** Returns mdi-sub-window geometry. */
     101    /** Returns sub-window geometry. */
    104102    QRect widgetGeometry() const;
    105     /** Returns mdi-sub-window start-geometry. */
     103    /** Returns sub-window start-geometry. */
    106104    QRect startWidgetGeometry() const { return m_startWidgetGeometry; }
    107     /** Returns mdi-sub-window final-geometry. */
     105    /** Returns sub-window final-geometry. */
    108106    QRect finalWidgetGeometry() const { return m_finalWidgetGeometry; }
    109107
     
    124122        /** Holds whether window is expanded. */
    125123        bool m_fExpanded;
    126         /** Holds mdi-sub-window start-geometry. */
     124        /** Holds sub-window start-geometry. */
    127125        QRect m_startWidgetGeometry;
    128         /** Holds mdi-sub-window final-geometry. */
     126        /** Holds sub-window final-geometry. */
    129127        QRect m_finalWidgetGeometry;
    130128    /** @} */
     
    134132        /** Holds the main-layout instance. */
    135133        QHBoxLayout *m_pMainLayout;
    136         /** Holds the mdi-area instance. */
    137         QMdiArea *m_pMdiArea;
     134        /** Holds the area instance. */
     135        QWidget *m_pArea;
    138136        /** Holds the child-widget reference. */
    139137        QWidget *m_pWidget;
    140         /** Holds the child-widget wrapper instance. */
    141         QMdiSubWindow *m_pEmbeddedWidget;
    142138    /** @} */
    143139};
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp

    r65799 r66755  
    2323# include <QApplication>
    2424# include <QTimer>
    25 # include <QMdiArea>
    26 # include <QMdiSubWindow>
    2725# include <QLabel>
    2826# include <QMenu>
     
    347345    m_spacings << widgetForAction(addWidget(new QWidget));
    348346#endif /* !VBOX_WS_X11 */
    349 
    350     /* Resize to sizehint: */
    351     resize(sizeHint());
    352347}
    353348
     
    439434    , m_fAutoHide(fAutoHide)
    440435    /* Variables: Contents stuff: */
    441     , m_pMdiArea(0)
     436    , m_pArea(0)
    442437    , m_pToolbar(0)
    443     , m_pEmbeddedToolbar(0)
    444438    /* Variables: Hover stuff: */
    445439    , m_fHovered(false)
     
    520514void UIMiniToolBar::adjustGeometry()
    521515{
    522     /* Resize embedded-toolbar to minimum size: */
    523     m_pEmbeddedToolbar->resize(m_pEmbeddedToolbar->sizeHint());
    524 
    525     /* Calculate embedded-toolbar position: */
     516    /* Resize toolbar to minimum size: */
     517    m_pToolbar->resize(m_pToolbar->sizeHint());
     518
     519    /* Calculate toolbar position: */
    526520    int iX = 0, iY = 0;
    527     iX = width() / 2 - m_pEmbeddedToolbar->width() / 2;
     521    iX = width() / 2 - m_pToolbar->width() / 2;
    528522    switch (m_alignment)
    529523    {
    530524        case Qt::AlignTop:    iY = 0; break;
    531         case Qt::AlignBottom: iY = height() - m_pEmbeddedToolbar->height(); break;
     525        case Qt::AlignBottom: iY = height() - m_pToolbar->height(); break;
    532526        default: break;
    533527    }
     
    537531    switch (m_alignment)
    538532    {
    539         case Qt::AlignTop:    m_hiddenToolbarPosition = m_shownToolbarPosition - QPoint(0, m_pEmbeddedToolbar->height() - 3); break;
    540         case Qt::AlignBottom: m_hiddenToolbarPosition = m_shownToolbarPosition + QPoint(0, m_pEmbeddedToolbar->height() - 3); break;
     533        case Qt::AlignTop:    m_hiddenToolbarPosition = m_shownToolbarPosition - QPoint(0, m_pToolbar->height() - 3); break;
     534        case Qt::AlignBottom: m_hiddenToolbarPosition = m_shownToolbarPosition + QPoint(0, m_pToolbar->height() - 3); break;
    541535    }
    542536    m_pAnimation->update();
    543537
    544     /* Update embedded-toolbar geometry if known: */
     538    /* Update toolbar geometry if known: */
    545539    if (property("AnimationState").toString() == "Final")
    546         m_pEmbeddedToolbar->move(m_shownToolbarPosition);
     540        m_pToolbar->move(m_shownToolbarPosition);
    547541    else
    548         m_pEmbeddedToolbar->move(m_hiddenToolbarPosition);
     542        m_pToolbar->move(m_hiddenToolbarPosition);
    549543
    550544#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
    551545    /* Adjust window mask: */
    552     setMask(m_pEmbeddedToolbar->geometry());
     546    setMask(m_pToolbar->geometry());
    553547#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
    554548}
     
    839833    setFocusPolicy(Qt::NoFocus);
    840834
    841     /* Prepare mdi-area: */
    842     m_pMdiArea = new QMdiArea;
    843     {
    844         /* Allow any MDI area size: */
    845         m_pMdiArea->setMinimumSize(QSize(1, 1));
     835    /* Prepare area: */
     836    m_pArea = new QWidget;
     837    {
     838        /* Allow any area size: */
     839        m_pArea->setMinimumSize(QSize(1, 1));
    846840        /* Configure own background: */
    847         QPalette pal = m_pMdiArea->palette();
     841        QPalette pal = m_pArea->palette();
    848842        pal.setColor(QPalette::Window, QColor(Qt::transparent));
    849         m_pMdiArea->setPalette(pal);
    850         /* Configure viewport background: */
    851         m_pMdiArea->setBackground(QColor(Qt::transparent));
    852         /* Layout mdi-area according parent-widget: */
     843        m_pArea->setPalette(pal);
     844        /* Layout area according parent-widget: */
    853845        QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    854846        pMainLayout->setContentsMargins(0, 0, 0, 0);
    855         pMainLayout->addWidget(m_pMdiArea);
     847        pMainLayout->addWidget(m_pArea);
    856848        /* Make sure we have no focus: */
    857         m_pMdiArea->setFocusPolicy(Qt::NoFocus);
    858         m_pMdiArea->viewport()->setFocusPolicy(Qt::NoFocus);
     849        m_pArea->setFocusPolicy(Qt::NoFocus);
    859850    }
    860851
     
    877868        connect(m_pToolbar, SIGNAL(sigExitAction()), this, SIGNAL(sigExitAction()));
    878869        connect(m_pToolbar, SIGNAL(sigCloseAction()), this, SIGNAL(sigCloseAction()));
    879         /* Add child to mdi-area: */
    880         m_pEmbeddedToolbar = m_pMdiArea->addSubWindow(m_pToolbar, Qt::Window | Qt::FramelessWindowHint);
     870        /* Add child to area: */
     871        m_pToolbar->setParent(m_pArea);
    881872        /* Make sure we have no focus: */
    882         m_pEmbeddedToolbar->setFocusPolicy(Qt::NoFocus);
     873        m_pToolbar->setFocusPolicy(Qt::NoFocus);
    883874    }
    884875
     
    922913        m_pHoverLeaveTimer->stop();
    923914
    924     /* Destroy animation before mdi-toolbar: */
     915    /* Destroy animation before toolbar: */
    925916    delete m_pAnimation;
    926917    m_pAnimation = 0;
    927918
    928     /* Destroy mdi-toolbar after animation: */
    929     delete m_pEmbeddedToolbar;
    930     m_pEmbeddedToolbar = 0;
     919    /* Destroy toolbar after animation: */
     920    delete m_pToolbar;
     921    m_pToolbar = 0;
    931922}
    932923
     
    11211112{
    11221113    /* Update position: */
    1123     AssertPtrReturnVoid(m_pEmbeddedToolbar);
    1124     m_pEmbeddedToolbar->move(point);
     1114    AssertPtrReturnVoid(m_pToolbar);
     1115    m_pToolbar->move(point);
    11251116
    11261117#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
    11271118    /* Update window mask: */
    1128     setMask(m_pEmbeddedToolbar->geometry());
     1119    setMask(m_pToolbar->geometry());
    11291120#endif /* VBOX_WS_WIN || VBOX_WS_X11 */
    11301121}
     
    11331124{
    11341125    /* Return position: */
    1135     AssertPtrReturn(m_pEmbeddedToolbar, QPoint());
    1136     return m_pEmbeddedToolbar->pos();
     1126    AssertPtrReturn(m_pToolbar, QPoint());
     1127    return m_pToolbar->pos();
    11371128}
    11381129
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.h

    r65797 r66755  
    2626class QTimer;
    2727class QLabel;
    28 class QMdiArea;
    29 class QMdiSubWindow;
    3028class UIAnimation;
    3129class UIMiniToolBarPrivate;
     
    169167    bool m_fAutoHide;
    170168
    171     /** Holds the MDI-area. */
    172     QMdiArea *m_pMdiArea;
     169    /** Holds the area. */
     170    QWidget *m_pArea;
    173171    /** Holds the internal widget. */
    174172    UIMiniToolBarPrivate *m_pToolbar;
    175     /** Holds the pointer to the wrapped
    176       * internal widget inside the MDI-area. */
    177     QMdiSubWindow *m_pEmbeddedToolbar;
    178173
    179174    /** Holds whether we are hovered. */
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