mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +00:00
Ladybird: Accept file drops
This commit is contained in:
parent
731fec525e
commit
f3c6510b83
3 changed files with 26 additions and 0 deletions
|
@ -349,6 +349,14 @@ void BrowserWindow::new_tab(QString const& url, Activate activate)
|
||||||
QObject::connect(tab_ptr, &Tab::title_changed, this, &BrowserWindow::tab_title_changed);
|
QObject::connect(tab_ptr, &Tab::title_changed, this, &BrowserWindow::tab_title_changed);
|
||||||
QObject::connect(tab_ptr, &Tab::favicon_changed, this, &BrowserWindow::tab_favicon_changed);
|
QObject::connect(tab_ptr, &Tab::favicon_changed, this, &BrowserWindow::tab_favicon_changed);
|
||||||
|
|
||||||
|
QObject::connect(&tab_ptr->view(), &WebContentView::urls_dropped, this, [this](auto& urls) {
|
||||||
|
VERIFY(urls.size());
|
||||||
|
m_current_tab->navigate(urls[0].toString());
|
||||||
|
|
||||||
|
for (qsizetype i = 1; i < urls.size(); ++i)
|
||||||
|
new_tab(urls[i].toString(), Activate::No);
|
||||||
|
});
|
||||||
|
|
||||||
tab_ptr->view().on_get_all_cookies = [this](auto const& url) {
|
tab_ptr->view().on_get_all_cookies = [this](auto const& url) {
|
||||||
return m_cookie_jar.get_all_cookies(url);
|
return m_cookie_jar.get_all_cookies(url);
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QMimeData>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -58,6 +59,7 @@ WebContentView::WebContentView(StringView webdriver_content_ipc_path)
|
||||||
: m_webdriver_content_ipc_path(webdriver_content_ipc_path)
|
: m_webdriver_content_ipc_path(webdriver_content_ipc_path)
|
||||||
{
|
{
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
setAcceptDrops(true);
|
||||||
|
|
||||||
setFocusPolicy(Qt::FocusPolicy::StrongFocus);
|
setFocusPolicy(Qt::FocusPolicy::StrongFocus);
|
||||||
|
|
||||||
|
@ -312,6 +314,19 @@ void WebContentView::mouseReleaseEvent(QMouseEvent* event)
|
||||||
client().async_mouse_up(to_content(position), button, buttons, modifiers);
|
client().async_mouse_up(to_content(position), button, buttons, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebContentView::dragEnterEvent(QDragEnterEvent* event)
|
||||||
|
{
|
||||||
|
if (event->mimeData()->hasUrls())
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebContentView::dropEvent(QDropEvent* event)
|
||||||
|
{
|
||||||
|
VERIFY(event->mimeData()->hasUrls());
|
||||||
|
emit urls_dropped(event->mimeData()->urls());
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
|
||||||
void WebContentView::keyPressEvent(QKeyEvent* event)
|
void WebContentView::keyPressEvent(QKeyEvent* event)
|
||||||
{
|
{
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
|
|
|
@ -78,6 +78,8 @@ public:
|
||||||
virtual void mouseMoveEvent(QMouseEvent*) override;
|
virtual void mouseMoveEvent(QMouseEvent*) override;
|
||||||
virtual void mousePressEvent(QMouseEvent*) override;
|
virtual void mousePressEvent(QMouseEvent*) override;
|
||||||
virtual void mouseReleaseEvent(QMouseEvent*) override;
|
virtual void mouseReleaseEvent(QMouseEvent*) override;
|
||||||
|
virtual void dragEnterEvent(QDragEnterEvent*) override;
|
||||||
|
virtual void dropEvent(QDropEvent*) override;
|
||||||
virtual void keyPressEvent(QKeyEvent* event) override;
|
virtual void keyPressEvent(QKeyEvent* event) override;
|
||||||
virtual void keyReleaseEvent(QKeyEvent* event) override;
|
virtual void keyReleaseEvent(QKeyEvent* event) override;
|
||||||
virtual void showEvent(QShowEvent*) override;
|
virtual void showEvent(QShowEvent*) override;
|
||||||
|
@ -159,6 +161,7 @@ signals:
|
||||||
void navigate_forward();
|
void navigate_forward();
|
||||||
void refresh();
|
void refresh();
|
||||||
void restore_window();
|
void restore_window();
|
||||||
|
void urls_dropped(QList<QUrl> const&);
|
||||||
Gfx::IntPoint reposition_window(Gfx::IntPoint);
|
Gfx::IntPoint reposition_window(Gfx::IntPoint);
|
||||||
Gfx::IntSize resize_window(Gfx::IntSize);
|
Gfx::IntSize resize_window(Gfx::IntSize);
|
||||||
Gfx::IntRect maximize_window();
|
Gfx::IntRect maximize_window();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue