File indexing completed on 2024-05-12 17:08:47
0001 /* 0002 SPDX-FileCopyrightText: 2022 Kai Uwe Broulik <kde@broulik.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 #include <QPixmap> 0011 #include <QQuickItem> 0012 #include <QString> 0013 #include <QUrl> 0014 #include <QWindow> 0015 0016 class DragHelper : public QObject 0017 { 0018 Q_OBJECT 0019 0020 Q_PROPERTY(bool dragActive READ dragActive NOTIFY dragActiveChanged) 0021 Q_PROPERTY(int dragPixmapSize READ dragPixmapSize WRITE setDragPixmapSize NOTIFY dragPixmapSizeChanged) 0022 0023 public: 0024 explicit DragHelper(QObject *parent = nullptr); 0025 ~DragHelper() override; 0026 0027 bool dragActive() const; 0028 0029 int dragPixmapSize() const; 0030 void setDragPixmapSize(int dragPixmapSize); 0031 0032 Q_INVOKABLE bool isDrag(int oldX, int oldY, int newX, int newY) const; 0033 Q_INVOKABLE void startDrag(QQuickItem *item, const QUrl &url, const QString &iconName); 0034 Q_INVOKABLE void startDrag(QQuickItem *item, const QUrl &url, const QPixmap &pixmap); 0035 0036 Q_SIGNALS: 0037 void dragActiveChanged(); 0038 void dragPixmapSizeChanged(); 0039 0040 private Q_SLOTS: 0041 void doDrag(QQuickItem *item, const QUrl &url, const QPixmap &pixmap); 0042 0043 private: 0044 bool m_dragActive = false; 0045 int m_dragPixmapSize = 48; // set to units.iconSizes.large in DraggableFileArea 0046 };