contextmenu.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include "contextmenu.h"
  2. #include <QShortcut>
  3. ContextMenu::ContextMenu(QWidget *parent) :
  4. QMenu(parent)
  5. {
  6. //Context menu
  7. open = new QAction(tr("Open"), this);
  8. addAction(open);
  9. connect(open, SIGNAL(triggered()), this, SIGNAL(openTriggered()));
  10. addSeparator();
  11. cut = new QAction(tr("Cut"), this);
  12. addAction(cut);
  13. connect(cut, SIGNAL(triggered()), this, SIGNAL(cutTriggered()));
  14. copy = new QAction(tr("Copy"), this);
  15. addAction(copy);
  16. connect(copy, SIGNAL(triggered()), this,SIGNAL(copyTriggered()));
  17. paste = new QAction(tr("Paste"), this);
  18. addAction(paste);
  19. paste->setDisabled(true);
  20. connect(paste, SIGNAL(triggered()), this, SIGNAL(pasteTriggered()));
  21. addSeparator();
  22. del = new QAction(tr("Delete"), this);
  23. addAction(del);
  24. connect(del, SIGNAL(triggered()), this, SIGNAL(deleteTriggered()));;
  25. rename = new QAction(tr("Rename"), this);
  26. addAction(rename);
  27. connect(rename, SIGNAL(triggered()), this,SIGNAL(renameTriggered()));
  28. addSeparator();
  29. fbNewMenu=new QMenu(tr("New"));
  30. addFolder = new QAction(tr("Folder"), this);
  31. connect(addFolder,SIGNAL(triggered()),this,SIGNAL(createFolderTriggered()));
  32. fbNewMenu->addAction(addFolder);
  33. addMenu(fbNewMenu);
  34. }
  35. void ContextMenu::addContextMenuAction(QAction *action){
  36. addAction(action);
  37. }
  38. void ContextMenu::addContextMenuMenu(QMenu *menu){
  39. addMenu(menu);
  40. }
  41. void ContextMenu::addContextMenuSeparator(){
  42. addSeparator();
  43. }
  44. void ContextMenu::removeFromContextMenu(QAction *action){
  45. removeAction(action);
  46. }
  47. QList <QAction *> ContextMenu::contextMenuActions(){
  48. return actions();
  49. }
  50. void ContextMenu::setNewFolderEnabled(bool enabled){
  51. addFolder->setEnabled(enabled);
  52. }
  53. void ContextMenu::setPasteEnabled(bool enabled){
  54. paste->setEnabled(enabled);
  55. }
  56. void ContextMenu::setDeleteEnabled(bool enabled){
  57. del->setEnabled(enabled);
  58. }
  59. void ContextMenu::setRenameEnabled(bool enabled){
  60. rename->setEnabled(enabled);
  61. }
  62. void ContextMenu::setOpenEnabled(bool enabled){
  63. open->setEnabled(enabled);
  64. }