diff options
| author | Karol Kosek <krkk@krkk.ct8.pl> | 2021-04-21 09:28:37 +0200 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2021-04-21 22:07:17 +0200 |
| commit | 86959d55a041ad9bf113d0f600d8f0ad5e8220c8 (patch) | |
| tree | 2f351226eb54475414c0e2f35abe8402916896bd | |
| parent | 0e3d0b1a5e13f38828f08934c41ed263fa4c1a7d (diff) | |
BrowserTab: accept file drops
| -rw-r--r-- | lib/luis-l-gist/interactiveview.cpp | 4 | ||||
| -rw-r--r-- | src/browsertab.cpp | 13 | ||||
| -rw-r--r-- | src/browsertab.hpp | 2 |
3 files changed, 19 insertions, 0 deletions
diff --git a/lib/luis-l-gist/interactiveview.cpp b/lib/luis-l-gist/interactiveview.cpp index 8e0cf97..c6e8228 100644 --- a/lib/luis-l-gist/interactiveview.cpp +++ b/lib/luis-l-gist/interactiveview.cpp @@ -21,6 +21,10 @@ InteractiveView::InteractiveView(QWidget * parent) : panButton = Qt::MiddleButton; zoomKey = Qt::Key_Z; + + /* QGraphicsView turns it on for some reason, + * switching it back off to let BrowserTab handle it -krkk */ + setAcceptDrops(false); } qreal InteractiveView::getScale() const diff --git a/src/browsertab.cpp b/src/browsertab.cpp index b2a31a1..ef6f5e8 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -164,6 +164,7 @@ BrowserTab::BrowserTab(MainWindow *mainWindow) : QWidget(nullptr), refreshOptionalToolbarItems(); refreshToolbarIcons(); + setAcceptDrops(true); } BrowserTab::~BrowserTab() @@ -1798,6 +1799,18 @@ void BrowserTab::on_close_search_clicked() this->ui->search_bar->setVisible(false); } +void BrowserTab::dragEnterEvent(QDragEnterEvent *event) +{ + if (event->mimeData()->hasUrls()) + event->acceptProposedAction(); +} + +void BrowserTab::dropEvent(QDropEvent *event) +{ + for (const auto &url : event->mimeData()->urls()) + mainWindow->addNewTab(true, url); +} + void BrowserTab::resizeEvent(QResizeEvent *event) { this->updatePageMargins(); diff --git a/src/browsertab.hpp b/src/browsertab.hpp index 337f0f3..868e519 100644 --- a/src/browsertab.hpp +++ b/src/browsertab.hpp @@ -204,6 +204,8 @@ private: bool searchBoxFind(QString text, bool backward=false); protected: + void dragEnterEvent(QDragEnterEvent * event); + void dropEvent(QDropEvent * event); void resizeEvent(QResizeEvent * event); public: |
