mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 10:56:11 +00:00
Created adding comments option inside Hexdump. (#2927)
This commit is contained in:
parent
de5c1a5154
commit
d2243006e2
@ -2,6 +2,7 @@
|
||||
#include "Cutter.h"
|
||||
#include "Configuration.h"
|
||||
#include "dialogs/WriteCommandsDialogs.h"
|
||||
#include "dialogs/CommentsDialog.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
@ -120,6 +121,19 @@ HexWidget::HexWidget(QWidget *parent)
|
||||
connect(actionCopyAddress, &QAction::triggered, this, &HexWidget::copyAddress);
|
||||
addAction(actionCopyAddress);
|
||||
|
||||
// Add comment option
|
||||
actionComment = new QAction(tr("Add Comment"), this);
|
||||
actionComment->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);
|
||||
actionComment->setShortcut(Qt::Key_Semicolon);
|
||||
connect(actionComment, &QAction::triggered, this, &HexWidget::on_actionAddComment_triggered);
|
||||
addAction(actionComment);
|
||||
|
||||
// delete comment option
|
||||
actionDeleteComment = new QAction(tr("Delete Comment"), this);
|
||||
actionDeleteComment->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);
|
||||
connect(actionDeleteComment, &QAction::triggered, this, &HexWidget::on_actionDeleteComment_triggered);
|
||||
addAction(actionDeleteComment);
|
||||
|
||||
actionSelectRange = new QAction(tr("Select range"), this);
|
||||
connect(actionSelectRange, &QAction::triggered, this,
|
||||
[this]() { rangeDialog.open(cursor.address); });
|
||||
@ -620,6 +634,16 @@ void HexWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
actionCopyAddress->setDisabled(disable);
|
||||
};
|
||||
|
||||
QString comment = Core()->getCommentAt(cursor.address);
|
||||
|
||||
if (comment.isNull() || comment.isEmpty()) {
|
||||
actionDeleteComment->setVisible(false);
|
||||
actionComment->setText(tr("Add Comment"));
|
||||
} else {
|
||||
actionDeleteComment->setVisible(true);
|
||||
actionComment->setText(tr("Edit Comment"));
|
||||
}
|
||||
|
||||
QMenu *menu = new QMenu();
|
||||
QMenu *sizeMenu = menu->addMenu(tr("Item size:"));
|
||||
sizeMenu->addActions(actionsItemSize);
|
||||
@ -689,6 +713,20 @@ void HexWidget::copyAddress()
|
||||
clipboard->setText(RzAddressString(addr));
|
||||
}
|
||||
|
||||
//slot for add comment action
|
||||
void HexWidget::on_actionAddComment_triggered()
|
||||
{
|
||||
uint64_t addr = cursor.address;
|
||||
CommentsDialog::addOrEditComment(addr, this);
|
||||
}
|
||||
|
||||
//slot for deleting comment action
|
||||
void HexWidget::on_actionDeleteComment_triggered()
|
||||
{
|
||||
uint64_t addr = cursor.address;
|
||||
Core()->delComment(addr);
|
||||
}
|
||||
|
||||
void HexWidget::onRangeDialogAccepted()
|
||||
{
|
||||
if (rangeDialog.empty()) {
|
||||
|
@ -311,6 +311,8 @@ private slots:
|
||||
void copy();
|
||||
void copyAddress();
|
||||
void onRangeDialogAccepted();
|
||||
void on_actionAddComment_triggered();
|
||||
void on_actionDeleteComment_triggered();
|
||||
|
||||
// Write command slots
|
||||
void w_writeString();
|
||||
@ -475,6 +477,9 @@ private:
|
||||
QAction *actionHexPairs;
|
||||
QAction *actionCopy;
|
||||
QAction *actionCopyAddress;
|
||||
QAction *actionComment;
|
||||
QAction *actionDeleteComment;
|
||||
QAction *actionSetFlag;
|
||||
QAction *actionSelectRange;
|
||||
QList<QAction *> actionsWriteString;
|
||||
QList<QAction *> actionsWriteOther;
|
||||
|
Loading…
Reference in New Issue
Block a user