contextmenu.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef CONTEXTMENU_H
  2. #define CONTEXTMENU_H
  3. #include <QMenu>
  4. /*! \class ContextMenu
  5. \brief Sets the contextual menu of files in the file browser
  6. BrowserButtons class is used for configuring the contextual menu of files in the file browse. By default some basic actions
  7. are added (like open, copy, cut, paste...) but is also possible to add custom actions and remove the predefined ones
  8. */
  9. class ContextMenu : public QMenu
  10. {
  11. Q_OBJECT
  12. public:
  13. //! Class constructor
  14. /*!
  15. This function adds default actions to the context menu
  16. */
  17. explicit ContextMenu(QWidget *parent = 0);
  18. //! Adds an action to the conext menu
  19. /*!
  20. Adds a custom action to the conext menu of files in the file browser
  21. \param action Action to be added to the context menu
  22. */
  23. void addContextMenuAction(QAction *action);
  24. //! Adds a menu to the conext menu
  25. /*!
  26. Adds a custom menu to the conext menu of files in the file browser
  27. \param menu Menu to be added to the context menu
  28. */
  29. void addContextMenuMenu(QMenu *menu);
  30. //! Adds a separator to the conext menu
  31. /*!
  32. Adds a separator to the conext menu of files in the file browser
  33. */
  34. void addContextMenuSeparator();
  35. //! Removes an action from the conext menu
  36. /*!
  37. Removes an action from the conext menu of files in the file browser
  38. \param action Action to be removed from the context menu
  39. */
  40. void removeFromContextMenu(QAction *action);
  41. //! Returns context menu's list of actions
  42. /*!
  43. Returns a list with the context menu actions
  44. */
  45. QList <QAction *> contextMenuActions();
  46. //! Enables/disables New Folder option in the context menu
  47. /*!
  48. Enables/disables New Folder option in the context menu. Normally is enabled when the selected file (current index of the data model) is a directory
  49. */
  50. void setNewFolderEnabled(bool);
  51. //! Enables/disables Paste option in the context menu
  52. /*!
  53. Enables/disables Paste option in the context menu. Normally is enabled when there is something in the clipboard
  54. and disabled after pasting the content
  55. */
  56. void setPasteEnabled(bool);
  57. //! Enables/disables Delete option in the context menu
  58. /*!
  59. Enables/disables Delete option in the context menu.
  60. */
  61. void setDeleteEnabled(bool);
  62. //! Enables/disables Rename option in the context menu
  63. /*!
  64. Enables/disables Rename option in the context menu.
  65. */
  66. void setRenameEnabled(bool);
  67. //! Enables/disables Open option in the context menu
  68. /*!
  69. Enables/disables Open option in the context menu.
  70. */
  71. void setOpenEnabled(bool);
  72. private:
  73. //! New menu within the context menu. Includes actions like cretion of folders
  74. QMenu *fbNewMenu;
  75. //! Action for opening a file or directory
  76. QAction *open;
  77. //! Action for deleting a file or directory
  78. QAction *del;
  79. //! Action for copying a file or directory
  80. QAction *copy;
  81. //! Action for cutting a file or directory
  82. QAction *cut;
  83. //! Action for pasting a file or directory
  84. QAction *paste;
  85. //! Action for renaming a file or directory
  86. QAction *rename;
  87. //! Action for creating a directory
  88. QAction *addFolder;
  89. signals:
  90. //! This signal is emitted when the open menu option is triggered
  91. void openTriggered();
  92. //! This signal is emitted when the copy menu option is triggered
  93. void copyTriggered();
  94. //! This signal is emitted when the cut menu option is triggered
  95. void cutTriggered();
  96. //! This signal is emitted when the paste menu option is triggered
  97. void pasteTriggered();
  98. //! This signal is emitted when the delete menu option is triggered
  99. void deleteTriggered();
  100. //! This signal is emitted when the rename menu option is triggered
  101. void renameTriggered();
  102. //! This signal is emitted when the New Folder menu option is triggered
  103. void createFolderTriggered();
  104. public slots:
  105. };
  106. #endif // CONTEXTMENU_H