VirtualBox

Changeset 81357 in vbox


Ignore:
Timestamp:
Oct 18, 2019 2:13:59 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: UIExtraDataManager: Syncing geometry restore logic between VirtualBox Manager, Extra-data Manager, Session Information dialog and Log Viewer.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r81353 r81357  
    470470      * @{ */
    471471        /** Extra-data Manager Window constructor. */
    472         UIExtraDataManagerWindow();
     472        UIExtraDataManagerWindow(QWidget *pCenterWidget);
    473473        /** Extra-data Manager Window destructor. */
    474474        ~UIExtraDataManagerWindow();
     
    645645
    646646
     647    /** @name Arguments
     648      * @{ */
     649        /** Holds the center widget reference. */
     650        QWidget *m_pCenterWidget;
     651    /** @} */
     652
    647653    /** @name General
    648654      * @{ */
     
    706712*********************************************************************************************************************************/
    707713
    708 UIExtraDataManagerWindow::UIExtraDataManagerWindow()
    709     : m_pMainLayout(0), m_pToolBar(0), m_pSplitter(0)
     714UIExtraDataManagerWindow::UIExtraDataManagerWindow(QWidget *pCenterWidget)
     715    : m_pCenterWidget(pCenterWidget)
     716    , m_pMainLayout(0), m_pToolBar(0), m_pSplitter(0)
    710717    , m_pPaneOfChooser(0), m_pFilterOfChooser(0), m_pViewOfChooser(0)
    711718    , m_pModelSourceOfChooser(0), m_pModelProxyOfChooser(0)
     
    16831690    /* Load window geometry: */
    16841691    {
    1685         const QRect geo = gEDataManager->extraDataManagerGeometry(this);
     1692        const QRect geo = gEDataManager->extraDataManagerGeometry(this, m_pCenterWidget);
    16861693        LogRel2(("GUI: UIExtraDataManagerWindow: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",
    16871694                 geo.x(), geo.y(), geo.width(), geo.height()));
     
    41164123
    41174124    /* Use geometry (loaded or default): */
    4118     QRect geometry = fOk ? QRect(iX, iY, iW, iH) : QRect(QPoint(0, 0), availableGeometry.size() * .33 /* % */);
     4125    QRect geometry = fOk ? QRect(iX, iY, iW, iH) : QRect(QPoint(0, 0), availableGeometry.size() * .50 /* % */);
    41194126
    41204127    /* Take hint-widget into account: */
     
    44244431
    44254432#ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI
    4426 QRect UIExtraDataManager::extraDataManagerGeometry(QWidget *pWidget)
     4433QRect UIExtraDataManager::extraDataManagerGeometry(QWidget *pWidget, QWidget *pParentWidget)
    44274434{
    44284435    /* Get corresponding extra-data: */
     
    44454452    while (0);
    44464453
     4454    /* Get available-geometry [of screen with point (iX, iY) if possible]: */
     4455    const QRect availableGeometry = fOk ? gpDesktop->availableGeometry(QPoint(iX, iY)) :
     4456                                          gpDesktop->availableGeometry();
     4457
    44474458    /* Use geometry (loaded or default): */
    4448     QRect geometry = fOk ? QRect(iX, iY, iW, iH) : QRect(0, 0, 800, 600);
     4459    QRect geometry = fOk ? QRect(iX, iY, iW, iH) : QRect(QPoint(0, 0), availableGeometry.size() * .50 /* % */);
    44494460
    44504461    /* Take hint-widget into account: */
     
    44524463        geometry.setSize(geometry.size().expandedTo(pWidget->minimumSizeHint()));
    44534464
    4454     /* Get available-geometry [of screen with point (iX, iY) if possible]: */
    4455     const QRect availableGeometry = fOk ? gpDesktop->availableGeometry(QPoint(iX, iY)) :
    4456                                           gpDesktop->availableGeometry();
    4457 
     4465    /* As a fallback, move default-geometry to pParentWidget' geometry center: */
     4466    if (!fOk && pParentWidget)
     4467        geometry.moveCenter(pParentWidget->geometry().center());
    44584468    /* As final fallback, move default-geometry to available-geometry' center: */
    4459     if (!fOk)
     4469    else if (!fOk)
    44604470        geometry.moveCenter(availableGeometry.center());
    44614471
     
    45414551#endif /* VBOX_GUI_WITH_EXTRADATA_MANAGER_UI */
    45424552
    4543 QRect UIExtraDataManager::logWindowGeometry(QWidget *pWidget, const QRect &defaultGeometry)
     4553QRect UIExtraDataManager::logWindowGeometry(QWidget *pWidget, QWidget *pParentWidget, const QRect &defaultGeometry)
    45444554{
    45454555    /* Get corresponding extra-data: */
     
    45624572    while (0);
    45634573
     4574    /* Get available-geometry [of screen with point (iX, iY) if possible]: */
     4575    const QRect availableGeometry = fOk ? gpDesktop->availableGeometry(QPoint(iX, iY)) :
     4576                                          gpDesktop->availableGeometry();
     4577
    45644578    /* Use geometry (loaded or default): */
    45654579    QRect geometry = fOk ? QRect(iX, iY, iW, iH) : defaultGeometry;
     
    45694583        geometry.setSize(geometry.size().expandedTo(pWidget->minimumSizeHint()));
    45704584
     4585    /* As a fallback, move default-geometry to pParentWidget' geometry center: */
     4586    if (!fOk && pParentWidget)
     4587        geometry.moveCenter(pParentWidget->geometry().center());
     4588    /* As final fallback, move default-geometry to available-geometry' center: */
     4589    else if (!fOk)
     4590        geometry.moveCenter(availableGeometry.center());
     4591
    45714592    /* In Windows Qt fails to reposition out of screen window properly, so doing it ourselves: */
    45724593#ifdef VBOX_WS_WIN
    4573     /* Get available-geometry [of screen with point (iX, iY) if possible]: */
    4574     const QRect availableGeometry = fOk ? gpDesktop->availableGeometry(QPoint(iX, iY)) :
    4575                                           gpDesktop->availableGeometry();
    4576 
    45774594    /* Make sure resulting geometry is within current bounds: */
    45784595    if (!availableGeometry.contains(geometry))
     
    48444861    {
    48454862        /* Create window: */
    4846         m_pWindow = new UIExtraDataManagerWindow;
     4863        m_pWindow = new UIExtraDataManagerWindow(pCenterWidget);
    48474864        /* Configure window connections: */
    48484865        connect(this, &UIExtraDataManager::sigExtraDataMapAcknowledging,
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r81309 r81357  
    714714    /** @name VirtualBox: Extra-data Manager window
    715715      * @{ */
    716         /** Returns Extra-data Manager geometry using @a pWidget as hint. */
    717         QRect extraDataManagerGeometry(QWidget *pWidget);
     716        /** Returns Extra-data Manager geometry using @a pWidget and @a pParentWidget as hint. */
     717        QRect extraDataManagerGeometry(QWidget *pWidget, QWidget *pParentWidget);
    718718        /** Returns whether Extra-data Manager should be maximized or not. */
    719719        bool extraDataManagerShouldBeMaximized();
     
    730730    /** @name Virtual Machine: Log Viewer dialog
    731731      * @{ */
    732         /** Returns log-window geometry using @a pWidget and @a defaultGeometry as hints. */
    733         QRect logWindowGeometry(QWidget *pWidget, const QRect &defaultGeometry);
     732        /** Returns log-window geometry using @a pWidget, @a pParentWidget and @a defaultGeometry as hints. */
     733        QRect logWindowGeometry(QWidget *pWidget, QWidget *pParentWidget, const QRect &defaultGeometry);
    734734        /** Returns whether log-window should be maximized or not. */
    735735        bool logWindowShouldBeMaximized();
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerDialog.cpp

    r81284 r81357  
    128128    }
    129129    QRect defaultGeo(0, 0, iDefaultWidth, iDefaultHeight);
    130     if (centerWidget())
    131         defaultGeo.moveCenter(centerWidget()->geometry().center());
    132     else
    133         defaultGeo.moveCenter(availableGeo.center());
    134130
    135131    /* Load geometry from extradata: */
    136     const QRect geo = gEDataManager->logWindowGeometry(this, defaultGeo);
     132    const QRect geo = gEDataManager->logWindowGeometry(this, centerWidget(), defaultGeo);
    137133    LogRel2(("GUI: UIVMLogViewerDialog: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",
    138134             geo.x(), geo.y(), geo.width(), geo.height()));
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