VirtualBox

Changeset 86831 in vbox


Ignore:
Timestamp:
Nov 9, 2020 8:20:42 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
141278
Message:

FE/Qt: bugref:9831. Creating find widget in a better position

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp

    r86830 r86831  
    160160    const QHelpEngine* m_pHelpEngine;
    161161    UIFindInPageWidget *m_pFindInPageWidget;
    162     /* Initilized as false and set to true once the find widget is positioned during first resize. */
    163     bool m_fFindWidgetPositioned;
     162    /* Initilized as false and set to true once the user drag moves the find widget. */
     163    bool m_fFindWidgetDragged;
    164164    const int m_iMarginForFindWidget;
    165165    /** Document positions of the cursors within the document for all matches. */
     
    625625    , m_pHelpEngine(pHelpEngine)
    626626    , m_pFindInPageWidget(new UIFindInPageWidget(this))
    627     , m_fFindWidgetPositioned(false)
     627    , m_fFindWidgetDragged(false)
    628628    , m_iMarginForFindWidget(qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin))
    629629    , m_iSelectedMatchIndex(0)
     
    673673    if (!m_pFindInPageWidget)
    674674        return;
     675    /* Try to position the widget somewhere meaningful initially: */
     676    if (!m_fFindWidgetDragged)
     677        m_pFindInPageWidget->move(width() - m_iMarginForFindWidget - m_pFindInPageWidget->width(),
     678                                  m_iMarginForFindWidget);
     679
    675680    m_pFindInPageWidget->setVisible(fVisible);
    676681
     
    709714void UIHelpBrowserViewer::resizeEvent(QResizeEvent *pEvent)
    710715{
     716    /* Make sure the widget stays inside the parent during parent resize: */
    711717    if (m_pFindInPageWidget)
    712718    {
    713         if (!m_fFindWidgetPositioned)
    714         {
    715             m_pFindInPageWidget->move(m_iMarginForFindWidget, m_iMarginForFindWidget);
    716             m_fFindWidgetPositioned = true;
    717         }
    718         else
    719             if (!isRectInside(m_pFindInPageWidget->geometry(), m_iMarginForFindWidget))
    720                 moveFindWidgetIn(m_iMarginForFindWidget);
     719        if (!isRectInside(m_pFindInPageWidget->geometry(), m_iMarginForFindWidget))
     720            moveFindWidgetIn(m_iMarginForFindWidget);
    721721    }
    722722    QIWithRetranslateUI<QTextBrowser>::resizeEvent(pEvent);
     
    831831    if (isRectInside(geo, m_iMarginForFindWidget))
    832832        m_pFindInPageWidget->move(m_pFindInPageWidget->pos() + delta);
     833    m_fFindWidgetDragged = true;
    833834    update();
    834835}
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