1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org> |
4 | SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org> |
5 | SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org> |
6 | SPDX-FileCopyrightText: 2013 Dawit Alemayehu <adawit@kde.org> |
7 | SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org> |
8 | |
9 | SPDX-License-Identifier: LGPL-2.0-or-later |
10 | */ |
11 | |
12 | #ifndef KIO_JOBUIDELEGATE_H |
13 | #define KIO_JOBUIDELEGATE_H |
14 | |
15 | #include "kiowidgets_export.h" |
16 | #include <KDialogJobUiDelegate> |
17 | #include <kio/askuseractioninterface.h> |
18 | #include <kio/global.h> |
19 | #include <kio/jobuidelegateextension.h> |
20 | #include <kio/renamedialog.h> |
21 | #include <kio/skipdialog.h> |
22 | |
23 | class KJob; |
24 | class KDirOperator; |
25 | class KIOWidgetJobUiDelegateFactory; |
26 | |
27 | namespace KIO |
28 | { |
29 | class JobUiDelegatePrivate; |
30 | |
31 | class FileUndoManager; |
32 | |
33 | class Job; |
34 | |
35 | /*! |
36 | * \class KIO::JobUiDelegate |
37 | * \inmodule KIOWidgets |
38 | * \inheaderfile KIO/JobUiDelegate |
39 | * |
40 | * A UI delegate tuned to be used with KIO Jobs. |
41 | */ |
42 | class KIOWIDGETS_EXPORT JobUiDelegate : public KDialogJobUiDelegate, public JobUiDelegateExtension |
43 | { |
44 | Q_OBJECT |
45 | // Allow the factory to construct. Everyone else needs to go through the factory or derive! |
46 | friend class ::KIOWidgetJobUiDelegateFactory; |
47 | // KIO internals don't need to derive either |
48 | friend class KIO::FileUndoManager; |
49 | |
50 | protected: |
51 | friend class ::KDirOperator; |
52 | |
53 | /*! |
54 | * Constructs a new KIO Job UI delegate. |
55 | * |
56 | * \a flags allows to enable automatic error/warning handling |
57 | * |
58 | * \a window the window associated with this delegate, see setWindow. |
59 | * |
60 | * \a ifaces Interface instances such as OpenWithHandlerInterface to replace the default interfaces |
61 | * |
62 | * \since 5.98 |
63 | */ |
64 | explicit JobUiDelegate(KJobUiDelegate::Flags flags = AutoHandlingDisabled, QWidget *window = nullptr, const QList<QObject *> &ifaces = {}); |
65 | |
66 | public: |
67 | ~JobUiDelegate() override; |
68 | |
69 | public: |
70 | /*! |
71 | * Associate this job with a window given by \a window. |
72 | * |
73 | * \a window the window to associate to |
74 | * |
75 | * \sa window() |
76 | */ |
77 | void setWindow(QWidget *window) override; |
78 | |
79 | /*! |
80 | * Unregister the given window from kded. |
81 | * This is normally done automatically when the window is destroyed. |
82 | * |
83 | * This method is useful for instance when keeping a hidden window |
84 | * around to make it faster to reuse later. |
85 | * \since 5.2 |
86 | */ |
87 | static void unregisterWindow(QWidget *window); |
88 | |
89 | #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(6, 15) |
90 | /*! |
91 | * Ask for confirmation before deleting/trashing \a urls. |
92 | * |
93 | * Note that this method is not called automatically by KIO jobs. It's the application's |
94 | * responsibility to ask the user for confirmation before calling KIO::del() or KIO::trash(). |
95 | * |
96 | * \a urls the urls about to be deleted/trashed |
97 | * |
98 | * \a deletionType the type of deletion (Delete for real deletion, Trash otherwise) |
99 | * |
100 | * \a confirmationType see ConfirmationType. Normally set to DefaultConfirmation. |
101 | * |
102 | * \note The window passed to setWindow is used as the parent for the message box. |
103 | * |
104 | * Returns true if confirmed |
105 | * |
106 | * \deprecated[6.15] Use AskUserActionInterface::askUserDelete |
107 | */ |
108 | bool askDeleteConfirmation(const QList<QUrl> &urls, DeletionType deletionType, ConfirmationType confirmationType) override; |
109 | #endif |
110 | |
111 | /*! |
112 | * Creates a clipboard updater |
113 | */ |
114 | ClipboardUpdater *createClipboardUpdater(Job *job, ClipboardUpdaterMode mode) override; |
115 | /*! |
116 | * Update URL in clipboard, if present |
117 | */ |
118 | void updateUrlInClipboard(const QUrl &src, const QUrl &dest) override; |
119 | |
120 | private: |
121 | std::unique_ptr<JobUiDelegatePrivate> const d; |
122 | }; |
123 | } |
124 | |
125 | #endif |
126 | |