mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 03:16:10 +00:00
Add AddressableItemContextMenu bindings (#2054)
This commit is contained in:
parent
5af4dce7f6
commit
eb88c8b21a
@ -44,7 +44,7 @@ project(Cutter VERSION "${CUTTER_VERSION_FULL}")
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
include_directories(core widgets common plugins)
|
include_directories(core widgets common plugins menus)
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
@ -87,7 +87,7 @@ win32:defined(CUTTER_DEPS_DIR, var) {
|
|||||||
!defined(PYSIDE_TYPESYSTEMS, var) PYSIDE_TYPESYSTEMS="$${CUTTER_DEPS_DIR}/pyside/share/PySide2/typesystems"
|
!defined(PYSIDE_TYPESYSTEMS, var) PYSIDE_TYPESYSTEMS="$${CUTTER_DEPS_DIR}/pyside/share/PySide2/typesystems"
|
||||||
}
|
}
|
||||||
|
|
||||||
INCLUDEPATH *= . core widgets dialogs common plugins
|
INCLUDEPATH *= . core widgets dialogs common plugins menus
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
# Generate debug symbols in release mode
|
# Generate debug symbols in release mode
|
||||||
|
@ -9,5 +9,6 @@
|
|||||||
#include "../core/MainWindow.h"
|
#include "../core/MainWindow.h"
|
||||||
#include "../widgets/CutterDockWidget.h"
|
#include "../widgets/CutterDockWidget.h"
|
||||||
#include "../plugins/CutterPlugin.h"
|
#include "../plugins/CutterPlugin.h"
|
||||||
|
#include "../menus/AddressableItemContextMenu.h"
|
||||||
|
|
||||||
#endif //CUTTER_BINDINGS_H
|
#endif //CUTTER_BINDINGS_H
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<enum-type name="ContextMenuType" />
|
<enum-type name="ContextMenuType" />
|
||||||
</object-type>
|
</object-type>
|
||||||
<object-type name="BasicBlockHighlighter" />
|
<object-type name="BasicBlockHighlighter" />
|
||||||
|
<object-type name="AddressableItemContextMenu" />
|
||||||
<object-type name="CutterDockWidget" />
|
<object-type name="CutterDockWidget" />
|
||||||
|
|
||||||
<template name="plugin_meta_get">
|
<template name="plugin_meta_get">
|
||||||
|
@ -13,31 +13,32 @@
|
|||||||
AddressableItemContextMenu::AddressableItemContextMenu(QWidget *parent, MainWindow *mainWindow)
|
AddressableItemContextMenu::AddressableItemContextMenu(QWidget *parent, MainWindow *mainWindow)
|
||||||
: QMenu(parent)
|
: QMenu(parent)
|
||||||
, mainWindow(mainWindow)
|
, mainWindow(mainWindow)
|
||||||
, actionShowInMenu(tr("Show in"), this)
|
|
||||||
, actionCopyAddress(tr("Copy address"), this)
|
|
||||||
, actionShowXrefs(tr("Show X-Refs"), this)
|
|
||||||
, actionAddcomment(tr("Add comment"), this)
|
|
||||||
{
|
{
|
||||||
connect(&actionCopyAddress, &QAction::triggered, this,
|
actionShowInMenu = new QAction(tr("Show in"), this);
|
||||||
|
actionCopyAddress = new QAction(tr("Copy address"), this);
|
||||||
|
actionShowXrefs = new QAction(tr("Show X-Refs"), this);
|
||||||
|
actionAddcomment = new QAction(tr("Add comment"), this);
|
||||||
|
|
||||||
|
connect(actionCopyAddress, &QAction::triggered, this,
|
||||||
&AddressableItemContextMenu::onActionCopyAddress);
|
&AddressableItemContextMenu::onActionCopyAddress);
|
||||||
actionCopyAddress.setShortcuts({Qt::CTRL + Qt::SHIFT + Qt::Key_C});
|
actionCopyAddress->setShortcuts({Qt::CTRL + Qt::SHIFT + Qt::Key_C});
|
||||||
actionCopyAddress.setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);
|
actionCopyAddress->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);
|
||||||
|
|
||||||
connect(&actionShowXrefs, &QAction::triggered, this,
|
connect(actionShowXrefs, &QAction::triggered, this,
|
||||||
&AddressableItemContextMenu::onActionShowXrefs);
|
&AddressableItemContextMenu::onActionShowXrefs);
|
||||||
actionShowXrefs.setShortcut({Qt::Key_X});
|
actionShowXrefs->setShortcut({Qt::Key_X});
|
||||||
actionShowXrefs.setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);
|
actionShowXrefs->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);
|
||||||
|
|
||||||
connect(&actionAddcomment, &QAction::triggered, this,
|
connect(actionAddcomment, &QAction::triggered, this,
|
||||||
&AddressableItemContextMenu::onActionAddComment);
|
&AddressableItemContextMenu::onActionAddComment);
|
||||||
actionAddcomment.setShortcut({Qt::Key_Semicolon});
|
actionAddcomment->setShortcut({Qt::Key_Semicolon});
|
||||||
actionAddcomment.setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);
|
actionAddcomment->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);
|
||||||
|
|
||||||
addAction(&actionShowInMenu);
|
addAction(actionShowInMenu);
|
||||||
addAction(&actionCopyAddress);
|
addAction(actionCopyAddress);
|
||||||
addAction(&actionShowXrefs);
|
addAction(actionShowXrefs);
|
||||||
addSeparator();
|
addSeparator();
|
||||||
addAction(&actionAddcomment);
|
addAction(actionAddcomment);
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
pluginMenu = mainWindow->getContextMenuExtensions(MainWindow::ContextMenuType::Addressable);
|
pluginMenu = mainWindow->getContextMenuExtensions(MainWindow::ContextMenuType::Addressable);
|
||||||
@ -100,10 +101,10 @@ void AddressableItemContextMenu::onActionAddComment()
|
|||||||
|
|
||||||
void AddressableItemContextMenu::aboutToShowSlot()
|
void AddressableItemContextMenu::aboutToShowSlot()
|
||||||
{
|
{
|
||||||
if (actionShowInMenu.menu()) {
|
if (actionShowInMenu->menu()) {
|
||||||
actionShowInMenu.menu()->deleteLater();
|
actionShowInMenu->menu()->deleteLater();
|
||||||
}
|
}
|
||||||
actionShowInMenu.setMenu(mainWindow->createShowInMenu(this, offset));
|
actionShowInMenu->setMenu(mainWindow->createShowInMenu(this, offset));
|
||||||
|
|
||||||
pluginMenuAction->setVisible(!pluginMenu->isEmpty());
|
pluginMenuAction->setVisible(!pluginMenu->isEmpty());
|
||||||
for (QAction *pluginAction : pluginMenu->actions()) {
|
for (QAction *pluginAction : pluginMenu->actions()) {
|
||||||
|
@ -39,10 +39,10 @@ private:
|
|||||||
bool hasTarget = false;
|
bool hasTarget = false;
|
||||||
protected:
|
protected:
|
||||||
void setHasTarget(bool hasTarget);
|
void setHasTarget(bool hasTarget);
|
||||||
QAction actionShowInMenu;
|
QAction *actionShowInMenu;
|
||||||
QAction actionCopyAddress;
|
QAction *actionCopyAddress;
|
||||||
QAction actionShowXrefs;
|
QAction *actionShowXrefs;
|
||||||
QAction actionAddcomment;
|
QAction *actionAddcomment;
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
bool wholeFunction = false;
|
bool wholeFunction = false;
|
||||||
|
@ -77,6 +77,7 @@ if get_option('enable_python')
|
|||||||
join_paths(meson.current_source_dir(), 'common'),
|
join_paths(meson.current_source_dir(), 'common'),
|
||||||
join_paths(meson.current_source_dir(), 'widgets'),
|
join_paths(meson.current_source_dir(), 'widgets'),
|
||||||
join_paths(meson.current_source_dir(), 'plugins'),
|
join_paths(meson.current_source_dir(), 'plugins'),
|
||||||
|
join_paths(meson.current_source_dir(), 'menus'),
|
||||||
join_paths(meson.current_source_dir(), 'subprojects/radare2/libr/include'),
|
join_paths(meson.current_source_dir(), 'subprojects/radare2/libr/include'),
|
||||||
join_paths(meson.current_build_dir(), 'subprojects/radare2'),
|
join_paths(meson.current_build_dir(), 'subprojects/radare2'),
|
||||||
qt5core_dep.get_pkgconfig_variable('includedir'),
|
qt5core_dep.get_pkgconfig_variable('includedir'),
|
||||||
|
Loading…
Reference in New Issue
Block a user