mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
WebView: Accept drops with urls and open them
First dropped url is opened with current webview, the others are opened in new tabs
This commit is contained in:
parent
e39e2229ce
commit
8d312ad132
|
@ -48,6 +48,7 @@
|
||||||
#include <QWebEngineHistory>
|
#include <QWebEngineHistory>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
|
#include <QMimeData>
|
||||||
|
|
||||||
bool WebView::s_forceContextMenuOnMouseRelease = false;
|
bool WebView::s_forceContextMenuOnMouseRelease = false;
|
||||||
|
|
||||||
|
@ -67,6 +68,7 @@ WebView::WebView(QWidget* parent)
|
||||||
|
|
||||||
m_currentZoomLevel = zoomLevels().indexOf(100);
|
m_currentZoomLevel = zoomLevels().indexOf(100);
|
||||||
|
|
||||||
|
setAcceptDrops(true);
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
|
|
||||||
WebInspector::registerView(this);
|
WebInspector::registerView(this);
|
||||||
|
@ -578,6 +580,30 @@ void WebView::userDefinedOpenUrlInBgTab(const QUrl &url)
|
||||||
userDefinedOpenUrlInNewTab(actionUrl, true);
|
userDefinedOpenUrlInNewTab(actionUrl, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebView::dragEnterEvent(QDragEnterEvent *event)
|
||||||
|
{
|
||||||
|
if (event->mimeData()->hasUrls()) {
|
||||||
|
event->accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWebEngineView::dragEnterEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebView::dropEvent(QDropEvent *event)
|
||||||
|
{
|
||||||
|
if (event->mimeData()->hasUrls()) {
|
||||||
|
const QList<QUrl> &urls = event->mimeData()->urls();
|
||||||
|
load(urls.at(0));
|
||||||
|
for (int i = 1; i < urls.size(); ++i) {
|
||||||
|
openUrlInNewTab(urls.at(i), Qz::NT_CleanSelectedTab);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWebEngineView::dropEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void WebView::createContextMenu(QMenu *menu, const WebHitTestResult &hitTest)
|
void WebView::createContextMenu(QMenu *menu, const WebHitTestResult &hitTest)
|
||||||
{
|
{
|
||||||
// cppcheck-suppress variableScope
|
// cppcheck-suppress variableScope
|
||||||
|
|
|
@ -134,6 +134,8 @@ protected slots:
|
||||||
void userDefinedOpenUrlInBgTab(const QUrl &url = QUrl());
|
void userDefinedOpenUrlInBgTab(const QUrl &url = QUrl());
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
void dropEvent(QDropEvent *event);
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
|
|
||||||
|
@ -158,7 +160,6 @@ protected:
|
||||||
void checkForForm(QAction *action, const QPoint &pos);
|
void checkForForm(QAction *action, const QPoint &pos);
|
||||||
void createSearchEngine();
|
void createSearchEngine();
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addSpeedDial();
|
void addSpeedDial();
|
||||||
void configureSpeedDial();
|
void configureSpeedDial();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user