GDragOperation.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <LibCore/CEventLoop.h>
  3. #include <LibCore/CObject.h>
  4. class GraphicsBitmap;
  5. class GWindowServerConnection;
  6. class GDragOperation : public CObject {
  7. C_OBJECT(GDragOperation)
  8. public:
  9. enum class Outcome {
  10. None,
  11. Accepted,
  12. Cancelled,
  13. };
  14. virtual ~GDragOperation() override;
  15. void set_text(const String& text) { m_text = text; }
  16. void set_bitmap(const GraphicsBitmap* bitmap) { m_bitmap = bitmap; }
  17. void set_data(const String& data_type, const String& data)
  18. {
  19. m_data_type = data_type;
  20. m_data = data;
  21. }
  22. Outcome exec();
  23. Outcome outcome() const { return m_outcome; }
  24. static void notify_accepted(Badge<GWindowServerConnection>);
  25. static void notify_cancelled(Badge<GWindowServerConnection>);
  26. protected:
  27. explicit GDragOperation(CObject* parent = nullptr);
  28. private:
  29. void done(Outcome);
  30. OwnPtr<CEventLoop> m_event_loop;
  31. Outcome m_outcome { Outcome::None };
  32. String m_text;
  33. String m_data_type;
  34. String m_data;
  35. RefPtr<GraphicsBitmap> m_bitmap;
  36. };