Implement Drag&Drop support
This commit is contained in:
parent
360a5a1bef
commit
43e3ea25da
@ -25,7 +25,7 @@
|
|||||||
#define VER_LAMEXP_MAJOR 4
|
#define VER_LAMEXP_MAJOR 4
|
||||||
#define VER_LAMEXP_MINOR_HI 0
|
#define VER_LAMEXP_MINOR_HI 0
|
||||||
#define VER_LAMEXP_MINOR_LO 0
|
#define VER_LAMEXP_MINOR_LO 0
|
||||||
#define VER_LAMEXP_BUILD 11
|
#define VER_LAMEXP_BUILD 12
|
||||||
#define VER_LAMEXP_SUFFIX TechPreview
|
#define VER_LAMEXP_SUFFIX TechPreview
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -47,6 +47,8 @@
|
|||||||
#include <QWindowsVistaStyle>
|
#include <QWindowsVistaStyle>
|
||||||
#include <QWindowsStyle>
|
#include <QWindowsStyle>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
|
#include <QDragEnterEvent>
|
||||||
|
#include <QWindowsMime>
|
||||||
|
|
||||||
//Win32 includes
|
//Win32 includes
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
@ -205,6 +207,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
connect(m_messageHandler, SIGNAL(killSignalReceived()), this, SLOT(close()), Qt::QueuedConnection);
|
connect(m_messageHandler, SIGNAL(killSignalReceived()), this, SLOT(close()), Qt::QueuedConnection);
|
||||||
connect(m_delayedFileTimer, SIGNAL(timeout()), this, SLOT(handleDelayedFiles()));
|
connect(m_delayedFileTimer, SIGNAL(timeout()), this, SLOT(handleDelayedFiles()));
|
||||||
m_messageHandler->start();
|
m_messageHandler->start();
|
||||||
|
|
||||||
|
//Enable Drag & Drop
|
||||||
|
this->setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -284,6 +289,34 @@ void MainWindow::showEvent(QShowEvent *event)
|
|||||||
QTimer::singleShot(0, this, SLOT(windowShown()));
|
QTimer::singleShot(0, this, SLOT(windowShown()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||||
|
{
|
||||||
|
QStringList formats = event->mimeData()->formats();
|
||||||
|
|
||||||
|
for(int i = 0; i < formats.count(); i++)
|
||||||
|
{
|
||||||
|
if(formats[i].indexOf("FileNameW") >= 0)
|
||||||
|
{
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::dropEvent(QDropEvent *event)
|
||||||
|
{
|
||||||
|
ABORT_IF_BUSY;
|
||||||
|
|
||||||
|
QStringList droppedFiles;
|
||||||
|
const QList<QUrl> urls = event->mimeData()->urls();
|
||||||
|
|
||||||
|
for(int i = 0; i < urls.count(); i++)
|
||||||
|
{
|
||||||
|
droppedFiles << QFileInfo(urls.at(i).toLocalFile()).absoluteFilePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
addFiles(droppedFiles);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -71,6 +71,8 @@ private slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent *event);
|
void showEvent(QShowEvent *event);
|
||||||
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
void dropEvent(QDropEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addFiles(const QStringList &files);
|
void addFiles(const QStringList &files);
|
||||||
|
Loading…
Reference in New Issue
Block a user