diff --git a/pipeviz.pri b/pipeviz.pri index 6a447ae..63c85ab 100644 --- a/pipeviz.pri +++ b/pipeviz.pri @@ -28,7 +28,8 @@ HEADERS += src/PluginsList.h \ src/PadProperties.h \ src/PipelineIE.h \ src/CustomSettings.h \ - src/SeekSlider.h + src/SeekSlider.h \ + src/CustomMenuAction.h SOURCES += src/main.cpp \ src/PluginsList.cpp \ @@ -39,4 +40,5 @@ SOURCES += src/main.cpp \ src/PadProperties.cpp \ src/PipelineIE.cpp \ src/CustomSettings.cpp \ - src/SeekSlider.cpp + src/SeekSlider.cpp \ + src/CustomMenuAction.cpp diff --git a/src/CustomMenuAction.cpp b/src/CustomMenuAction.cpp new file mode 100644 index 0000000..6f4e1e2 --- /dev/null +++ b/src/CustomMenuAction.cpp @@ -0,0 +1,13 @@ +#include "CustomMenuAction.h" + +CustomMenuAction::CustomMenuAction(const QString& displayName, QObject * parent) +:QAction(displayName, parent) +, m_name(displayName) +{ +} + +CustomMenuAction::CustomMenuAction(const QString& displayName, const QString& name, QObject * parent) +:QAction(displayName, parent) +, m_name(name) +{ +} diff --git a/src/CustomMenuAction.h b/src/CustomMenuAction.h new file mode 100644 index 0000000..f230f49 --- /dev/null +++ b/src/CustomMenuAction.h @@ -0,0 +1,22 @@ +#ifndef CUSTOM_MENU_ACTION_H_ +#define CUSTOM_MENU_ACTION_H_ + + +#include + +class CustomMenuAction: public QAction +{ +public: + CustomMenuAction(const QString& displayName, QObject * parent); + + CustomMenuAction(const QString& displayName, const QString& name, QObject * parent); + + QString getName() { return m_name;} + +private: + QString m_name; +}; + + + +#endif //CUSTOM_MENU_ACTION_H_ diff --git a/src/GraphDisplay.cpp b/src/GraphDisplay.cpp index 74fa345..e2a7398 100644 --- a/src/GraphDisplay.cpp +++ b/src/GraphDisplay.cpp @@ -15,6 +15,7 @@ #include "ElementProperties.h" #include "PadProperties.h" +#include "CustomMenuAction.h" #define PAD_SIZE 8 #define PAD_SIZE_ACTION 16 @@ -542,22 +543,25 @@ void GraphDisplay::showContextMenu(QMouseEvent *event) if(selectedCount > 1) { - QAction *pact = menu.addAction("Remove selected"); + CustomMenuAction *pact = new CustomMenuAction("Remove selected", &menu); + menu.addAction(pact); if(isActive) pact -> setDisabled(true); } else if(padId != ((size_t)-1)) - menu.addAction("Pad properties"); + menu.addAction(new CustomMenuAction("Pad properties", &menu)); else if(elementId != ((size_t)-1)) { - menu.addAction("Element properties"); - QAction *pact = menu.addAction("Remove"); + menu.addAction(new CustomMenuAction("Element properties", &menu)); + QAction *pact = new CustomMenuAction("Remove", &menu); + menu.addAction(pact); if(isActive) pact -> setDisabled(true); - pact = menu.addAction("Request pad..."); + pact = new CustomMenuAction("Request pad...", &menu); + menu.addAction(pact); } else { @@ -595,7 +599,9 @@ void GraphDisplay::showContextMenu(QMouseEvent *event) elementId = m_info[i].m_id; padId = m_info[i].m_pads[j].m_id; - QAction *pact = menu.addAction("Disconnect"); + QAction *pact = new CustomMenuAction("Disconnect", &menu); + menu.addAction(pact); + if(isActive) pact -> setDisabled(true); @@ -610,20 +616,20 @@ void GraphDisplay::showContextMenu(QMouseEvent *event) if(!menu.isEmpty()) { - QAction *pact = menu.exec(event -> globalPos()); + CustomMenuAction *pact = (CustomMenuAction*)menu.exec(event -> globalPos()); if(pact) { - if(pact -> text() == "Remove") + if(pact -> getName() == "Remove") removePlugin(elementId); - else if(pact -> text() == "Element properties") + else if(pact -> getName() == "Element properties") showElementProperties(elementId); - else if(pact -> text() == "Pad properties") + else if(pact -> getName() == "Pad properties") showPadProperties(elementId, padId); - else if(pact -> text() == "Disconnect") + else if(pact -> getName() == "Disconnect") disconnect(elementId, padId); - else if(pact -> text() == "Request pad...") + else if(pact -> getName() == "Request pad...") requestPad(elementId); - else if(pact -> text() == "Remove selected") + else if(pact -> getName() == "Remove selected") removeSelected(); } }