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
22 * \inmodule KIOFileWidgets
23 *
24 * \brief This class adds "Copy To" and "Move To" submenus to a popupmenu.
25 */
26class KIOFILEWIDGETS_EXPORT KFileCopyToMenu : public QObject
27{
28 Q_OBJECT
29public:
30 /*!
31 * Creates a KFileCopyToMenu instance
32 * Note that this instance (and the widget) must stay alive for at least as
33 * long as the popupmenu; it has the slots for the actions created by addActionsTo.
34 *
35 * \a parentWidget parent widget for the file dialog and message boxes.
36 * The parentWidget also serves as a parent for this object.
37 */
38 explicit KFileCopyToMenu(QWidget *parentWidget);
39
40 ~KFileCopyToMenu() override;
41
42 /*!
43 * Sets the URLs which the actions apply to.
44 */
45 void setUrls(const QList<QUrl> &urls);
46
47 /*!
48 * If setReadOnly(true) is called, the "Move To" submenu will not appear.
49 */
50 void setReadOnly(bool ro);
51
52 /*!
53 * Generate the actions and submenus, and adds them to the \a menu.
54 * All actions are created as children of the menu.
55 */
56 void addActionsTo(QMenu *menu) const;
57
58 /*!
59 * Enables or disables automatic error handling with message boxes.
60 * When called with true, a messagebox is shown in case of an error during a copy or move.
61 * When called with false, the application should connect to the error signal instead.
62 * Auto error handling is disabled by default.
63 */
64 void setAutoErrorHandlingEnabled(bool b);
65
66Q_SIGNALS:
67 /*!
68 * Emitted when the copy or move job fails.
69 *
70 * \a errorCode the KIO job error code
71 *
72 * \a 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