VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.h@ 100064

Last change on this file since 100064 was 98700, checked in by vboxsync, 16 months ago

FE/Qt: bugref:10322: Runtime UI: Reworking CMachine wrapper usage step-by-step; DnD related stuff.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/* $Id: UIDnDHandler.h 98700 2023-02-23 10:13:07Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIDnDHandler class declaration..
4 */
5
6/*
7 * Copyright (C) 2011-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_runtime_UIDnDHandler_h
29#define FEQT_INCLUDED_SRC_runtime_UIDnDHandler_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QMimeData>
36#include <QMutex>
37#include <QStringList>
38
39/* COM includes: */
40#include "COMEnums.h"
41#include "CDnDTarget.h"
42#include "CDnDSource.h"
43
44/* Forward declarations: */
45class QMimeData;
46
47class UIDnDMIMEData;
48class UIMachine;
49
50/**
51 * Main class for implementing Drag'n'Drop in the frontend.
52 */
53class UIDnDHandler: public QObject
54{
55 Q_OBJECT;
56
57public:
58
59 UIDnDHandler(UIMachine *pMachine, QWidget *pParent);
60 virtual ~UIDnDHandler(void);
61
62 /**
63 * Drag and drop data set from the source.
64 */
65 typedef struct UIDnDDataSource
66 {
67 /** List of formats supported by the source. */
68 QStringList lstFormats;
69 /** List of allowed drop actions from the source. */
70 QVector<KDnDAction> vecActions;
71 /** Default drop action from the source. */
72 KDnDAction defaultAction;
73
74 } UIDnDDataSource;
75
76 int init(void);
77 void reset(void);
78
79 /* Frontend -> Target. */
80 Qt::DropAction dragEnter(ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData);
81 Qt::DropAction dragMove (ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData);
82 Qt::DropAction dragDrop (ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData);
83 void dragLeave(ulong screenId);
84
85 /* Source -> Frontend. */
86 int dragCheckPending(ulong screenId);
87 int dragStart(ulong screenId);
88 int dragStop(ulong screenID);
89
90 /* Data access. */
91 int retrieveData(Qt::DropAction dropAction, const QString &strMIMEType, QVector<uint8_t> &vecData);
92 int retrieveData(Qt::DropAction dropAction, const QString &strMIMEType, QVariant::Type vaType, QVariant &vaData);
93
94public:
95
96 static KDnDAction toVBoxDnDAction(Qt::DropAction action);
97 static QVector<KDnDAction> toVBoxDnDActions(Qt::DropActions actions);
98 static Qt::DropAction toQtDnDAction(KDnDAction action);
99 static Qt::DropActions toQtDnDActions(const QVector<KDnDAction> &vecActions);
100
101public slots:
102
103 /**
104 * Called by UIDnDMIMEData (Linux, OS X, Solaris) to start retrieving the actual data
105 * from the guest. This function will block and show a modal progress dialog until
106 * the data transfer is complete.
107 *
108 * @return IPRT status code.
109 * @param dropAction Drop action to perform.
110 * @param strMIMEType MIME data type.
111 * @param vaType Qt's variant type of the MIME data.
112 * @param vaData Reference to QVariant where to store the retrieved data.
113 */
114 int sltGetData(Qt::DropAction dropAction, const QString &strMIMEType, QVariant::Type vaType, QVariant &vaData);
115
116protected:
117
118#ifdef DEBUG
119 static void debugOutputQt(QtMsgType type, const char *pszMsg);
120#endif
121
122protected:
123
124 int dragStartInternal(const QStringList &lstFormats, Qt::DropAction defAction, Qt::DropActions actions);
125 int retrieveDataInternal(Qt::DropAction dropAction, const QString &strMIMEType, QVector<uint8_t> &vecData);
126
127protected:
128
129#ifdef RT_OS_WINDOWS
130 static int getProcessIntegrityLevel(DWORD *pdwIntegrityLevel);
131#endif
132
133protected:
134
135 /** Pointer to machine UI. */
136 UIMachine *m_pMachine;
137 /** Pointer to parent widget. */
138 QWidget *m_pParent;
139 /** Drag and drop source instance. */
140 CDnDSource m_dndSource;
141 /** Drag and drop target instance. */
142 CDnDTarget m_dndTarget;
143 /** Current data from the source (if any).
144 * At the momenet we only support one source at a time. */
145 UIDnDDataSource m_dataSource;
146 /** Flag indicating whether data has been retrieved from
147 * the guest already or not. */
148 bool m_fDataRetrieved;
149 QMutex m_ReadLock;
150 QMutex m_WriteLock;
151 /** Data received from the guest. */
152 QVector<uint8_t> m_vecData;
153
154#ifdef RT_OS_WINDOWS
155 /** Process integrity level we're running with. Needed for UIPI detection + logging.
156 * Set to 0 if not set yet or unavailable. */
157 DWORD m_dwIntegrityLevel;
158#else /* !RT_OS_WINDOWS */
159 /** Pointer to MIMEData instance used for handling
160 * own MIME times on non-Windows host OSes. */
161 UIDnDMIMEData *m_pMIMEData;
162 friend class UIDnDMIMEData;
163#endif /* RT_OS_WINDOWS */
164};
165#endif /* !FEQT_INCLUDED_SRC_runtime_UIDnDHandler_h */
166
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use