File indexing completed on 2024-04-21 11:33:25

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2009 Harald Hvaal <haraldhv@stud.ntnu.no>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only
0006 */
0007 #ifndef _KIO_DNDPOPUPMENUPLUGIN_H_
0008 #define _KIO_DNDPOPUPMENUPLUGIN_H_
0009 
0010 #include "kiowidgets_export.h"
0011 #include <QList>
0012 #include <QObject>
0013 
0014 class KFileItemListProperties;
0015 class QUrl;
0016 class QAction;
0017 
0018 namespace KIO
0019 {
0020 /**
0021  * @class KIO::DndPopupMenuPlugin dndpopupmenuplugin.h <KIO/DndPopupMenuPlugin>
0022  *
0023  * Base class for drag and drop popup menus
0024  *
0025  * This can be used for adding dynamic menu items to the normal copy/move/link
0026  * here menu appearing in KIO-based file managers. In the setup method you may check
0027  * the properties of the dropped files, and if applicable, append your own
0028  * QAction that the user may trigger in the menu.
0029  *
0030  * The plugin should have Json metadata and be installed into kf5/kio_dnd/.
0031  *
0032  * @author Harald Hvaal <metellius@gmail.com>
0033  * @since 5.6
0034  */
0035 class KIOWIDGETS_EXPORT DndPopupMenuPlugin : public QObject
0036 {
0037     Q_OBJECT
0038 public:
0039     /**
0040      * Constructor.
0041      */
0042     DndPopupMenuPlugin(QObject *parent);
0043     ~DndPopupMenuPlugin() override;
0044 
0045     /**
0046      * Implement the setup method in the plugin in order to create actions
0047      * in the given actionCollection and add it to the menu using menu->addAction().
0048      * The popup menu will be set as parent of the actions.
0049      *
0050      * @param popupMenuInfo all the information about the source URLs being dropped
0051      * @param destination the URL to where the file(s) were dropped
0052      * @return a QList with the QActions that will be plugged into the menu.
0053      */
0054     virtual QList<QAction *> setup(const KFileItemListProperties &popupMenuInfo, const QUrl &destination) = 0;
0055 };
0056 
0057 }
0058 
0059 #endif