VirtualBox

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


Ignore:
Timestamp:
Jul 8, 2015 1:58:33 PM (10 years ago)
Author:
vboxsync
Message:

DnD: FE/Qt: UIDnDMIMEData: Try to fix the drop target handling on OS X.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp

    r56555 r56865  
    4545    , m_enmState(Dragging)
    4646    , m_vaData(QVariant::Invalid)
     47#ifdef RT_OS_DARWIN
     48    , m_fCanDrop(false)
     49#endif
    4750{
    4851    LogFlowThisFuncEnter();
    4952
    5053#ifdef DEBUG
    51     LogFlowFunc(("Number of formats: %d\n", lstFormats.size()));
    52     for (int i = 0; i < lstFormats.size(); i++)
    53         LogFlowFunc(("\tFormat %d: %s\n", i, lstFormats.at(i).toAscii().constData()));
     54    LogFlowFunc(("Number of formats: %d\n", m_lstFormats.size()));
     55    for (int i = 0; i < m_lstFormats.size(); i++)
     56        LogFlowFunc(("\tFormat %d: %s\n", i, m_lstFormats.at(i).toAscii().constData()));
     57#endif
     58
     59#ifdef RT_OS_DARWIN
     60    connect(this, SIGNAL(notifyDropped()), this, SLOT(sltDropped()));
    5461#endif
    5562}
     
    5764QStringList UIDnDMIMEData::formats(void) const
    5865{
     66    LogFlowFuncEnter();
    5967    return m_lstFormats;
    6068}
     
    6270bool UIDnDMIMEData::hasFormat(const QString &strMIMEType) const
    6371{
    64     bool fRc = (m_curAction != Qt::IgnoreAction);
     72    bool fRc = false;
     73
     74#ifdef RT_OS_DARWIN
     75    if (strMIMEType.compare("application/x-qt-mime-type-name", Qt::CaseInsensitive) == 0)
     76        fRc = true;
     77#endif
     78
     79    if (!fRc)
     80        fRc = m_curAction != Qt::IgnoreAction;
     81
    6582    LogFlowFunc(("%s: %RTbool (QtMimeData: %RTbool, curAction=0x%x)\n",
    6683                 strMIMEType.toStdString().c_str(), fRc, QMimeData::hasFormat(strMIMEType), m_curAction));
     84
     85#ifdef RT_OS_DARWIN
     86    /*
     87     * On OS X hasFormat() only seems to get called on a successful
     88     * drop, that is, if the host knows (and the user accepts) the drop operation.
     89     * 
     90     * As we can't do here much since this is a const'ed function we're emitting a
     91     * signal to ourselves in order to let us know that we can start receiving data
     92     * from the guest within the next retrieveData() call.
     93     */
     94    emit notifyDropped();
     95#endif
     96
    6797    return fRc;
    6898}
     99
     100#ifdef RT_OS_DARWIN
     101void UIDnDMIMEData::sltDropped(void)
     102{
     103    LogFlowFuncEnter();
     104    m_fCanDrop = true;
     105}
     106#endif
    69107
    70108/**
     
    82120                 m_enmState, m_curAction, m_defAction, strMIMEType.toStdString().c_str(), vaType, QVariant::typeToName(vaType)));
    83121
    84     bool fCanDrop = true;
     122    bool fCanDrop = true; /* Accept by default. */
    85123
    86124#ifdef RT_OS_WINDOWS
    87     /* On Windows this function will be called several times by Qt's
     125    /*
     126     * On Windows this function will be called several times by Qt's
    88127     * OLE-specific internals to figure out which data formats we have
    89      * to offer. So just assume we can drop data here for a start.* */
    90     fCanDrop = true;
     128     * to offer. So just assume we can drop data here for a start.
     129     */
     130#elif defined(RT_OS_DARWIN)
     131    /*
     132     * On OS X we rely on an internal flag which gets set in the overriden
     133     * hasFormat() function. That function only gets called on a successful drop
     134     * so that we can tell if we have to start receiving data the next time
     135     * we come by here.
     136     */
     137    fCanDrop = m_fCanDrop;
    91138#else
    92     /* On non-Windows our state gets updated via an own event filter
     139    /*
     140     * On non-Windows our state gets updated via an own event filter
    93141     * (see UIDnDMimeData::eventFilter). This filter will update the current
    94      * operation state for us (based on the mouse buttons). */
     142     * operation state for us (based on the mouse buttons).
     143     */
    95144    if (m_curAction == Qt::IgnoreAction)
    96145    {
     
    139188    }
    140189
     190#ifdef RT_OS_DARWIN
     191    LogFlowFunc(("Returning data for Cocoa\n"));
     192    return QMimeData::retrieveData(strMIMEType, vaType);
     193#else
    141194    LogFlowFunc(("Skipping request, state=%RU32 ...\n", m_enmState));
    142195    return QVariant(QVariant::Invalid); /* Return a NULL variant. */
     196#endif
    143197}
    144198
     
    204258    m_curAction = dropAction;
    205259}
    206 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h

    r56555 r56865  
    6767     int getData(const QString &strMIMEType, QVariant::Type vaType, QVariant &vaData) const;
    6868
     69#ifdef RT_OS_DARWIN
     70     void notifyDropped(void) const;
     71#endif
     72
    6973public slots:
    7074
     75    /**
     76     * Slot indicating that the current drop target has been changed.
     77     * @note Does not work on OS X.
     78     */
    7179    void sltDropActionChanged(Qt::DropAction dropAction);
     80
     81#ifdef RT_OS_DARWIN
     82    /**
     83     * Slot indicating that the host wants us to drop the
     84     * data from the guest to the host.
     85     */
     86    void sltDropped(void);
     87#endif
    7288
    7389protected:
     
    111127    mutable State     m_enmState;
    112128    mutable QVariant  m_vaData;
     129
     130#ifdef RT_OS_DARWIN
     131    /** Flag indicating whether we can drop data from the
     132     *  guest to the host or not. */
     133    bool              m_fCanDrop;
     134#endif
    113135};
    114136
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