mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 01:20:42 +00:00
Handle drag and drop into the main window
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "MainWindow.h"
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QMimeData>
|
||||
#include <QProgressBar>
|
||||
#include "Code/CaptureContext.h"
|
||||
#include "Code/QRDUtils.h"
|
||||
@@ -40,6 +41,8 @@ MainWindow::MainWindow(CaptureContext *ctx) : QMainWindow(NULL), ui(new Ui::Main
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
QObject::connect(ui->action_Load_Default_Layout, &QAction::triggered, this,
|
||||
&MainWindow::loadLayout_triggered);
|
||||
QObject::connect(ui->action_Load_Layout_1, &QAction::triggered, this,
|
||||
@@ -727,6 +730,35 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
SaveLayout(0);
|
||||
}
|
||||
|
||||
QString dragFilename(const QMimeData *mimeData)
|
||||
{
|
||||
if(mimeData->hasUrls())
|
||||
{
|
||||
QList<QUrl> urls = mimeData->urls();
|
||||
if(urls.size() == 1 && urls[0].isLocalFile())
|
||||
{
|
||||
QFileInfo f(urls[0].toLocalFile());
|
||||
if(f.exists())
|
||||
return f.absoluteFilePath();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if(dragFilename(event->mimeData()) != "")
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void MainWindow::dropEvent(QDropEvent *event)
|
||||
{
|
||||
QString fn = dragFilename(event->mimeData());
|
||||
if(fn != "")
|
||||
LoadFromFilename(fn);
|
||||
}
|
||||
|
||||
void MainWindow::LoadSaveLayout(QAction *action, bool save)
|
||||
{
|
||||
if(action == NULL)
|
||||
|
||||
@@ -70,6 +70,9 @@ private slots:
|
||||
private:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||
void dropEvent(QDropEvent *event) override;
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
CaptureContext *m_Ctx;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user