summaryrefslogtreecommitdiff
path: root/ui/menus.h
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2019-04-13 21:06:13 -0400
committerBrian Potchik <brian@vector35.com>2019-04-13 21:06:13 -0400
commit8487508eecef5c96848c6a273e87872a2e14a84a (patch)
tree058ba6c6d923415190ca00536c3f4d181d27c7e5 /ui/menus.h
parent6e8fb8761a627d79c26bde4e7351022f707bb6fb (diff)
Add MenuHelper for better menu behavior.
Diffstat (limited to 'ui/menus.h')
-rw-r--r--ui/menus.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/ui/menus.h b/ui/menus.h
index 0a455243..b3358304 100644
--- a/ui/menus.h
+++ b/ui/menus.h
@@ -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;
+};