| 1 | /* |
| 2 | SPDX-FileCopyrightText: 1997 Torben Weis <weis@stud.uni-frankfurt.de> |
| 3 | SPDX-FileCopyrightText: 1999 Dirk Mueller <mueller@kde.org> |
| 4 | Portions SPDX-FileCopyrightText: 1999 Preston Brown <pbrown@kde.org> |
| 5 | SPDX-FileCopyrightText: 2007 Pino Toscano <pino@kde.org> |
| 6 | SPDX-FileCopyrightText: 2023 Harald Sitter <sitter@kde.org> |
| 7 | |
| 8 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 9 | */ |
| 10 | |
| 11 | #pragma once |
| 12 | |
| 13 | #include <QString> |
| 14 | |
| 15 | #include <KService> |
| 16 | |
| 17 | #include "kiocore_export.h" |
| 18 | |
| 19 | namespace KIO |
| 20 | { |
| 21 | |
| 22 | /*! |
| 23 | * \class KIO::OpenWith |
| 24 | * \inheaderfile KIO/OpenWith |
| 25 | * |
| 26 | * \brief Core class for open with style dialog handling. |
| 27 | * |
| 28 | * This only implements core functionality. For an actual open with |
| 29 | * implementation see KOpenWithDialog. For a way to trigger open with dialogs see OpenUrlJob and OpenWithHandlerInterface. |
| 30 | */ |
| 31 | class KIOCORE_EXPORT OpenWith |
| 32 | { |
| 33 | public: |
| 34 | struct [[nodiscard]] AcceptResult { |
| 35 | /*! |
| 36 | * Whether the accept was successful (if not error is set) |
| 37 | */ |
| 38 | bool accept; |
| 39 | /*! |
| 40 | * The error message if the acccept failed |
| 41 | */ |
| 42 | QString error; |
| 43 | /*! |
| 44 | * Whether the sycoca needs rebuilding (e.g. call KBuildSycocaProgressDialog::rebuildKSycoca) |
| 45 | */ |
| 46 | bool rebuildSycoca = false; |
| 47 | }; |
| 48 | /*! |
| 49 | * Accept an openwith request with the provided arguments as context. |
| 50 | * This function may have side effects to do with accepting, such as setting the default application for the |
| 51 | * mimetype if \a remember is true. |
| 52 | * |
| 53 | * Returns an AcceptResult |
| 54 | */ |
| 55 | static AcceptResult accept(KService::Ptr &service, |
| 56 | const QString &typedExec, |
| 57 | bool remember, |
| 58 | const QString &mimeType, |
| 59 | bool openInTerminal, |
| 60 | bool lingerTerminal, |
| 61 | bool saveNewApps); |
| 62 | }; |
| 63 | |
| 64 | } // namespace KIO |
| 65 | |