VirtualBox

Changeset 78005 in vbox for trunk


Ignore:
Timestamp:
Apr 3, 2019 4:43:47 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9080: Handle only events sent to required object and call to base-class afterwards, eventFilter is a virtual function first of all.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoBrowserBase.cpp

    r77519 r78005  
    100100bool UILocationSelector::eventFilter(QObject *pObj, QEvent *pEvent)
    101101{
    102     if (pObj == m_pLineEdit)
    103     {
    104         if(pEvent->type() == QEvent::MouseButtonPress)
    105         {
    106             QMouseEvent *pMouseEvent = dynamic_cast<QMouseEvent*>(pEvent);
    107             if (pMouseEvent && pMouseEvent->button() == Qt::LeftButton)
    108                 emit sigExpandCollapseTreeView();
    109         }
    110     }
    111     /* Pass the events to event system for further processing: */
    112     return false;
     102    /* Handle only events sent to m_pLineEdit only: */
     103    if (pObj != m_pLineEdit)
     104        return QIWithRetranslateUI<QWidget>::eventFilter(pObj, pEvent);
     105
     106    if (pEvent->type() == QEvent::MouseButtonPress)
     107    {
     108        QMouseEvent *pMouseEvent = dynamic_cast<QMouseEvent*>(pEvent);
     109        if (pMouseEvent && pMouseEvent->button() == Qt::LeftButton)
     110            emit sigExpandCollapseTreeView();
     111    }
     112
     113    /* Call to base-class: */
     114    return QIWithRetranslateUI<QWidget>::eventFilter(pObj, pEvent);
    113115}
    114116
     
    230232bool UIVisoBrowserBase::eventFilter(QObject *pObj, QEvent *pEvent)
    231233{
    232     if (pObj == m_pTreeView)
    233     {
    234         if(pEvent->type() == QEvent::KeyPress)
    235         {
    236             QKeyEvent *pKeyEvent = dynamic_cast<QKeyEvent*>(pEvent);
    237             if (pKeyEvent &&
    238                 (pKeyEvent->key() == Qt::Key_Return ||
    239                  pKeyEvent->key() == Qt::Key_Enter))
    240             {
    241                 updateTreeViewGeometry(false);
    242             }
    243         }
    244         else if (pEvent->type() == QEvent::FocusOut)
     234    /* Handle only events sent to m_pTreeView only: */
     235    if (pObj != m_pTreeView)
     236        return QIWithRetranslateUI<QWidget>::eventFilter(pObj, pEvent);
     237
     238    if (pEvent->type() == QEvent::KeyPress)
     239    {
     240        QKeyEvent *pKeyEvent = dynamic_cast<QKeyEvent*>(pEvent);
     241        if (pKeyEvent &&
     242            (pKeyEvent->key() == Qt::Key_Return ||
     243             pKeyEvent->key() == Qt::Key_Enter))
    245244        {
    246245            updateTreeViewGeometry(false);
    247246        }
    248247    }
    249     return false;
     248    else if (pEvent->type() == QEvent::FocusOut)
     249    {
     250        updateTreeViewGeometry(false);
     251    }
     252
     253    /* Call to base-class: */
     254    return QIWithRetranslateUI<QWidget>::eventFilter(pObj, pEvent);
    250255}
    251256
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationPanel.cpp

    r77519 r78005  
    2626#include "QIToolButton.h"
    2727#include "UIVisoConfigurationPanel.h"
     28#include "UIVisoCreator.h"
    2829
    29 UIVisoConfigurationPanel::UIVisoConfigurationPanel(QWidget *pParent /* =0 */)
     30UIVisoConfigurationPanel::UIVisoConfigurationPanel(UIVisoCreator *pCreator, QWidget *pParent /* =0 */)
    3031    : UIDialogPanel(pParent)
     32    , m_pCreator(pCreator)
    3133    , m_pVisoNameLabel(0)
    3234    , m_pCustomOptionsLabel(0)
     
    6971    if (!mainLayout())
    7072        return;
     73
     74    /* Install creator's event-filter: */
     75    m_pCreator->installEventFilter(this);
    7176
    7277    /* Name edit and and label: */
     
    111116bool UIVisoConfigurationPanel::eventFilter(QObject *pObject, QEvent *pEvent)
    112117{
     118    /* Handle only events sent to creator only: */
     119    if (pObject != m_pCreator)
     120        return UIDialogPanel::eventFilter(pObject, pEvent);
     121
    113122    switch (pEvent->type())
    114123    {
     
    116125        {
    117126            QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent);
    118 
    119              if (pKeyEvent->key() == Qt::Key_Return && m_pCustomOptionsComboBox && m_pCustomOptionsComboBox->hasFocus())
    120                  addCustomVisoOption();
     127            if (pKeyEvent->key() == Qt::Key_Return && m_pCustomOptionsComboBox && m_pCustomOptionsComboBox->hasFocus())
     128                addCustomVisoOption();
    121129            return true;
    122130            break;
     
    125133        break;
    126134    }
     135
     136    /* Call to base-class: */
    127137    return UIDialogPanel::eventFilter(pObject, pEvent);
    128138}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationPanel.h

    r77519 r78005  
    3030class QILineEdit;
    3131class QIToolButton;
     32class UIVisoCreator;
    3233
    3334class UIVisoConfigurationPanel : public UIDialogPanel
     
    4142
    4243public:
    43     UIVisoConfigurationPanel(QWidget *pParent = 0);
     44    UIVisoConfigurationPanel(UIVisoCreator *pCreator, QWidget *pParent = 0);
    4445    ~UIVisoConfigurationPanel();
    4546    virtual QString panelName() const /* override */;
     
    6465    void emitCustomVisoOptions();
    6566
     67    /** Holds the parent creator reference. */
     68    UIVisoCreator *m_pCreator;
     69
    6670    QILabel      *m_pVisoNameLabel;
    6771    QILabel      *m_pCustomOptionsLabel;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r77518 r78005  
    308308    }
    309309
    310     m_pConfigurationPanel = new UIVisoConfigurationPanel;
     310    m_pConfigurationPanel = new UIVisoConfigurationPanel(this);
    311311    if (m_pConfigurationPanel)
    312312    {
     
    315315        m_pConfigurationPanel->setVisoName(m_visoOptions.m_strVisoName);
    316316        m_pConfigurationPanel->setVisoCustomOptions(m_visoOptions.m_customOptions);
    317         installEventFilter(m_pConfigurationPanel);
    318317    }
    319318
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