Qt: Handle display surface Drag & Drop events

This commit is contained in:
TheLastRar
2025-11-18 15:03:57 +01:00
committed by lightningterror
parent 4209900351
commit 4d1afb9fdd
3 changed files with 18 additions and 0 deletions
+10
View File
@@ -365,6 +365,16 @@ bool DisplaySurface::event(QEvent* event)
return true;
}
case QEvent::DragEnter:
QWindow::event(event);
emit dragEnterEvent(static_cast<QDragEnterEvent*>(event));
return event->isAccepted();
case QEvent::Drop:
QWindow::event(event);
emit dropEvent(static_cast<QDropEvent*>(event));
return event->isAccepted();
case QEvent::Move:
{
updateCenterPos();
+4
View File
@@ -3,6 +3,7 @@
#pragma once
#include "common/WindowInfo.h"
#include <QtGui/QDragMoveEvent>
#include <QtGui/QWindow>
#include <optional>
#include <vector>
@@ -32,6 +33,9 @@ Q_SIGNALS:
void windowResizedEvent(int width, int height, float scale);
void windowRestoredEvent();
void dragEnterEvent(QDragEnterEvent* event);
void dropEvent(QDropEvent* event);
protected:
void handleCloseEvent(QCloseEvent* event);
void handleKeyInputEvent(QEvent* event);
+4
View File
@@ -2441,6 +2441,10 @@ void MainWindow::createDisplayWidget(bool fullscreen, bool render_to_main)
m_ui.mainContainer->setCurrentIndex(1);
}
// Attatch drag and drop signals
connect(m_display_surface, &DisplaySurface::dragEnterEvent, this, &MainWindow::dragEnterEvent);
connect(m_display_surface, &DisplaySurface::dropEvent, this, &MainWindow::dropEvent);
updateDisplayRelatedActions(true, render_to_main, fullscreen);
// We need the surface visible.