1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2020 David Faure <faure@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
6 | */ |
7 | |
8 | #ifndef WIDGETSUNTRUSTEDPROGRAMHANDLER_H |
9 | #define WIDGETSUNTRUSTEDPROGRAMHANDLER_H |
10 | |
11 | #include "untrustedprogramhandlerinterface.h" |
12 | |
13 | #include <memory> |
14 | |
15 | class QDialog; |
16 | class QWidget; |
17 | |
18 | namespace KIO |
19 | { |
20 | // TODO KF6: Make KIO::JobUiDelegate inherit from WidgetsUntrustedProgramHandler |
21 | // (or even merge the two classes) |
22 | // so that setDelegate(new KIO::JobUiDelegate) provides both dialog boxes on error |
23 | // and the messagebox for handling untrusted programs. |
24 | // Then port those users of ApplicationLauncherJob which were setting a KDialogJobUiDelegate |
25 | // to set a KIO::JobUiDelegate instead. |
26 | class WidgetsUntrustedProgramHandlerPrivate; |
27 | |
28 | class WidgetsUntrustedProgramHandler : public UntrustedProgramHandlerInterface |
29 | { |
30 | Q_OBJECT |
31 | public: |
32 | explicit WidgetsUntrustedProgramHandler(QObject *parent = nullptr); |
33 | ~WidgetsUntrustedProgramHandler() override; |
34 | |
35 | void showUntrustedProgramWarning(KJob *job, const QString &programName) override; |
36 | |
37 | // Compat code for KRun::runUrl. Will disappear before KF6 |
38 | bool execUntrustedProgramWarning(QWidget *window, const QString &programName); |
39 | |
40 | void setWindow(QWidget *window); |
41 | |
42 | private: |
43 | QDialog *createDialog(QWidget *parentWidget, const QString &programName); |
44 | |
45 | std::unique_ptr<WidgetsUntrustedProgramHandlerPrivate> d; |
46 | }; |
47 | |
48 | } |
49 | |
50 | #endif // WIDGETSUNTRUSTEDPROGRAMHANDLER_H |
51 | |