diff options
| author | Glenn Smith <glenn@vector35.com> | 2024-01-15 20:49:32 -0500 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2024-02-07 17:23:52 -0500 |
| commit | 1395618054638709642086781284771929892358 (patch) | |
| tree | e4dee6144d7d68b1c32e81183c74f66aa2dd8ddf /ui/uicontext.h | |
| parent | 8037455723546000448135499957273623776581 (diff) | |
UIContext: Add plugin hook for when actions execute
Diffstat (limited to 'ui/uicontext.h')
| -rw-r--r-- | ui/uicontext.h | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/ui/uicontext.h b/ui/uicontext.h index 9d8e3377..fee474ce 100644 --- a/ui/uicontext.h +++ b/ui/uicontext.h @@ -264,6 +264,31 @@ class BINARYNINJAUIAPI UIContextNotification (void)view; (void)selection; } + + /*! + Callback when an action is executed, allowing plugins to intercept and modify + the behavior of the action. Plugins may modify the `action` parameter and + specify new behavior for the action to execute, which will happen immediately + after all registered notifications have been notified. + + The original behavior (potentially modified by another notification) can be + executed by saving a copy of the value of `action` and calling it from within + your modified value. + + \param context + \param handler + \param name + \param ctx + \param action + */ + virtual void OnActionExecuted(UIContext* context, UIActionHandler* handler, const QString& name, const UIActionContext& ctx, std::function<void(const UIActionContext&)>& action) + { + (void)context; + (void)handler; + (void)name; + (void)ctx; + (void)action; + } }; /*! @@ -295,24 +320,6 @@ class BINARYNINJAUIAPI UIContext protected: void setupUIContext(QWidget* obj); - void NotifyOnContextOpen(); - void NotifyOnContextClose(); - - bool NotifyOnBeforeOpenDatabase(FileMetadataRef metadata); - bool NotifyOnAfterOpenDatabase(FileMetadataRef metadata, BinaryViewRef data); - void NotifyOnAfterOpenProject(ProjectRef project); - bool NotifyOnBeforeOpenProjectFile(ProjectFileRef projectFile); - void NotifyOnAfterOpenProjectFile(ProjectFileRef projectFile, ViewFrame* frame); - bool NotifyOnBeforeOpenFile(FileContext* file); - void NotifyOnAfterOpenFile(FileContext* file, ViewFrame* frame); - bool NotifyOnBeforeSaveFile(FileContext* file, ViewFrame* frame); - void NotifyOnAfterSaveFile(FileContext* file, ViewFrame* frame); - bool NotifyOnBeforeCloseFile(FileContext* file, ViewFrame* frame); - void NotifyOnAfterCloseFile(FileContext* file, ViewFrame* frame); - - void NotifyOnViewChange(ViewFrame* frame, const QString& type); - void NotifyOnAddressChange(ViewFrame* frame, View* view, const ViewLocation& location); - public: UIContext(); virtual ~UIContext(); @@ -463,7 +470,25 @@ public: virtual Sidebar* sidebar() = 0; virtual GlobalArea* globalArea() = 0; + void NotifyOnContextOpen(); + void NotifyOnContextClose(); + + bool NotifyOnBeforeOpenDatabase(FileMetadataRef metadata); + bool NotifyOnAfterOpenDatabase(FileMetadataRef metadata, BinaryViewRef data); + void NotifyOnAfterOpenProject(ProjectRef project); + bool NotifyOnBeforeOpenProjectFile(ProjectFileRef projectFile); + void NotifyOnAfterOpenProjectFile(ProjectFileRef projectFile, ViewFrame* frame); + bool NotifyOnBeforeOpenFile(FileContext* file); + void NotifyOnAfterOpenFile(FileContext* file, ViewFrame* frame); + bool NotifyOnBeforeSaveFile(FileContext* file, ViewFrame* frame); + void NotifyOnAfterSaveFile(FileContext* file, ViewFrame* frame); + bool NotifyOnBeforeCloseFile(FileContext* file, ViewFrame* frame); + void NotifyOnAfterCloseFile(FileContext* file, ViewFrame* frame); + + void NotifyOnViewChange(ViewFrame* frame, const QString& type); + void NotifyOnAddressChange(ViewFrame* frame, View* view, const ViewLocation& location); void updateCrossReferences(ViewFrame* frame, View* view, const SelectionInfoForXref& selection); + void NotifyOnActionExecuted(UIActionHandler* handler, const QString& name, const UIActionContext& ctx, std::function<void(const UIActionContext&)>& action); virtual void findAll(const BinaryNinja::FindParameters& params); |
