File indexing completed on 2024-04-21 05:51:21
0001 /* This file was part of the KDE libraries 0002 0003 SPDX-FileCopyrightText: 2002 Carsten Pfeiffer <pfeiffer@kde.org> 0004 SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 // Born as kdelibs/kio/kfile/kfilebookmarkhandler.h 0010 0011 #ifndef BOOKMARKHANDLER_H 0012 #define BOOKMARKHANDLER_H 0013 0014 // KDE 0015 #include <KBookmarkManager> 0016 #include <KBookmarkOwner> 0017 0018 // Konsole 0019 #include "ViewProperties.h" 0020 #include "konsoleprivate_export.h" 0021 0022 class QMenu; 0023 class QUrl; 0024 class KActionCollection; 0025 0026 namespace Konsole 0027 { 0028 0029 /** 0030 * This class handles the communication between the bookmark menu and the active session, 0031 * providing a suggested title and URL when the user clicks the "Add Bookmark" item in 0032 * the bookmarks menu. 0033 * 0034 * The bookmark handler is associated with a session controller, which is used to 0035 * determine the working URL of the current session. When the user changes the active 0036 * view, the bookmark handler's controller should be changed using setController() 0037 * 0038 * When the user selects a bookmark, the openUrl() signal is emitted. 0039 */ 0040 class KONSOLEPRIVATE_EXPORT BookmarkHandler : public QObject, public KBookmarkOwner 0041 { 0042 Q_OBJECT 0043 0044 public: 0045 /** 0046 * Constructs a new bookmark handler for Konsole bookmarks. 0047 * 0048 * @param collection The collection which the bookmark menu's actions should be added to 0049 * @param menu The menu which the bookmark actions should be added to 0050 * @param toplevel TODO: Document me 0051 * @param parent The parent object 0052 */ 0053 BookmarkHandler(KActionCollection *collection, QMenu *menu, bool toplevel, QObject *parent); 0054 ~BookmarkHandler() override; 0055 0056 QUrl currentUrl() const override; 0057 QString currentTitle() const override; 0058 QString currentIcon() const override; 0059 bool enableOption(BookmarkOption option) const override; 0060 bool supportsTabs() const override; 0061 QList<KBookmarkOwner::FutureBookmark> currentBookmarkList() const override; 0062 void openFolderinTabs(const KBookmarkGroup &group) override; 0063 0064 /** 0065 * Returns the menu which this bookmark handler inserts its actions into. 0066 */ 0067 QMenu *menu() const 0068 { 0069 return _menu; 0070 } 0071 0072 QList<ViewProperties *> views() const; 0073 ViewProperties *activeView() const; 0074 0075 public Q_SLOTS: 0076 /** 0077 * 0078 */ 0079 void setViews(const QList<ViewProperties *> &views); 0080 0081 void setActiveView(ViewProperties *view); 0082 0083 Q_SIGNALS: 0084 /** 0085 * Emitted when the user selects a bookmark from the bookmark menu. 0086 * 0087 * @param url The url of the bookmark which was selected by the user. 0088 */ 0089 void openUrl(const QUrl &url); 0090 0091 /** 0092 * Emitted when the user selects 'Open Folder in Tabs' 0093 * from the bookmark menu. 0094 * 0095 * @param urls The urls of the bookmarks in the folder whose 0096 * 'Open Folder in Tabs' action was triggered 0097 */ 0098 void openUrls(const QList<QUrl> &urls); 0099 0100 private Q_SLOTS: 0101 void openBookmark(const KBookmark &bm, Qt::MouseButtons, Qt::KeyboardModifiers) override; 0102 0103 private: 0104 Q_DISABLE_COPY(BookmarkHandler) 0105 0106 QString titleForView(ViewProperties *view) const; 0107 QUrl urlForView(ViewProperties *view) const; 0108 QString iconForView(ViewProperties *view) const; 0109 0110 QMenu *_menu; 0111 QString _file; 0112 bool _toplevel; 0113 ViewProperties *_activeView; 0114 QList<ViewProperties *> _views; 0115 }; 0116 } 0117 0118 #endif // BOOKMARKHANDLER_H