VirtualBox

Ignore:
Timestamp:
May 10, 2016 3:16:04 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: ​​​​​​​​​​bugref:6769: Rework/cleanup file-path selector widget (part 13): Allow to override widget's tool-tip.

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

Legend:

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

    r60922 r60928  
    2828# include <QHBoxLayout>
    2929# include <QLineEdit>
    30 # include <QTimer>
    3130
    3231/* GUI includes: */
     
    6766    , m_fEditableMode(false)
    6867    , m_fMouseAwaited(false)
     68    , m_fToolTipOverriden(false)
    6969    , m_pCopyAction(new QAction(this))
    7070{
     
    145145}
    146146
     147void UIFilePathSelector::setToolTip(const QString &strToolTip)
     148{
     149    /* Call to base-class: */
     150    QComboBox::setToolTip(strToolTip);
     151
     152    /* Remember if the tool-tip overriden: */
     153    m_fToolTipOverriden = !toolTip().isEmpty();
     154}
     155
    147156void UIFilePathSelector::setPath(const QString &strPath, bool fRefreshText /* = true */)
    148157{
     
    156165{
    157166    if (m_fMouseAwaited && (pEvent->type() == QEvent::MouseButtonPress))
    158         QTimer::singleShot(0, this, SLOT(refreshText()));
     167        QMetaObject::invokeMethod(this, "refreshText", Qt::QueuedConnection);
    159168
    160169    return QIWithRetranslateUI<QComboBox>::eventFilter(pObject, pEvent);
     
    464473
    465474        /* Set the tool-tip: */
    466         setToolTip(m_strNoneToolTipFocused);
     475        if (!m_fToolTipOverriden)
     476            QComboBox::setToolTip(m_strNoneToolTipFocused);
    467477        setItemData(PathId, toolTip(), Qt::ToolTipRole);
    468478
     
    493503
    494504            /* Set the tool-tip: */
    495             setToolTip(m_strNoneToolTip);
     505            if (!m_fToolTipOverriden)
     506                QComboBox::setToolTip(m_strNoneToolTip);
    496507            setItemData(PathId, toolTip(), Qt::ToolTipRole);
    497508        }
     
    512523
    513524        /* Set the tool-tip: */
    514         setToolTip(fullPath());
     525        if (!m_fToolTipOverriden)
     526            QComboBox::setToolTip(fullPath());
    515527        setItemData(PathId, toolTip(), Qt::ToolTipRole);
    516528    }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilePathSelector.h

    r60922 r60928  
    105105    QString path() const { return m_strPath; }
    106106
     107    /** Sets overriden widget's @a strToolTip.
     108      * @note If nothing set it's generated automatically. */
     109    void setToolTip(const QString &strToolTip);
     110
    107111public slots:
    108112
     
    192196    bool     m_fMouseAwaited;
    193197
     198    /** Holds whether the tool-tip overriden. */
     199    bool     m_fToolTipOverriden;
     200
    194201    /** Holds the copy action instance. */
    195202    QAction *m_pCopyAction;
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