1 | /* |
2 | This file is part of the KDE project |
3 | SPDX-FileCopyrightText: 1998, 1999 Torben Weis <weis@kde.org> |
4 | SPDX-FileCopyrightText: 2006 Daniel Teske <teske@squorn.de> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | */ |
8 | |
9 | #ifndef __kbookmarkmenu_h__ |
10 | #define |
11 | |
12 | #include <kbookmarkswidgets_export.h> |
13 | |
14 | #include <QObject> |
15 | #include <memory> |
16 | |
17 | class QAction; |
18 | class ; |
19 | class KBookmark; |
20 | class KBookmarkManager; |
21 | class KBookmarkOwner; |
22 | class KBookmarkMenu; |
23 | |
24 | class ; |
25 | |
26 | /** |
27 | * @class KBookmarkMenu kbookmarkmenu.h KBookmarkMenu |
28 | * |
29 | * This class provides a bookmark menu. It is typically used in |
30 | * cooperation with KActionMenu but doesn't have to be. |
31 | * |
32 | * If you use this class by itself, then it will use KDE defaults for |
33 | * everything -- the bookmark path, bookmark editor, bookmark launcher.. |
34 | * everything. These defaults reside in the classes |
35 | * KBookmarkOwner (editing bookmarks) and KBookmarkManager |
36 | * (almost everything else). If you wish to change the defaults in |
37 | * any way, you must reimplement either this class or KBookmarkOwner. |
38 | * |
39 | * Using this class is very simple: |
40 | * |
41 | * 1) Create a popup menu (either KActionMenu or QMenu will do) |
42 | * 2) Instantiate a new KBookmarkMenu object using the above popup |
43 | * menu as a parameter |
44 | * 3) Insert your (now full) popup menu wherever you wish |
45 | * |
46 | * The functionality of this class can be disabled with the "action/bookmarks" |
47 | * Kiosk action (see the KAuthorized namespace). |
48 | */ |
49 | class KBOOKMARKSWIDGETS_EXPORT : public QObject |
50 | { |
51 | Q_OBJECT |
52 | public: |
53 | /** |
54 | * Fills a bookmark menu |
55 | * (one instance of KBookmarkMenu is created for the toplevel menu, |
56 | * but also one per submenu). |
57 | * |
58 | * @param manager the bookmark manager to use (i.e. for reading and writing) |
59 | * @param owner implementation of the KBookmarkOwner callback interface. |
60 | * @note If you pass a null KBookmarkOwner to the constructor, the |
61 | * openBookmark signal is not emitted, instead QDesktopServices::openUrl is used to open the bookmark. |
62 | * @param parentMenu menu to be filled |
63 | * @since 5.69 |
64 | */ |
65 | (KBookmarkManager *manager, KBookmarkOwner *owner, QMenu *); |
66 | |
67 | /** |
68 | * Creates a bookmark submenu |
69 | * |
70 | * @todo KF6: give ownership of the bookmarkmenu to another qobject, e.g. parentMenu. |
71 | * Currently this is a QObject without a parent, use setParent to benefit from automatic deletion. |
72 | */ |
73 | (KBookmarkManager *mgr, KBookmarkOwner *owner, QMenu *, const QString &parentAddress); |
74 | |
75 | () override; |
76 | |
77 | /** |
78 | * Call ensureUpToDate() if you need KBookmarkMenu to adjust to its |
79 | * final size before it is executed. |
80 | **/ |
81 | void (); |
82 | |
83 | /** |
84 | * Returns the action for adding a bookmark. If you are using KXmlGui, you can add it to your |
85 | * action collection. |
86 | * @code |
87 | * KBookmarkMenu *menu = new KBookmarkMenu(manager, owner, parentMenu); |
88 | * QAction *addAction = menu->addBookmarkAction(); |
89 | * actionCollection()->addAction(addAction->objectName(), addAction); |
90 | * @endcode |
91 | * @return the action for adding a bookmark. |
92 | * @since 5.69 |
93 | */ |
94 | QAction *() const; |
95 | |
96 | /** |
97 | * Returns the action for adding all current tabs as bookmarks. If you are using KXmlGui, you can |
98 | * add it to your action collection. |
99 | * @code |
100 | * KBookmarkMenu *menu = new KBookmarkMenu(manager, owner, parentMenu); |
101 | * QAction *bookmarkTabsAction = menu->bookmarkTabsAsFolderAction(); |
102 | * actionCollection()->addAction(bookmarkTabsAction->objectName(), bookmarkTabsAction); |
103 | * @endcode |
104 | * @return the action for adding all current tabs as bookmarks. |
105 | * @since 5.69 |
106 | */ |
107 | QAction *() const; |
108 | |
109 | /** |
110 | * Returns the action for adding a new bookmarks folder. If you are using KXmlGui, you can add it |
111 | * to your action collection. |
112 | * @code |
113 | * KBookmarkMenu *menu = new KBookmarkMenu(manager, owner, parentMenu); |
114 | * QAction *newBookmarkFolderAction = menu->bookmarkTabsAsFolderAction(); |
115 | * actionCollection()->addAction(newBookmarkFolderAction->objectName(), newBookmarkFolderAction); |
116 | * @endcode |
117 | * @return the action for adding a new bookmarks folder |
118 | * @since 5.70 |
119 | */ |
120 | QAction *() const; |
121 | |
122 | /** |
123 | * Returns the action for editing bookmarks. If you are using KXmlGui, you can add it to your |
124 | * action collection. |
125 | * @code |
126 | * KBookmarkMenu *menu = new KBookmarkMenu(manager, owner, parentMenu); |
127 | * QAction *editAction = menu->editBookmarksAction(); |
128 | * actionCollection()->addAction(editAction->objectName(), editAction); |
129 | * @endcode |
130 | * @return the action for editing bookmarks. |
131 | * @since 5.69 |
132 | */ |
133 | QAction *() const; |
134 | |
135 | /** |
136 | * Set this to true to make any "Edit Bookmarks" dialog |
137 | * show UI elements that are specific to browsers. |
138 | * |
139 | * @since 6.0 |
140 | */ |
141 | void (bool browserMode); |
142 | |
143 | /** |
144 | * Whether any "Edit Bookmarks" dialog shows UI elements |
145 | * that are specific to browsers. |
146 | * |
147 | * @since 6.0 |
148 | */ |
149 | bool () const; |
150 | |
151 | public Q_SLOTS: |
152 | // public for KonqBookmarkBar |
153 | void (const QString &); |
154 | |
155 | protected Q_SLOTS: |
156 | void (); |
157 | void (); |
158 | void (); |
159 | void (); |
160 | void (); |
161 | |
162 | protected: |
163 | virtual void (); |
164 | virtual void (); |
165 | virtual QAction *(const KBookmark &bm); |
166 | virtual QMenu *(QAction *action); |
167 | |
168 | void (); |
169 | void (); |
170 | void (); |
171 | void (); |
172 | void (); |
173 | void (); |
174 | void (); |
175 | |
176 | bool () const; |
177 | bool () const; |
178 | |
179 | /** |
180 | * Parent bookmark for this menu. |
181 | */ |
182 | QString () const; |
183 | |
184 | KBookmarkManager *() const; |
185 | KBookmarkOwner *() const; |
186 | /** |
187 | * The menu in which we insert our actions |
188 | * Supplied in the constructor. |
189 | */ |
190 | QMenu *() const; |
191 | |
192 | /** |
193 | * List of our sub menus |
194 | */ |
195 | QList<KBookmarkMenu *> ; |
196 | |
197 | /** |
198 | * List of our actions. |
199 | */ |
200 | QList<QAction *> ; |
201 | |
202 | private Q_SLOTS: |
203 | KBOOKMARKSWIDGETS_NO_EXPORT void (const QPoint &); |
204 | |
205 | private: |
206 | void (); |
207 | KBOOKMARKSWIDGETS_NO_EXPORT void (); |
208 | |
209 | private: |
210 | std::unique_ptr<KBookmarkMenuPrivate> const ; |
211 | }; |
212 | |
213 | #endif |
214 | |