image picker with clipboard and drag-n-drop capability for linux.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
712 B

2 years ago
  1. #pragma once
  2. #include <QClipboard>
  3. #include <QObject>
  4. #include <QImage>
  5. #include <QUrl>
  6. #include <QProcess>
  7. #include <iostream>
  8. #include <QGuiApplication>
  9. class Clipboard : public QObject {
  10. Q_OBJECT
  11. public:
  12. Clipboard(QGuiApplication *owner, const char *app) : _app(app), _owner(owner) { }
  13. virtual ~Clipboard() {};
  14. Q_INVOKABLE void setClipboard(QUrl str) {
  15. QProcess proc;
  16. proc.setProgram(QString(_app));
  17. QStringList args{"clipboard", str.path()};
  18. proc.setArguments(args);
  19. qint64 pid;
  20. proc.startDetached(&pid);
  21. std::cout << "clipboard owner " << _app << " started: " << pid << std::endl;
  22. _owner->quit();
  23. }
  24. private:
  25. const char *_app;
  26. QGuiApplication *_owner;
  27. };