No Description

neweventtoolbutton.cpp 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include "neweventtoolbutton.h"
  2. #include <QMenu>
  3. #include <QDebug>
  4. // Custom QToolButton which has a context menu that expands to allow
  5. // selection of different types of map events.
  6. NewEventToolButton::NewEventToolButton(QWidget *parent) :
  7. QToolButton(parent)
  8. {
  9. setPopupMode(QToolButton::MenuButtonPopup);
  10. QObject::connect(this, SIGNAL(triggered(QAction*)),
  11. this, SLOT(setDefaultAction(QAction*)));
  12. }
  13. void NewEventToolButton::initButton()
  14. {
  15. // Add a context menu to select different types of map events.
  16. this->newObjectAction = new QAction("New Object", this);
  17. this->newObjectAction->setIcon(QIcon(":/icons/add.ico"));
  18. connect(this->newObjectAction, SIGNAL(triggered(bool)), this, SLOT(newObject()));
  19. this->newWarpAction = new QAction("New Warp", this);
  20. this->newWarpAction->setIcon(QIcon(":/icons/add.ico"));
  21. connect(this->newWarpAction, SIGNAL(triggered(bool)), this, SLOT(newWarp()));
  22. this->newCoordScriptAction = new QAction("New Coord Script", this);
  23. this->newCoordScriptAction->setIcon(QIcon(":/icons/add.ico"));
  24. connect(this->newCoordScriptAction, SIGNAL(triggered(bool)), this, SLOT(newCoordScript()));
  25. this->newCoordWeatherAction = new QAction("New Coord Weather", this);
  26. this->newCoordWeatherAction->setIcon(QIcon(":/icons/add.ico"));
  27. connect(this->newCoordWeatherAction, SIGNAL(triggered(bool)), this, SLOT(newCoordWeather()));
  28. this->newSignAction = new QAction("New Sign", this);
  29. this->newSignAction->setIcon(QIcon(":/icons/add.ico"));
  30. connect(this->newSignAction, SIGNAL(triggered(bool)), this, SLOT(newSign()));
  31. this->newHiddenItemAction = new QAction("New Hidden Item", this);
  32. this->newHiddenItemAction->setIcon(QIcon(":/icons/add.ico"));
  33. connect(this->newHiddenItemAction, SIGNAL(triggered(bool)), this, SLOT(newHiddenItem()));
  34. this->newSecretBaseAction = new QAction("New Secret Base", this);
  35. this->newSecretBaseAction->setIcon(QIcon(":/icons/add.ico"));
  36. connect(this->newSecretBaseAction, SIGNAL(triggered(bool)), this, SLOT(newSecretBase()));
  37. QMenu *alignMenu = new QMenu();
  38. alignMenu->addAction(this->newObjectAction);
  39. alignMenu->addAction(this->newWarpAction);
  40. alignMenu->addAction(this->newCoordScriptAction);
  41. alignMenu->addAction(this->newCoordWeatherAction);
  42. alignMenu->addAction(this->newSignAction);
  43. alignMenu->addAction(this->newHiddenItemAction);
  44. alignMenu->addAction(this->newSecretBaseAction);
  45. this->setMenu(alignMenu);
  46. this->setDefaultAction(this->newObjectAction);
  47. }
  48. QString NewEventToolButton::getSelectedEventType()
  49. {
  50. return this->selectedEventType;
  51. }
  52. void NewEventToolButton::newObject()
  53. {
  54. this->selectedEventType = EventType::Object;
  55. emit newEventAdded(this->selectedEventType);
  56. }
  57. void NewEventToolButton::newWarp()
  58. {
  59. this->selectedEventType = EventType::Warp;
  60. emit newEventAdded(this->selectedEventType);
  61. }
  62. void NewEventToolButton::newCoordScript()
  63. {
  64. this->selectedEventType = EventType::CoordScript;
  65. emit newEventAdded(this->selectedEventType);
  66. }
  67. void NewEventToolButton::newCoordWeather()
  68. {
  69. this->selectedEventType = EventType::CoordWeather;
  70. emit newEventAdded(this->selectedEventType);
  71. }
  72. void NewEventToolButton::newSign()
  73. {
  74. this->selectedEventType = EventType::Sign;
  75. emit newEventAdded(this->selectedEventType);
  76. }
  77. void NewEventToolButton::newHiddenItem()
  78. {
  79. this->selectedEventType = EventType::HiddenItem;
  80. emit newEventAdded(this->selectedEventType);
  81. }
  82. void NewEventToolButton::newSecretBase()
  83. {
  84. this->selectedEventType = EventType::SecretBase;
  85. emit newEventAdded(this->selectedEventType);
  86. }