VirtualBox

Changeset 47041 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jul 8, 2013 1:59:23 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Popup-center: Popup-stack layout now takes into account *parent-window* menu-bar and status-bar if necessary.

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

Legend:

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

    r47028 r47041  
    2121#include <QEvent>
    2222#include <QMainWindow>
     23#include <QMenuBar>
    2324#include <QStatusBar>
    2425
     
    3435    : m_iLayoutMargin(1)
    3536    , m_iLayoutSpacing(1)
     37    , m_iParentMenuBarHeight(0)
    3638    , m_iParentStatusBarHeight(0)
    3739{
     
    115117    /* Call to base-class: */
    116118    QWidget::setParent(pParent);
     119    /* Recalculate parent menu-bar height: */
     120    m_iParentMenuBarHeight = parentMenuBarHeight(pParent);
    117121    /* Recalculate parent status-bar height: */
    118122    m_iParentStatusBarHeight = parentStatusBarHeight(pParent);
     
    123127    /* Call to base-class: */
    124128    QWidget::setParent(pParent, flags);
     129    /* Recalculate parent menu-bar height: */
     130    m_iParentMenuBarHeight = parentMenuBarHeight(pParent);
    125131    /* Recalculate parent status-bar height: */
    126132    m_iParentStatusBarHeight = parentStatusBarHeight(pParent);
     
    139145    bool fIsWindow = isWindow();
    140146    const int iX = fIsWindow ? parentWidget()->x() : 0;
    141     const int iY = fIsWindow ? parentWidget()->y() : 0;
     147    const int iY = fIsWindow ? parentWidget()->y() : m_iParentMenuBarHeight;
    142148    const int iWidth = parentWidget()->width();
    143149    const int iHeight = m_minimumSizeHint.height();
     
    282288
    283289/* static */
     290int UIPopupStack::parentMenuBarHeight(QWidget *pParent)
     291{
     292    /* Menu-bar can exist only on QMainWindow sub-class: */
     293    if (QMainWindow *pMainWindow = qobject_cast<QMainWindow*>(pParent))
     294    {
     295        /* Search for existing menu-bar child: */
     296        if (QMenuBar *pMenuBar = pMainWindow->findChild<QMenuBar*>())
     297            return pMenuBar->height();
     298    }
     299    /* Zero by default: */
     300    return 0;
     301}
     302
     303/* static */
    284304int UIPopupStack::parentStatusBarHeight(QWidget *pParent)
    285305{
     
    287307    if (QMainWindow *pMainWindow = qobject_cast<QMainWindow*>(pParent))
    288308    {
    289         /* Status-bar can exist only:
    290          * 1. on non-machine-window
    291          * 2. on machine-window in normal mode: */
    292         if (!qobject_cast<UIMachineWindow*>(pMainWindow) ||
    293             qobject_cast<UIMachineWindowNormal*>(pMainWindow))
    294             return pMainWindow->statusBar()->height();
     309        /* Search for existing status-bar child: */
     310        if (QStatusBar *pStatusBar = pMainWindow->findChild<QStatusBar*>())
     311            return pStatusBar->height();
    295312    }
    296313    /* Zero by default: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h

    r47014 r47041  
    8181
    8282    /* Static helpers: Prepare stuff: */
     83    static int parentMenuBarHeight(QWidget *pParent);
    8384    static int parentStatusBarHeight(QWidget *pParent);
    8485
     
    8788    const int m_iLayoutSpacing;
    8889    QSize m_minimumSizeHint;
     90    int m_iParentMenuBarHeight;
    8991    int m_iParentStatusBarHeight;
    9092    QMap<QString, UIPopupPane*> m_panes;
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