Beispiel #1
0
QMimeData* StartPageModel::mimeData(const QModelIndexList &indexes) const
{
	QMimeData *mimeData(new QMimeData());
	QStringList texts;
	QList<QUrl> urls;

	if (indexes.count() == 1)
	{
		mimeData->setProperty("x-item-index", indexes.at(0));

		itemFromIndex(indexes.at(0))->setData(true, IsDraggedRole);
	}

	for (int i = 0; i < indexes.count(); ++i)
	{
		if (indexes.at(i).isValid() && static_cast<BookmarksModel::BookmarkType>(indexes.at(i).data(BookmarksModel::TypeRole).toInt()) == BookmarksModel::UrlBookmark)
		{
			texts.append(indexes.at(i).data(BookmarksModel::UrlRole).toString());
			urls.append(indexes.at(i).data(BookmarksModel::UrlRole).toUrl());
		}
	}

	mimeData->setText(texts.join(QLatin1String(", ")));
	mimeData->setUrls(urls);

	connect(mimeData, SIGNAL(destroyed()), this, SLOT(dragEnded()));

	return mimeData;
}
Beispiel #2
0
void WebPageProxy::startDragDrop(const IntPoint& imageOrigin, const IntPoint& dragPoint, uint64_t okEffect, const HashMap<UINT, Vector<String> >& dataMap, uint64_t fileSize, const String& pathname, const SharedMemory::Handle& fileContentHandle, const IntSize& dragImageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag)
{
    COMPtr<WCDataObject> dataObject;
    WCDataObject::createInstance(&dataObject, dataMap);

    if (fileSize) {
        RefPtr<SharedMemory> fileContentBuffer = SharedMemory::create(fileContentHandle, SharedMemory::ReadOnly);
        setFileDescriptorData(dataObject.get(), fileSize, pathname);
        setFileContentData(dataObject.get(), fileSize, fileContentBuffer->data());
    }

    RefPtr<SharedMemory> memoryBuffer = SharedMemory::create(dragImageHandle, SharedMemory::ReadOnly);
    if (!memoryBuffer)
        return;

    RefPtr<WebDragSource> source = WebDragSource::createInstance();
    if (!source)
        return;

    COMPtr<IDragSourceHelper> helper;
    if (FAILED(::CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER, IID_IDragSourceHelper, reinterpret_cast<LPVOID*>(&helper))))
        return;

    BitmapInfo bitmapInfo = BitmapInfo::create(dragImageSize);
    void* bits;
    OwnPtr<HBITMAP> hbmp = adoptPtr(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &bits, 0, 0));
    memcpy(bits, memoryBuffer->data(), memoryBuffer->size());

    SHDRAGIMAGE sdi;
    sdi.sizeDragImage.cx = bitmapInfo.bmiHeader.biWidth;
    sdi.sizeDragImage.cy = bitmapInfo.bmiHeader.biHeight;
    sdi.crColorKey = 0xffffffff;
    sdi.hbmpDragImage = hbmp.leakPtr();
    sdi.ptOffset.x = dragPoint.x() - imageOrigin.x();
    sdi.ptOffset.y = dragPoint.y() - imageOrigin.y();
    if (isLinkDrag)
        sdi.ptOffset.y = bitmapInfo.bmiHeader.biHeight - sdi.ptOffset.y;

    helper->InitializeFromBitmap(&sdi, dataObject.get());

    DWORD effect = DROPEFFECT_NONE;

    DragOperation operation = DragOperationNone;
    if (::DoDragDrop(dataObject.get(), source.get(), okEffect, &effect) == DRAGDROP_S_DROP) {
        if (effect & DROPEFFECT_COPY)
            operation = DragOperationCopy;
        else if (effect & DROPEFFECT_LINK)
            operation = DragOperationLink;
        else if (effect & DROPEFFECT_MOVE)
            operation = DragOperationMove;
    }
    POINT globalPoint;
    ::GetCursorPos(&globalPoint);
    POINT localPoint = globalPoint;
    ::ScreenToClient(m_pageClient->nativeWindow(), &localPoint);

    dragEnded(localPoint, globalPoint, operation);
}
void GameplayLayer::_handleActionDiceDragEnded(EventCustom* event) {
  auto data = (ActionDiceDragData*) event->getUserData();
  auto sprite = data->getSprite();
  auto dice = sprite->getDice();
  
  sprite->setLocalZOrder(sprite->getLocalZOrder() - DRAG_Z_ORDER_DELTA);
  
  OverlayUtil::removeOverlay(this);
  
  auto handler = DiceDragHandlerFactory::getHandler(dice);
  bool docked = handler->dragEnded(data, this, this->_getDockableContainer());
  
  if (!docked) {
    sprite->restoreOriginalPosition();
  }
}
Beispiel #4
0
void WWindowPrivate::init()
{
    Q_Q(WWindow);

    icon = sk->icon();

    visible = true;

    hoverItem = NULL;

    q->setAcceptHoverEvents(true);

#ifdef QT_LATEST
    q->setFlag(QQuickItem::ItemAcceptsDrops);
#endif

    //---------------------------------------------------------------------------------------------
    // View

#if defined(SK_WIN_NATIVE)
    view = new WView(q, NULL);
#elif defined(Q_OS_WIN)
    view = new WView(q, NULL, Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);
#else
    view = new WView(q, NULL, Qt::FramelessWindowHint);
#endif

#ifdef QT_4
    view->setWindowTitle(sk->name());
#else
    view->setTitle(sk->name());
#endif

    if (icon.isEmpty() == false)
    {
#ifdef QT_4
        view->setWindowIcon(QIcon(icon));
#else
        view->setIcon(QIcon(icon));
#endif
    }

    view->setVisible(true);

    //---------------------------------------------------------------------------------------------
    // Signals

    QObject::connect(view, SIGNAL(messageReceived(const QString &)),
                     q,    SIGNAL(messageReceived(const QString &)));

    QObject::connect(view, SIGNAL(stateChanged(Qt::WindowState)),
                     q,    SIGNAL(stateChanged(Qt::WindowState)));

    QObject::connect(view, SIGNAL(fadeIn ()), q, SIGNAL(fadeIn ()));
    QObject::connect(view, SIGNAL(fadeOut()), q, SIGNAL(fadeOut()));

    QObject::connect(view, SIGNAL(dragEnded()), q, SIGNAL(dragEnded()));

    QObject::connect(view, SIGNAL(beforeClose()), q, SIGNAL(beforeClose()));

    //---------------------------------------------------------------------------------------------

    QObject::connect(view, SIGNAL(itemWidthChanged ()), q, SIGNAL(itemWidthChanged ()));
    QObject::connect(view, SIGNAL(itemHeightChanged()), q, SIGNAL(itemHeightChanged()));

    QObject::connect(view, SIGNAL(xChanged()), q, SIGNAL(viewXChanged()));
    QObject::connect(view, SIGNAL(yChanged()), q, SIGNAL(viewYChanged()));

    QObject::connect(view, SIGNAL(widthChanged ()), q, SIGNAL(viewWidthChanged ()));
    QObject::connect(view, SIGNAL(heightChanged()), q, SIGNAL(viewHeightChanged()));

    QObject::connect(view, SIGNAL(centerXChanged()), q, SIGNAL(centerXChanged()));
    QObject::connect(view, SIGNAL(centerYChanged()), q, SIGNAL(centerYChanged()));

    QObject::connect(view, SIGNAL(originXChanged()), q, SIGNAL(originXChanged()));
    QObject::connect(view, SIGNAL(originYChanged()), q, SIGNAL(originYChanged()));

    QObject::connect(view, SIGNAL(ratioChanged()), q, SIGNAL(ratioChanged()));

    QObject::connect(view, SIGNAL(zoomChanged()), q, SIGNAL(zoomChanged()));

    QObject::connect(view, SIGNAL(minimumWidthChanged ()), q, SIGNAL(minimumWidthChanged ()));
    QObject::connect(view, SIGNAL(minimumHeightChanged()), q, SIGNAL(minimumHeightChanged()));

    QObject::connect(view, SIGNAL(maximumWidthChanged ()), q, SIGNAL(maximumWidthChanged ()));
    QObject::connect(view, SIGNAL(maximumHeightChanged()), q, SIGNAL(maximumHeightChanged()));

    QObject::connect(view, SIGNAL(geometryNormalChanged()), q, SIGNAL(geometryNormalChanged()));

    QObject::connect(view, SIGNAL(minimizedChanged ()), q, SIGNAL(minimizedChanged ()));
    QObject::connect(view, SIGNAL(maximizedChanged ()), q, SIGNAL(maximizedChanged ()));
    QObject::connect(view, SIGNAL(fullScreenChanged()), q, SIGNAL(fullScreenChanged()));
    QObject::connect(view, SIGNAL(lockedChanged    ()), q, SIGNAL(lockedChanged    ()));
    QObject::connect(view, SIGNAL(scalingChanged   ()), q, SIGNAL(scalingChanged   ()));

    QObject::connect(view, SIGNAL(activeChanged  ()), q, SIGNAL(activeChanged  ()));
    QObject::connect(view, SIGNAL(enteredChanged ()), q, SIGNAL(enteredChanged ()));
    QObject::connect(view, SIGNAL(draggingChanged()), q, SIGNAL(draggingChanged()));
    QObject::connect(view, SIGNAL(draggedChanged ()), q, SIGNAL(draggedChanged ()));
    QObject::connect(view, SIGNAL(resizingChanged()), q, SIGNAL(resizingChanged()));
    QObject::connect(view, SIGNAL(touchingChanged()), q, SIGNAL(touchingChanged()));

    QObject::connect(view, SIGNAL(mousePosChanged   ()), q, SIGNAL(mousePosChanged   ()));
    QObject::connect(view, SIGNAL(mouseCursorChanged()), q, SIGNAL(mouseCursorChanged()));

#ifdef QT_4
    QObject::connect(view, SIGNAL(openglChanged()), q, SIGNAL(openglChanged()));
#endif

    QObject::connect(view, SIGNAL(antialiasChanged()), q, SIGNAL(antialiasChanged()));
    QObject::connect(view, SIGNAL(vsyncChanged    ()), q, SIGNAL(vsyncChanged    ()));

    QObject::connect(view, SIGNAL(hoverEnabledChanged()), q, SIGNAL(hoverEnabledChanged()));

    QObject::connect(view, SIGNAL(fadeEnabledChanged ()), q, SIGNAL(fadeEnabledChanged ()));
    QObject::connect(view, SIGNAL(fadeDurationChanged()), q, SIGNAL(fadeDurationChanged()));

    //---------------------------------------------------------------------------------------------

    QObject::connect(view, SIGNAL(idleCheckChanged()), q, SIGNAL(idleCheckChanged()));
    QObject::connect(view, SIGNAL(idleChanged     ()), q, SIGNAL(idleChanged     ()));
    QObject::connect(view, SIGNAL(idleDelayChanged()), q, SIGNAL(idleDelayChanged()));

    //---------------------------------------------------------------------------------------------

    QObject::connect(view, SIGNAL(mousePressed(WDeclarativeMouseEvent *)),
                     q,    SIGNAL(mousePressed(WDeclarativeMouseEvent *)));

    QObject::connect(view, SIGNAL(mouseReleased(WDeclarativeMouseEvent *)),
                     q,    SIGNAL(mouseReleased(WDeclarativeMouseEvent *)));

    QObject::connect(view, SIGNAL(mouseDoubleClicked(WDeclarativeMouseEvent *)),
                     q,    SIGNAL(mouseDoubleClicked(WDeclarativeMouseEvent *)));

    QObject::connect(view, SIGNAL(keyPressed(WDeclarativeKeyEvent *)),
                     q,    SIGNAL(keyPressed(WDeclarativeKeyEvent *)));

    QObject::connect(view, SIGNAL(keyReleased(WDeclarativeKeyEvent *)),
                     q,    SIGNAL(keyReleased(WDeclarativeKeyEvent *)));

    //---------------------------------------------------------------------------------------------

    QObject::connect(view, SIGNAL(keyShiftPressedChanged()),
                     q,    SIGNAL(keyShiftPressedChanged()));

    QObject::connect(view, SIGNAL(keyControlPressedChanged()),
                     q,    SIGNAL(keyControlPressedChanged()));

    QObject::connect(view, SIGNAL(keyAltPressedChanged()),
                     q,    SIGNAL(keyAltPressedChanged()));

    //---------------------------------------------------------------------------------------------

    QObject::connect(view, SIGNAL(availableGeometryChanged()),
                     q,    SIGNAL(availableGeometryChanged()));
}
void DragController::cleanupAfterSystemDrag()
{
    dragEnded();
}