VirtualBox

Changeset 52056 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 16, 2014 5:09:15 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 3646: Status-bar Editor: Mac OS X host support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r52053 r52056  
    239239        return QWidget::mouseMoveEvent(pEvent);
    240240
     241    /* Revoke hovered state: */
     242    m_fHovered = false;
     243    /* Update: */
     244    update();
     245
    241246    /* Initialize dragging: */
    242247    m_mousePressPosition = QPoint();
     
    285290    void sltParentGeometryChanged(const QRect &rect);
    286291
     292    /** Handles 3D overlay visibility change. */
     293    void sltHandle3DOverlayVisibilityChange();
     294
    287295    /** Handles configuration change. */
    288296    void sltHandleConfigurationChange();
     
    304312    /** Prepare animation routine. */
    305313    void prepareAnimation();
     314    /** Prepare geometry. */
     315    void prepareGeometry();
    306316
    307317    /** Updates status buttons. */
     
    412422}
    413423
     424void UIStatusBarEditorWindow::sltHandle3DOverlayVisibilityChange()
     425{
     426    /* Reactivate window when 3D overlay covered us: */
     427    activateWindow();
     428}
     429
    414430void UIStatusBarEditorWindow::sltHandleConfigurationChange()
    415431{
     
    457473    /* Delete window when closed: */
    458474    setAttribute(Qt::WA_DeleteOnClose);
    459     /* Make window background translucent: */
     475    /* Make sure we have no background
     476     * until the first one paint-event: */
     477    setAttribute(Qt::WA_NoSystemBackground);
     478#if defined(Q_WS_MAC)
     479    /* Using native API to enable translucent background for the Mac host.
     480     * - We also want to disable window-shadows which is possible
     481     *   using Qt::WA_MacNoShadow only since Qt 4.8,
     482     *   while minimum supported version is 4.7.1 for now: */
     483    ::darwinSetShowsWindowTransparent(this, true);
     484#elif defined(Q_WS_WIN)
     485    /* Using Qt API to enable translucent background:
     486     * - Under Win host Qt conflicts with 3D stuff (black seamless regions).
     487     * - Under Mac host Qt doesn't allows to disable window-shadows
     488     *   until version 4.8, but minimum supported version is 4.7.1 for now.
     489     * - Under x11 host Qt has it broken with KDE 4.9 (black background): */
    460490    setAttribute(Qt::WA_TranslucentBackground);
     491#endif /* Q_WS_WIN */
    461492    /* Track D&D events: */
    462493    setAcceptDrops(true);
     
    467498    {
    468499        /* Configure main-layout: */
     500#if defined(Q_WS_WIN)
     501        /* Standard margins on Windows: */
    469502        int iLeft, iTop, iRight, iBottom;
    470503        m_pMainLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
     
    472505            iBottom -= 5;
    473506        m_pMainLayout->setContentsMargins(iLeft, iTop, iRight, iBottom);
     507#elif defined(Q_WS_MAC)
     508        /* Standard margins on Mac OS X are too big: */
     509        m_pMainLayout->setContentsMargins(10, 10, 10, 5);
     510#endif /* Q_WS_MAC */
    474511        m_pMainLayout->setSpacing(0);
    475512        /* Create close-button: */
     
    478515        {
    479516            /* Configure close-button: */
     517            m_pButtonClose->setFocusPolicy(Qt::StrongFocus);
    480518            m_pButtonClose->setMinimumSize(QSize(1, 1));
    481519            m_pButtonClose->setShortcut(Qt::Key_Escape);
     
    506544    /* Prepare animation: */
    507545    prepareAnimation();
     546    /* Prepare geometry: */
     547    prepareGeometry();
    508548
    509549    /* Activate window: */
     
    558598    /* Update animation: */
    559599    updateAnimation();
     600}
     601
     602void UIStatusBarEditorWindow::prepareGeometry()
     603{
     604    /* Prepare geometry based on minimum size-hint: */
     605    const QSize msh = minimumSizeHint();
     606    setGeometry(m_rect.x(), m_rect.y() + m_rect.height() - m_statusBarRect.height() - msh.height(),
     607                qMax(m_rect.width(), msh.width()), msh.height());
     608#ifdef Q_WS_WIN
     609    raise();
     610#endif /* Q_WS_WIN */
    560611}
    561612
     
    608659    setGeometry(m_rect.x(), m_rect.y() + m_rect.height() - m_statusBarRect.height() - sh.height(),
    609660                qMax(m_rect.width(), sh.width()), sh.height());
     661#ifdef Q_WS_WIN
    610662    raise();
     663#endif /* Q_WS_WIN */
    611664}
    612665
     
    660713    color1.setAlpha(0);
    661714    QColor color2 = pal.color(QPalette::Window).darker(200);
     715#ifdef Q_WS_WIN
    662716    QColor color3 = pal.color(QPalette::Window).darker(120);
     717#endif /* Q_WS_WIN */
    663718
    664719    /* Left corner: */
     
    700755    painter.fillRect(QRect(0, 5, 5, height() - 5), grad4);
    701756    painter.fillRect(QRect(width() - 5, 5, 5, height() - 5), grad5);
     757#ifdef Q_WS_WIN
    702758    painter.save();
    703759    painter.setPen(color3);
     
    707763    painter.drawLine(QLine(QPoint(5 + 1, height() - 1),               QPoint(5 + 1, 5 + 1)));
    708764    painter.restore();
     765#endif /* Q_WS_WIN */
    709766
    710767    /* Paint drop token: */
     
    927984        connect(this, SIGNAL(sigGeometryChange(const QRect&)),
    928985                pStatusBarEditor, SLOT(sltParentGeometryChanged(const QRect&)));
     986        connect(machineLogic(), SIGNAL(sigNotifyAbout3DOverlayVisibilityChange(bool)),
     987                pStatusBarEditor, SLOT(sltHandle3DOverlayVisibilityChange()));
    929988        connect(pStatusBarEditor, SIGNAL(destroyed(QObject*)),
    930989                this, SLOT(sltStatusBarEditorWindowClosed()));
     
    10181077    AssertPtrReturnVoid(statusBar());
    10191078    {
    1020 #ifdef Q_WS_WIN
     1079#if defined(Q_WS_WIN) || defined (Q_WS_MAC)
    10211080        /* Configure status-bar: */
    10221081        statusBar()->setContextMenuPolicy(Qt::CustomContextMenu);
    10231082        connect(statusBar(), SIGNAL(customContextMenuRequested(const QPoint&)),
    10241083                this, SLOT(sltShowStatusBarContextMenu(const QPoint&)));
    1025 #endif /* Q_WS_WIN */
     1084#endif /* Q_WS_WIN || Q_WS_MAC */
    10261085        /* Create indicator-pool: */
    10271086        m_pIndicatorsPool = new UIIndicatorsPool(machineLogic()->uisession());
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