1/*
2 SPDX-FileCopyrightText: 2008, 2015 David Faure <faure@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef KFILECOPYTOMENU_H
8#define KFILECOPYTOMENU_H
9
10#include <QObject>
11#include <QUrl>
12
13#include <kiofilewidgets_export.h>
14
15#include <memory>
16
17class QMenu;
18class KFileCopyToMenuPrivate;
19
20/**
21 * @class KFileCopyToMenu kfilecopytomenu.h <KFileCopyToMenu>
22 *
23 * This class adds "Copy To" and "Move To" submenus to a popupmenu.
24 */
25class KIOFILEWIDGETS_EXPORT KFileCopyToMenu : public QObject
26{
27 Q_OBJECT
28public:
29 /**
30 * Creates a KFileCopyToMenu instance
31 * Note that this instance (and the widget) must stay alive for at least as
32 * long as the popupmenu; it has the slots for the actions created by addActionsTo.
33 *
34 * @param parentWidget parent widget for the file dialog and message boxes.
35 * The parentWidget also serves as a parent for this object.
36 */
37 explicit KFileCopyToMenu(QWidget *parentWidget);
38
39 /**
40 * Destructor
41 */
42 ~KFileCopyToMenu() override;
43
44 /**
45 * Sets the URLs which the actions apply to.
46 */
47 void setUrls(const QList<QUrl> &urls);
48
49 /**
50 * If setReadOnly(true) is called, the "Move To" submenu will not appear.
51 */
52 void setReadOnly(bool ro);
53
54 /**
55 * Generate the actions and submenus, and adds them to the @p menu.
56 * All actions are created as children of the menu.
57 */
58 void addActionsTo(QMenu *menu) const;
59
60 /**
61 * Enables or disables automatic error handling with message boxes.
62 * When called with true, a messagebox is shown in case of an error during a copy or move.
63 * When called with false, the application should connect to the error signal instead.
64 * Auto error handling is disabled by default.
65 */
66 void setAutoErrorHandlingEnabled(bool b);
67
68Q_SIGNALS:
69 /**
70 * Emitted when the copy or move job fails.
71 * @param errorCode the KIO job error code
72 * @param message the error message to show the user
73 */
74 void error(int errorCode, const QString &message);
75
76private:
77 std::unique_ptr<KFileCopyToMenuPrivate> const d;
78};
79
80#endif
81

source code of kio/src/filewidgets/kfilecopytomenu.h