diff options
| author | Brian Potchik <brian@vector35.com> | 2019-04-13 21:06:13 -0400 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2019-04-13 21:06:13 -0400 |
| commit | 8487508eecef5c96848c6a273e87872a2e14a84a (patch) | |
| tree | 058ba6c6d923415190ca00536c3f4d181d27c7e5 /ui/menus.h | |
| parent | 6e8fb8761a627d79c26bde4e7351022f707bb6fb (diff) | |
Add MenuHelper for better menu behavior.
Diffstat (limited to 'ui/menus.h')
| -rw-r--r-- | ui/menus.h | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -1,12 +1,15 @@ #pragma once #include <QtCore/QPointer> +#include <QtCore/QTimer> +#include <QtWidgets/QLabel> #include <QtWidgets/QMenu> #include <QtWidgets/QWidget> #include <functional> #include <map> #include <string> #include "binaryninjaapi.h" +#include "action.h" #include "viewframe.h" class BINARYNINJAUIAPI ContextMenuManager @@ -23,3 +26,39 @@ public: MenuInstance* show(Menu* source, UIActionHandler* handler); bool isActive() { return !m_menu.isNull(); } }; + + +class BINARYNINJAUIAPI MenuHelper: public QLabel +{ + Q_OBJECT + + QPalette::ColorRole m_backgroundRole; + QPalette::ColorRole m_foregroundRole; + QPalette::ColorRole m_activeForegroundRole; + +protected: + Menu m_menu; + ContextMenuManager m_contextMenuManager; + QTimer* m_timer; + +public: + MenuHelper(QWidget* parent); + + void setBackgroundColorRole(QPalette::ColorRole role = QPalette::Highlight); + void setForegroundColorRole(QPalette::ColorRole role = QPalette::WindowText); + void setActiveForegroundColorRole(QPalette::ColorRole role = QPalette::HighlightedText); + +Q_SIGNALS: + void clicked(); + +protected Q_SLOTS: + virtual void showMenu() = 0; + +private Q_SLOTS: + void underMouseTimerEvent(); + +protected: + void enterEvent(QEvent* event) override; + void leaveEvent(QEvent* event) override; + void mouseReleaseEvent(QMouseEvent* event) override; +}; |
