KWaylandServer

abstract_data_source.h
1 /*
2  SPDX-FileCopyrightText: 2020 David Edmundson <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #pragma once
8 
9 #include "clientconnection.h"
10 #include "datadevicemanager_interface.h"
11 
12 #include <KWaylandServer/kwaylandserver_export.h>
13 
14 struct wl_client;
15 
16 namespace KWaylandServer
17 {
18 /**
19  * @brief The AbstractDataSource class abstracts the data that
20  * can be transferred to another client.
21  *
22  * It loosely maps to DataDeviceInterface
23  */
24 
25 // Anything related to selections are pure virtual, content relating
26 // to drag and drop has a default implementation
27 
28 class KWAYLANDSERVER_EXPORT AbstractDataSource : public QObject
29 {
30  Q_OBJECT
31 public:
32  virtual bool isAccepted() const
33  {
34  return false;
35  }
36 
37  virtual void accept(const QString &mimeType)
38  {
39  Q_UNUSED(mimeType);
40  };
41  virtual void requestData(const QString &mimeType, qint32 fd) = 0;
42  virtual void cancel() = 0;
43 
44  virtual QStringList mimeTypes() const = 0;
45 
46  /**
47  * @returns The Drag and Drop actions supported by this DataSourceInterface.
48  */
50  {
51  return {};
52  };
53  /**
54  * The user performed the drop action during a drag and drop operation.
55  */
56  virtual void dropPerformed(){};
57  /**
58  * The drop destination finished interoperating with this data source.
59  */
60  virtual void dndFinished(){};
61  /**
62  * This event indicates the @p action selected by the compositor after matching the
63  * source/destination side actions. Only one action (or none) will be offered here.
64  */
66  {
67  Q_UNUSED(action);
68  };
69 
70  /**
71  * Called when a user stops clicking but it is not accepted by a client.
72  */
73  virtual void dndCancelled()
74  {
75  }
76 
77  virtual wl_client *client() const
78  {
79  return nullptr;
80  };
81 
82 Q_SIGNALS:
83  void aboutToBeDestroyed();
84 
85  void mimeTypeOffered(const QString &);
86  void supportedDragAndDropActionsChanged();
87 
88 protected:
89  explicit AbstractDataSource(QObject *parent = nullptr);
90 };
91 
92 }
The AbstractDataSource class abstracts the data that can be transferred to another client...
virtual void dndFinished()
The drop destination finished interoperating with this data source.
virtual void dndCancelled()
Called when a user stops clicking but it is not accepted by a client.
virtual DataDeviceManagerInterface::DnDActions supportedDragAndDropActions() const
virtual void dropPerformed()
The user performed the drop action during a drag and drop operation.
DnDAction
Drag and Drop actions supported by the DataSourceInterface.
virtual void dndAction(DataDeviceManagerInterface::DnDAction action)
This event indicates the action selected by the compositor after matching the source/destination side...
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.