File indexing completed on 2024-12-01 04:37:14
0001 /* 0002 smb4kbookmarkmenu - Bookmark menu 0003 0004 SPDX-FileCopyrightText: 2011-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef SMB4KBOOKMARKMENU_H 0009 #define SMB4KBOOKMARKMENU_H 0010 0011 // application specific includes 0012 #include "smb4kbookmarkeditor.h" 0013 #include "smb4kglobal.h" 0014 0015 // Qt includes 0016 #include <QAction> 0017 #include <QActionGroup> 0018 #include <QPointer> 0019 0020 // KDE includes 0021 #include <KActionMenu> 0022 0023 // forward declarations 0024 class Smb4KBookmark; 0025 0026 class Smb4KBookmarkMenu : public KActionMenu 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 /** 0032 * Enumeration 0033 */ 0034 enum Type { MainWindow, SystemTray }; 0035 0036 /** 0037 * Constructor 0038 */ 0039 explicit Smb4KBookmarkMenu(int type, QObject *parent = nullptr); 0040 0041 /** 0042 * Destructor 0043 */ 0044 ~Smb4KBookmarkMenu(); 0045 0046 /** 0047 * Refresh the menu 0048 */ 0049 void refreshMenu(); 0050 0051 /** 0052 * Enable/disable the 'Add Bookmark' action 0053 */ 0054 void setBookmarkActionEnabled(bool enable); 0055 0056 public Q_SLOTS: 0057 /** 0058 * Load the bookmarks into the menu 0059 */ 0060 void loadBookmarks(); 0061 0062 Q_SIGNALS: 0063 /** 0064 * This signal is emitted when the 'Add Bookmark' is triggered. 0065 */ 0066 void addBookmark(); 0067 0068 protected Q_SLOTS: 0069 /** 0070 * Called when the edit action is triggered 0071 */ 0072 void slotEditActionTriggered(bool checked); 0073 0074 /** 0075 * Called when the add action is triggered 0076 */ 0077 void slotAddActionTriggered(bool checked); 0078 0079 /** 0080 * Called when a mount action was triggered 0081 */ 0082 void slotMountActionTriggered(QAction *action); 0083 0084 /** 0085 * Called when a bookmark action is triggered 0086 */ 0087 void slotBookmarkActionTriggered(QAction *action); 0088 0089 /** 0090 * Called when a bookmark was unmounted 0091 */ 0092 void slotEnableBookmark(const SharePtr &share); 0093 0094 private: 0095 /** 0096 * Enables or disables the mount actions according to the status 0097 * of the bookmarks in their respective category. 0098 */ 0099 void adjustMountActions(); 0100 0101 /** 0102 * The actions 0103 */ 0104 QActionGroup *m_mountActions; 0105 0106 /** 0107 * The categories 0108 */ 0109 QActionGroup *m_categories; 0110 0111 /** 0112 * The bookmarks 0113 */ 0114 QActionGroup *m_bookmarks; 0115 0116 /** 0117 * The 'Edit Bookmarks' action 0118 */ 0119 QAction *m_editBookmarks; 0120 0121 /** 0122 * The "Add Bookmark" action 0123 */ 0124 QAction *m_addBookmark; 0125 0126 /** 0127 * The toplevel "Mount All Bookmarks" action 0128 */ 0129 QAction *m_toplevelMount; 0130 0131 /** 0132 * The separator between the actions and the bookmarks 0133 */ 0134 QAction *m_separator; 0135 }; 0136 0137 #endif