Commit 8681257e authored by Andrea Diamantini's avatar Andrea Diamantini
Browse files

Implement/fix drag and drop handling of text & url in the webview

BUG:254102
parent af59cbe2
......@@ -472,6 +472,7 @@ void WebView::enterEvent(QEvent *event)
void WebView::dropEvent(QDropEvent *event)
{
bool isEditable = page()->frameAt(event->pos())->hitTestContent(event->pos()).isContentEditable();
if (event->mimeData()->hasFormat("application/rekonq-bookmark"))
{
QByteArray addresses = event->mimeData()->data("application/rekonq-bookmark");
......@@ -485,6 +486,20 @@ void WebView::dropEvent(QDropEvent *event)
emit loadUrl(bookmark.url(), Rekonq::CurrentTab);
}
}
else if (event->mimeData()->hasUrls() && event->source() != this && !isEditable) //dropped links
{
Q_FOREACH (const QUrl &url, event->mimeData()->urls())
{
emit loadUrl(url, Rekonq::NewFocusedTab);
}
}
else if (event->mimeData()->hasFormat("text/plain") && event->source() != this && !isEditable) //dropped plain text with url format
{
QUrl url = QUrl::fromUserInput(event->mimeData()->data("text/plain"));
if (url.isValid())
emit loadUrl(url, Rekonq::NewFocusedTab);
}
else
{
KWebView::dropEvent(event);
......@@ -800,3 +815,21 @@ void WebView::stopScrolling()
m_dy = 0;
m_smoothScrolling = false;
}
void WebView::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls() || event->mimeData()->hasText())
event->acceptProposedAction();
else
KWebView::dragEnterEvent(event);
}
void WebView::dragMoveEvent(QDragMoveEvent *event)
{
if (event->mimeData()->hasUrls() || event->mimeData()->hasText())
event->acceptProposedAction();
else
KWebView::dragMoveEvent(event);
}
......@@ -65,6 +65,8 @@ protected:
void keyPressEvent(QKeyEvent *event);
void wheelEvent(QWheelEvent *event);
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent * event);
private Q_SLOTS:
void search();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment