File indexing completed on 2024-09-15 03:38:39
0001 /* 0002 SPDX-FileCopyrightText: 2008, 2015 David Faure <faure@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef KFILECOPYTOMENU_H 0008 #define KFILECOPYTOMENU_H 0009 0010 #include <QObject> 0011 #include <QUrl> 0012 0013 #include <kiofilewidgets_export.h> 0014 0015 #include <memory> 0016 0017 class QMenu; 0018 class KFileCopyToMenuPrivate; 0019 0020 /** 0021 * @class KFileCopyToMenu kfilecopytomenu.h <KFileCopyToMenu> 0022 * 0023 * This class adds "Copy To" and "Move To" submenus to a popupmenu. 0024 */ 0025 class KIOFILEWIDGETS_EXPORT KFileCopyToMenu : public QObject 0026 { 0027 Q_OBJECT 0028 public: 0029 /** 0030 * Creates a KFileCopyToMenu instance 0031 * Note that this instance (and the widget) must stay alive for at least as 0032 * long as the popupmenu; it has the slots for the actions created by addActionsTo. 0033 * 0034 * @param parentWidget parent widget for the file dialog and message boxes. 0035 * The parentWidget also serves as a parent for this object. 0036 */ 0037 explicit KFileCopyToMenu(QWidget *parentWidget); 0038 0039 /** 0040 * Destructor 0041 */ 0042 ~KFileCopyToMenu() override; 0043 0044 /** 0045 * Sets the URLs which the actions apply to. 0046 */ 0047 void setUrls(const QList<QUrl> &urls); 0048 0049 /** 0050 * If setReadOnly(true) is called, the "Move To" submenu will not appear. 0051 */ 0052 void setReadOnly(bool ro); 0053 0054 /** 0055 * Generate the actions and submenus, and adds them to the @p menu. 0056 * All actions are created as children of the menu. 0057 */ 0058 void addActionsTo(QMenu *menu) const; 0059 0060 /** 0061 * Enables or disables automatic error handling with message boxes. 0062 * When called with true, a messagebox is shown in case of an error during a copy or move. 0063 * When called with false, the application should connect to the error signal instead. 0064 * Auto error handling is disabled by default. 0065 */ 0066 void setAutoErrorHandlingEnabled(bool b); 0067 0068 Q_SIGNALS: 0069 /** 0070 * Emitted when the copy or move job fails. 0071 * @param errorCode the KIO job error code 0072 * @param message the error message to show the user 0073 */ 0074 void error(int errorCode, const QString &message); 0075 0076 private: 0077 std::unique_ptr<KFileCopyToMenuPrivate> const d; 0078 }; 0079 0080 #endif