commit fa3cf05f721f6bacf1fde492b64e749e4c6641c1 Author: Bruno BELANYI Date: Fri Oct 8 14:29:59 2021 +0200 dragger: initial version 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