VirtualBox

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


Ignore:
Timestamp:
Nov 29, 2011 10:38:55 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75091
Message:

FE/Qt4: initial DnD support

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r39337 r39451  
    111111        $(if $(VBOX_WITH_EXTPACK),VBOX_WITH_EXTPACK) \
    112112        $(if $(VBOX_WITH_EHCI),VBOX_WITH_EHCI) \
     113        $(if $(VBOX_WITH_DRAG_AND_DROP),VBOX_WITH_DRAG_AND_DROP) \
    113114        $(if $(VBOX_WITH_CRHGSMI),VBOX_WITH_CRHGSMI) \
    114115        $(if $(VBOX_WITH_VIRTIO),VBOX_WITH_VIRTIO) \
     
    558559        src/platform/darwin/UICocoaApplication.mm \
    559560        src/platform/darwin/UICocoaSpecialControls.mm \
     561        src/platform/darwin/UICocoaWindowTarget.mm \
    560562        src/platform/darwin/UIDesktopServices_darwin.cpp \
    561563        src/platform/darwin/UIDesktopServices_darwin_cocoa.mm \
     
    583585        src/VBoxFBQGL.cpp \
    584586        src/VBoxGLSupportInfo.cpp
     587endif
     588
     589ifdef VBOX_WITH_DRAG_AND_DROP
     590 VirtualBox_SOURCES += \
     591        src/runtime/UIDnDHandler.cpp
     592 VirtualBox_QT_MOCSRCS += \
     593        src/runtime/UIDnDHandler.cpp
    585594endif
    586595
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox2.qrc

    r38774 r39451  
    164164    <file alias="progress_snapshot_discard_90px.png">images/progress_snapshot_discard_90px.png</file>
    165165    <file alias="progress_clone_90px.png">images/progress_clone_90px.png</file>
     166    <file alias="progress_dnd_gh_90px.png">images/progress_dnd_gh_90px.png</file>
     167    <file alias="progress_dnd_hg_90px.png">images/progress_dnd_hg_90px.png</file>
    166168    <file alias="status_check_16px.png">images/status_check_16px.png</file>
    167169    <file alias="status_check_32px.png">images/status_check_32px.png</file>
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r39326 r39451  
    28802880}
    28812881
     2882#ifdef VBOX_WITH_DRAG_AND_DROP
     2883void UIMessageCenter::cannotDropData(const CGuest &guest,
     2884                                     QWidget *pParent /* = 0 */) const
     2885{
     2886    message(pParent ? pParent : mainWindowShown(),
     2887            Error,
     2888            tr("Failed to drop data."),
     2889            formatErrorInfo(guest));
     2890}
     2891
     2892void UIMessageCenter::cannotDropData(const CProgress &progress,
     2893                                     QWidget *pParent /* = 0 */) const
     2894{
     2895    AssertWrapperOk(progress);
     2896
     2897    message(pParent ? pParent : mainWindowShown(),
     2898            Error,
     2899            tr("Failed to drop data."),
     2900            formatErrorInfo(progress.GetErrorInfo()));
     2901}
     2902#endif /* VBOX_WITH_DRAG_AND_DROP */
     2903
    28822904void UIMessageCenter::remindAboutWrongColorDepth(ulong uRealBPP, ulong uWantedBPP)
    28832905{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r39326 r39451  
    426426    void cannotRemoveSharedFolder(const CConsole &console, const QString &strName,
    427427                                  const QString &strPath, QWidget *pParent = 0);
     428#ifdef VBOX_WITH_DRAG_AND_DROP
     429    void cannotDropData(const CGuest &guest, QWidget *pParent = 0) const;
     430    void cannotDropData(const CProgress &progress, QWidget *pParent = 0) const;
     431#endif /* VBOX_WITH_DRAG_AND_DROP */
    428432    void remindAboutWrongColorDepth(ulong uRealBPP, ulong uWantedBPP);
    429433    void remindAboutUnsupportedUSB2(const QString &strExtPackName, QWidget *pParent = 0);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r39073 r39451  
    177177    ulong height() { return m_height; }
    178178
     179    inline int convertGuestXTo(int x) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.width() / m_width * x) : x; }
     180    inline int convertGuestYTo(int y) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.height() / m_height * y) : y; }
     181    inline int convertHostXTo(int x) const  { return m_scaledSize.isValid() ? qRound((double)m_width / m_scaledSize.width() * x) : x; }
     182    inline int convertHostYTo(int y) const  { return m_scaledSize.isValid() ? qRound((double)m_height / m_scaledSize.height() * y) : y; }
     183
    179184    virtual QSize scaledSize() const { return m_scaledSize; }
    180185    virtual void setScaledSize(const QSize &size = QSize()) { m_scaledSize = size; }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r39156 r39451  
    2424#include <QPainter>
    2525#include <QScrollBar>
     26#include <QMainWindow>
    2627#include <VBox/VBoxVideo.h>
    2728#include <iprt/asm.h>
     
    4546#include "UIMachineViewSeamless.h"
    4647#include "UIMachineViewScale.h"
     48
     49#ifdef VBOX_WITH_DRAG_AND_DROP
     50# include "UIDnDHandler.h"
     51#endif
    4752
    4853#ifdef Q_WS_X11
     
    460465    /* Setup focus policy: */
    461466    setFocusPolicy(Qt::WheelFocus);
     467
     468#ifdef VBOX_WITH_DRAG_AND_DROP
     469    /* Enable Drag & Drop. */
     470    setAcceptDrops(true);
     471#endif /* VBOX_WITH_DRAG_AND_DROP */
    462472}
    463473
     
    10921102}
    10931103
     1104#ifdef VBOX_WITH_DRAG_AND_DROP
     1105
     1106void UIMachineView::dragEnterEvent(QDragEnterEvent *pEvent)
     1107{
     1108    /* The guest object to talk to. */
     1109    CGuest guest = session().GetConsole().GetGuest();
     1110
     1111    /* Get mouse-pointer location */
     1112    const QPoint &cpnt = viewportToContents(pEvent->pos());
     1113
     1114    /* Ask the guest for starting a DnD event. */
     1115    Qt::DropAction result = gDnD->dragHGEnter(guest,
     1116                                              screenId(),
     1117                                              frameBuffer()->convertHostXTo(cpnt.x()),
     1118                                              frameBuffer()->convertHostYTo(cpnt.y()),
     1119                                              pEvent->proposedAction(),
     1120                                              pEvent->possibleActions(),
     1121                                              pEvent->mimeData(), this);
     1122
     1123    /* Set the DnD action returned by the guest. */
     1124    pEvent->setDropAction(result);
     1125    pEvent->accept();
     1126}
     1127
     1128void UIMachineView::dragMoveEvent(QDragMoveEvent *pEvent)
     1129{
     1130    /* The guest object to talk to. */
     1131    CGuest guest = session().GetConsole().GetGuest();
     1132
     1133    /* Get mouse-pointer location */
     1134    const QPoint &cpnt = viewportToContents(pEvent->pos());
     1135
     1136    /* Ask the guest for moving the drop cursor. */
     1137    Qt::DropAction result = gDnD->dragHGMove(guest,
     1138                                             screenId(),
     1139                                             frameBuffer()->convertHostXTo(cpnt.x()),
     1140                                             frameBuffer()->convertHostYTo(cpnt.y()),
     1141                                             pEvent->proposedAction(),
     1142                                             pEvent->possibleActions(),
     1143                                             pEvent->mimeData(), this);
     1144
     1145    /* Set the DnD action returned by the guest. */
     1146    pEvent->setDropAction(result);
     1147    pEvent->accept();
     1148}
     1149
     1150void UIMachineView::dragLeaveEvent(QDragLeaveEvent *pEvent)
     1151{
     1152    /* The guest object to talk to. */
     1153    CGuest guest = session().GetConsole().GetGuest();
     1154
     1155    /* Ask the guest for stopping this DnD event. */
     1156    gDnD->dragHGLeave(guest, screenId(), this);
     1157    pEvent->accept();
     1158}
     1159
     1160void UIMachineView::dropEvent(QDropEvent *pEvent)
     1161{
     1162    /* The guest object to talk to. */
     1163    CGuest guest = session().GetConsole().GetGuest();
     1164
     1165    /* Get mouse-pointer location */
     1166    const QPoint &cpnt = viewportToContents(pEvent->pos());
     1167
     1168    /* Ask the guest for dropping data. */
     1169    Qt::DropAction result = gDnD->dragHGDrop(guest,
     1170                                             screenId(),
     1171                                             frameBuffer()->convertHostXTo(cpnt.x()),
     1172                                             frameBuffer()->convertHostYTo(cpnt.y()),
     1173                                             pEvent->proposedAction(),
     1174                                             pEvent->possibleActions(),
     1175                                             pEvent->mimeData(), this);
     1176
     1177    /* Set the DnD action returned by the guest. */
     1178    pEvent->setDropAction(result);
     1179    pEvent->accept();
     1180}
     1181
     1182void UIMachineView::handleGHDnd()
     1183{
     1184    /* The guest object to talk to. */
     1185    CGuest guest = session().GetConsole().GetGuest();
     1186
     1187    /* Check for a pending DnD event within the guest and if so, handle all the
     1188     * magic. */
     1189    gDnD->dragGHPending(session(), screenId(), this);
     1190}
     1191
     1192#endif /* VBOX_WITH_DRAG_AND_DROP */
     1193
    10941194#if defined(Q_WS_WIN)
    10951195
     
    11511251
    11521252#endif
     1253
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r39110 r39451  
    192192    void paintEvent(QPaintEvent *pEvent);
    193193
     194#ifdef VBOX_WITH_DRAG_AND_DROP
     195    void dragEnterEvent(QDragEnterEvent *pEvent);
     196    void dragLeaveEvent(QDragLeaveEvent *pEvent);
     197    void dragMoveEvent(QDragMoveEvent *pEvent);
     198    void dropEvent(QDropEvent *pEvent);
     199
     200    void handleGHDnd();
     201#endif /* VBOX_WITH_DRAG_AND_DROP */
     202
    194203    /* Platform specific event processors: */
    195204#if defined(Q_WS_WIN)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r38798 r39451  
    816816            cpnt.setY((int)(cpnt.y() * yRatio));
    817817
     818            if (   cpnt.x() < 0
     819                || cpnt.x() > iCw - 1
     820                || cpnt.y() < 0
     821                || cpnt.y() > iCh - 1)
     822            {
     823                if ((mouseButtons.testFlag(Qt::LeftButton)))
     824                {
     825                    m_views[uScreenId]->handleGHDnd();
     826
     827                    return false;
     828                }
     829            }
     830
    818831            /* Bound coordinates: */
    819832            if (cpnt.x() < 0) cpnt.setX(0);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette