From fa3cf05f721f6bacf1fde492b64e749e4c6641c1 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 8 Oct 2021 14:29:59 +0200 Subject: [PATCH] dragger: initial version --- dragger.cc | 33 +++++++++++++++++++++++++++++++++ dragger.pro | 3 +++ 2 files changed, 36 insertions(+) create mode 100644 dragger.cc create mode 100644 dragger.pro diff --git a/dragger.cc b/dragger.cc new file mode 100644 index 0000000..87c59e4 --- /dev/null +++ b/dragger.cc @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) { + QApplication app(argc, argv); + + QList 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(); +} diff --git a/dragger.pro b/dragger.pro new file mode 100644 index 0000000..6015b89 --- /dev/null +++ b/dragger.pro @@ -0,0 +1,3 @@ +SOURCES = dragger.cc +CONFIG += qt +QT += widgets