mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 11:26:11 +00:00
Created adding comments option inside Hexdump. (#2927)
This commit is contained in:
parent
7d42a5c7e6
commit
6fca09d313
@ -2,6 +2,7 @@
|
|||||||
#include "Cutter.h"
|
#include "Cutter.h"
|
||||||
#include "Configuration.h"
|
#include "Configuration.h"
|
||||||
#include "dialogs/WriteCommandsDialogs.h"
|
#include "dialogs/WriteCommandsDialogs.h"
|
||||||
|
#include "dialogs/CommentsDialog.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
@ -120,6 +121,19 @@ HexWidget::HexWidget(QWidget *parent)
|
|||||||
connect(actionCopyAddress, &QAction::triggered, this, &HexWidget::copyAddress);
|
connect(actionCopyAddress, &QAction::triggered, this, &HexWidget::copyAddress);
|
||||||
addAction(actionCopyAddress);
|
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);
|
actionSelectRange = new QAction(tr("Select range"), this);
|
||||||
connect(actionSelectRange, &QAction::triggered, this,
|
connect(actionSelectRange, &QAction::triggered, this,
|
||||||
[this]() { rangeDialog.open(cursor.address); });
|
[this]() { rangeDialog.open(cursor.address); });
|
||||||
@ -620,6 +634,16 @@ void HexWidget::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
actionCopyAddress->setDisabled(disable);
|
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 *menu = new QMenu();
|
||||||
QMenu *sizeMenu = menu->addMenu(tr("Item size:"));
|
QMenu *sizeMenu = menu->addMenu(tr("Item size:"));
|
||||||
sizeMenu->addActions(actionsItemSize);
|
sizeMenu->addActions(actionsItemSize);
|
||||||
@ -689,6 +713,20 @@ void HexWidget::copyAddress()
|
|||||||
clipboard->setText(RzAddressString(addr));
|
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()
|
void HexWidget::onRangeDialogAccepted()
|
||||||
{
|
{
|
||||||
if (rangeDialog.empty()) {
|
if (rangeDialog.empty()) {
|
||||||
|
@ -311,6 +311,8 @@ private slots:
|
|||||||
void copy();
|
void copy();
|
||||||
void copyAddress();
|
void copyAddress();
|
||||||
void onRangeDialogAccepted();
|
void onRangeDialogAccepted();
|
||||||
|
void on_actionAddComment_triggered();
|
||||||
|
void on_actionDeleteComment_triggered();
|
||||||
|
|
||||||
// Write command slots
|
// Write command slots
|
||||||
void w_writeString();
|
void w_writeString();
|
||||||
@ -475,6 +477,9 @@ private:
|
|||||||
QAction *actionHexPairs;
|
QAction *actionHexPairs;
|
||||||
QAction *actionCopy;
|
QAction *actionCopy;
|
||||||
QAction *actionCopyAddress;
|
QAction *actionCopyAddress;
|
||||||
|
QAction *actionComment;
|
||||||
|
QAction *actionDeleteComment;
|
||||||
|
QAction *actionSetFlag;
|
||||||
QAction *actionSelectRange;
|
QAction *actionSelectRange;
|
||||||
QList<QAction *> actionsWriteString;
|
QList<QAction *> actionsWriteString;
|
||||||
QList<QAction *> actionsWriteOther;
|
QList<QAction *> actionsWriteOther;
|
||||||
|
Loading…
Reference in New Issue
Block a user