mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-31 00:35:05 +00:00
Add X-Refs context menu item for Flags Widget (#1499)
* add xrefs for flags
This commit is contained in:
parent
089be2b87c
commit
f2cd0053a5
@ -2,6 +2,7 @@
|
||||
#include "ui_FlagsWidget.h"
|
||||
#include "core/MainWindow.h"
|
||||
#include "dialogs/RenameDialog.h"
|
||||
#include "dialogs/XrefsDialog.h"
|
||||
#include "common/Helpers.h"
|
||||
|
||||
#include <QComboBox>
|
||||
@ -149,7 +150,12 @@ FlagsWidget::FlagsWidget(MainWindow *main, QAction *action) :
|
||||
connect(ui->filterLineEdit, &QLineEdit::textChanged, this, [this] {
|
||||
tree->showItemsNumber(flags_proxy_model->rowCount());
|
||||
});
|
||||
|
||||
|
||||
auto xRefShortcut = new QShortcut(QKeySequence{Qt::CTRL + Qt::Key_X}, this);
|
||||
xRefShortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
ui->actionXrefs->setShortcut(Qt::CTRL + Qt::Key_X);
|
||||
connect(xRefShortcut, SIGNAL(activated()), this, SLOT(on_actionXrefs_triggered()));
|
||||
|
||||
setScrollMode();
|
||||
|
||||
ui->flagsTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
@ -198,11 +204,23 @@ void FlagsWidget::on_actionDelete_triggered()
|
||||
Core()->delFlag(flag.name);
|
||||
}
|
||||
|
||||
void FlagsWidget::on_actionXrefs_triggered()
|
||||
{
|
||||
FlagDescription flag = ui->flagsTreeView->selectionModel()->currentIndex().data(
|
||||
FlagsModel::FlagDescriptionRole).value<FlagDescription>();
|
||||
|
||||
XrefsDialog xresfDialog(nullptr);
|
||||
xresfDialog.fillRefsForAddress(flag.offset, RAddressString(flag.offset), false);
|
||||
xresfDialog.exec();
|
||||
}
|
||||
|
||||
void FlagsWidget::showContextMenu(const QPoint &pt)
|
||||
{
|
||||
QMenu *menu = new QMenu(ui->flagsTreeView);
|
||||
menu->addAction(ui->actionRename);
|
||||
menu->addAction(ui->actionDelete);
|
||||
menu->addSeparator();
|
||||
menu->addAction(ui->actionXrefs);
|
||||
menu->exec(ui->flagsTreeView->mapToGlobal(pt));
|
||||
delete menu;
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ private slots:
|
||||
|
||||
void on_actionRename_triggered();
|
||||
void on_actionDelete_triggered();
|
||||
void on_actionXrefs_triggered();
|
||||
|
||||
void showContextMenu(const QPoint &pt);
|
||||
|
||||
|
@ -98,11 +98,28 @@
|
||||
<property name="text">
|
||||
<string>Rename</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDelete">
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Del</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionXrefs">
|
||||
<property name="text">
|
||||
<string>X-Refs</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show X-Refs of this flag</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+X</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
Loading…
Reference in New Issue
Block a user