KParts

browseropenorsavequestion.h
1 /*
2  SPDX-FileCopyrightText: 2009 David Faure <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #ifndef BROWSEROPENORSAVEQUESTION_H
8 #define BROWSEROPENORSAVEQUESTION_H
9 
10 #include <kparts/browserrun.h>
11 #include <kparts/kparts_export.h>
12 
13 #include <KService>
14 #include <memory>
15 
16 namespace KParts
17 {
18 class BrowserOpenOrSaveQuestionPrivate;
19 
20 /**
21  * @class BrowserOpenOrSaveQuestion browseropenorsavequestion.h <KParts/BrowserOpenOrSaveQuestion>
22  *
23  * @short This class shows the dialog that asks the user whether to
24  * save a url or open a url in another application.
25  *
26  * It also has the variant which asks "save or embed" (e.g. into konqueror).
27  *
28  * @since 4.4
29  */
30 class KPARTS_EXPORT BrowserOpenOrSaveQuestion
31 {
32 public:
33  /**
34  * Constructor, for all kinds of dialogs shown in this class.
35  * @param url the URL in question
36  * @param mimeType the mimetype of the URL
37  */
38  BrowserOpenOrSaveQuestion(QWidget *parent, const QUrl &url, const QString &mimeType);
40 
41  /**
42  * Sets the suggested filename, shown in the dialog.
43  * @param suggestedFileName optional file name suggested by the server (HTTP Content-Disposition)
44  */
45  void setSuggestedFileName(const QString &suggestedFileName);
46 
47  /**
48  * Set of features that should be enabled in this dialog.
49  * This allows to add features before making all applications ready for those features
50  * (e.g. applications need to read selectedService() otherwise the dialog should not
51  * show the service selection button)
52  * @see Features
53  */
54  enum Feature {
55  BasicFeatures = 0, /**< Only the basic save, open, embed, cancel button */
56  ServiceSelection = 1, /**< Shows "Open With..." with the associated applications for the mimetype */
57  };
58  /**
59  * Stores a combination of #Feature values.
60  */
61  Q_DECLARE_FLAGS(Features, Feature)
62 
63  /**
64  * Enables the given features in the dialog
65  */
66  void setFeatures(Features features);
67 
68  enum Result { Save, Open, Embed, Cancel };
69 
70  /**
71  * Ask the user whether to save or open a url in another application.
72  * @return Save, Open or Cancel.
73  */
74  Result askOpenOrSave();
75 
76  /**
77  * @since 5.65
78  */
80  InlineDisposition = 0,
81  AttachmentDisposition = 1,
82  };
83 
84  /**
85  * Ask the user whether to save or open a url in another application.
86  * @param flags set to AttachmentDisposition if suggested by the server
87  * This is used because by default text/html files are opened embedded in browsers, not saved.
88  * But if the server said "attachment", it means the user is download a file for saving it.
89  * @return Save, Embed or Cancel.
90  */
91  Result askEmbedOrSave(int flags = 0);
92 
93  // TODO askOpenEmbedOrSave
94 
95  /**
96  * @return the service that was selected during askOpenOrSave,
97  * if it returned Open.
98  * In all other cases (no associated application, Save or Cancel
99  * selected), this returns 0.
100  *
101  * Requires setFeatures(BrowserOpenOrSaveQuestion::ServiceSelection).
102  */
103  KService::Ptr selectedService() const;
104 
105 private:
106  std::unique_ptr<BrowserOpenOrSaveQuestionPrivate> const d;
107  Q_DISABLE_COPY(BrowserOpenOrSaveQuestion)
108 };
109 
110 }
111 
112 #endif /* BROWSEROPENORSAVEQUESTION_H */
This class shows the dialog that asks the user whether to save a url or open a url in another applica...
The KParts namespace,.
Feature
Set of features that should be enabled in this dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 03:49:57 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.