KIO

openwithhandlerinterface.h
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 OPENWITHHANDLERINTERFACE_H
9#define OPENWITHHANDLERINTERFACE_H
10
11#include <KService>
12#include <QObject>
13#include <kiogui_export.h>
14class QString;
15
16class KJob;
17
18namespace KIO
19{
20class OpenWithHandlerInterfacePrivate;
21
22/**
23 * @class OpenWithHandlerInterface openwithhandlerinterface.h <KIO/OpenWithHandlerInterface>
24 * @brief The OpenWithHandlerInterface class allows OpenUrlJob to
25 * prompt the user about which application to use to open URLs that do not
26 * have an associated application (via the "Open With" dialog).
27 *
28 * This extension mechanism for jobs is similar to KIO::JobUiDelegateExtension
29 * and UntrustedProgramHandlerInterface.
30 *
31 * @since 5.71
32 */
33class KIOGUI_EXPORT OpenWithHandlerInterface : public QObject
34{
35 Q_OBJECT
36protected:
37 /**
38 * Constructor
39 */
40 explicit OpenWithHandlerInterface(QObject *parent = nullptr);
41
42 /**
43 * Destructor
44 */
46
47public:
48 /**
49 * Show the "Open With" dialog.
50 * @param job the job calling this. Useful to get all its properties
51 * @param urls the URLs to open
52 * @param mimeType the MIME type of the URLs, if known. Can be empty otherwise.
53 *
54 * Implementations of this method must emit either serviceSelected or canceled.
55 *
56 * The default implementation in this base class simply emits canceled().
57 * Any application using KIO::JobUiDelegate (from KIOWidgets) will benefit from an
58 * automatically registered subclass which implements this method using KOpenWithDialog.
59 */
60 virtual void promptUserForApplication(KJob *job, const QList<QUrl> &urls, const QString &mimeType);
61
62Q_SIGNALS:
63 /**
64 * Emitted by promptUserForApplication() once the user chooses an application.
65 * @param service the application chosen by the user
66 */
67 void serviceSelected(const KService::Ptr &service);
68
69 /**
70 * Emitted by promptUserForApplication() if the user canceled the application selection dialog.
71 */
72 void canceled();
73
74 /**
75 * Emitted by promptUserForApplication() if it fully handled it including launching the app.
76 * This is a special case for the native Windows open-with dialog.
77 */
78 void handled();
79
80private:
82};
83
84}
85
86#endif // OPENWITHHANDLERINTERFACE_H
The OpenWithHandlerInterface class allows OpenUrlJob to prompt the user about which application to us...
void serviceSelected(const KService::Ptr &service)
Emitted by promptUserForApplication() once the user chooses an application.
void handled()
Emitted by promptUserForApplication() if it fully handled it including launching the app.
void canceled()
Emitted by promptUserForApplication() if the user canceled the application selection dialog.
~OpenWithHandlerInterface() override
Destructor.
A namespace for KIO globals.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:52 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.