dragger: initial version
This commit is contained in:
commit
853ebeb6f3
3
dragger.pro
Normal file
3
dragger.pro
Normal file
|
@ -0,0 +1,3 @@
|
|||
SOURCES = src/dragger.cc
|
||||
CONFIG += qt
|
||||
QT += widgets
|
33
src/dragger.cc
Normal file
33
src/dragger.cc
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDrag>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QList>
|
||||
#include <QMimeData>
|
||||
#include <QUrl>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QList<QUrl> urls;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
QFileInfo file(QFile(argv[i]));
|
||||
if (file.exists()) {
|
||||
urls << QUrl("file:" + file.absoluteFilePath());
|
||||
} else {
|
||||
qInfo() << file.filePath() << "does not exist";
|
||||
}
|
||||
}
|
||||
|
||||
if (urls.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
QMimeData* mimeData = new QMimeData();
|
||||
mimeData->setUrls(urls);
|
||||
|
||||
QDrag drag(&app);
|
||||
drag.setMimeData(mimeData);
|
||||
drag.exec();
|
||||
}
|
Loading…
Reference in a new issue