forked from wingsummer/WingHexExplorer
增加遗漏的书签相关功能
This commit is contained in:
parent
61e361cd24
commit
bfa09e6cfb
|
@ -22,6 +22,14 @@
|
|||
|神末shenmo|打赏捐助|Deepin 论坛|
|
||||
|lv36|打赏捐助|Deepin 论坛|
|
||||
|
||||
## 代码贡献者
|
||||
|
||||
  维护一个好用的工具并不是一个人能做到了,更重要的是大家共同维护,如下是对本仓库代码有贡献的同志,特此感谢:
|
||||
|
||||
|昵称|贡献|
|
||||
|:--:|:--:|
|
||||
|神末shenmo|修复 ubuntu 下的显示问题|
|
||||
|
||||
## WingHexExplorer
|
||||
|
||||
  本软件是基于 QT 编写的十六进制编辑器,采用 C++ 进行开发,目的是让 Deepin 上具有强大而免费的十六进制编辑器。目前只有 010 Editor 具有强大的十六进制编辑功能,但它是商用的。关注我开发动态的应该知道我开发了在 Windows 上用 C# 开发的`WingSummer.WingCloudHexExplorer`,目的是方便专业人士修改分析 PE 文件,并可作为学习 PE 结构的重要辅助工具。该项目具有 31 个 Star 和 9 个 Fork ,我也不打算维护了,因为我主力系统不是 Windows ,也没有充分的资金支持,全是本人的一腔热血和一厢情愿。没有任何人参与该仓库任何形式的贡献,这或许就是在中国个人搞开源的现状吧。
|
||||
|
|
|
@ -18,7 +18,12 @@ HEADERS += $$PWD/document/commands/hexcommand.h \
|
|||
$$PWD/document/commands/metaremovecommand.h \
|
||||
$$PWD/document/commands/metareplacecommand.h \
|
||||
$$PWD/document/commands/metaclearcommand.h \
|
||||
$$PWD/document/commands/metaremoveposcommand.h
|
||||
$$PWD/document/commands/metaremoveposcommand.h \
|
||||
$$PWD/document/commands/bookmarkcommand.h \
|
||||
$$PWD/document/commands/bookmarkaddcommand.h \
|
||||
$$PWD/document/commands/bookmarkremovecommand.h \
|
||||
$$PWD/document/commands/bookmarkreplacecommand.h \
|
||||
$$PWD/document/commands/bookmarkclearcommand.h
|
||||
|
||||
SOURCES += $$PWD/document/commands/hexcommand.cpp \
|
||||
$$PWD/document/commands/insertcommand.cpp \
|
||||
|
@ -38,6 +43,11 @@ SOURCES += $$PWD/document/commands/hexcommand.cpp \
|
|||
$$PWD/document/commands/metaremovecommand.cpp \
|
||||
$$PWD/document/commands/metareplacecommand.cpp \
|
||||
$$PWD/document/commands/metaclearcommand.cpp \
|
||||
$$PWD/document/commands/metaremoveposcommand.cpp
|
||||
$$PWD/document/commands/metaremoveposcommand.cpp \
|
||||
$$PWD/document/commands/bookmarkcommand.cpp \
|
||||
$$PWD/document/commands/bookmarkaddcommand.cpp \
|
||||
$$PWD/document/commands/bookmarkremovecommand.cpp \
|
||||
$$PWD/document/commands/bookmarkreplacecommand.cpp \
|
||||
$$PWD/document/commands/bookmarkclearcommand.cpp
|
||||
|
||||
INCLUDEPATH += $$PWD
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#include "bookmarkaddcommand.h"
|
||||
|
||||
BookMarkAddCommand::BookMarkAddCommand(QHexDocument *doc, qint64 pos,
|
||||
QString comment, QUndoCommand *parent)
|
||||
: BookMarkCommand(doc, pos, comment, parent) {}
|
||||
|
||||
void BookMarkAddCommand::redo() { m_doc->addBookMark(m_pos, m_comment); }
|
||||
|
||||
void BookMarkAddCommand::undo() { m_doc->RemoveBookMark(m_pos); }
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef BOOKMARKADDCOMMAND_H
|
||||
#define BOOKMARKADDCOMMAND_H
|
||||
|
||||
#include "bookmarkcommand.h"
|
||||
|
||||
class BookMarkAddCommand : public BookMarkCommand {
|
||||
public:
|
||||
BookMarkAddCommand(QHexDocument *doc, qint64 pos, QString comment,
|
||||
QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
};
|
||||
|
||||
#endif // BOOKMARKADDCOMMAND_H
|
|
@ -0,0 +1,10 @@
|
|||
#include "bookmarkclearcommand.h"
|
||||
|
||||
BookMarkClearCommand::BookMarkClearCommand(QHexDocument *doc,
|
||||
QList<BookMarkStruct> bookmarks,
|
||||
QUndoCommand *parent)
|
||||
: QUndoCommand(parent), m_doc(doc), m_bookmarks(bookmarks) {}
|
||||
|
||||
void BookMarkClearCommand::redo() { m_doc->clearBookMark(); }
|
||||
|
||||
void BookMarkClearCommand::undo() { m_doc->applyBookMarks(m_bookmarks); }
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef BOOKMARKCLEARCOMMAND_H
|
||||
#define BOOKMARKCLEARCOMMAND_H
|
||||
|
||||
#include "document/qhexdocument.h"
|
||||
#include <QObject>
|
||||
#include <QUndoCommand>
|
||||
|
||||
class BookMarkClearCommand : public QUndoCommand {
|
||||
public:
|
||||
BookMarkClearCommand(QHexDocument *doc, QList<BookMarkStruct> bookmarks,
|
||||
QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
protected:
|
||||
QHexDocument *m_doc;
|
||||
QList<BookMarkStruct> m_bookmarks;
|
||||
};
|
||||
|
||||
#endif // BOOKMARKCLEARCOMMAND_H
|
|
@ -0,0 +1,5 @@
|
|||
#include "bookmarkcommand.h"
|
||||
|
||||
BookMarkCommand::BookMarkCommand(QHexDocument *doc, qint64 pos, QString comment,
|
||||
QUndoCommand *parent)
|
||||
: QUndoCommand(parent), m_doc(doc), m_comment(comment), m_pos(pos) {}
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef BOOKMARKCOMMAND_H
|
||||
#define BOOKMARKCOMMAND_H
|
||||
|
||||
#include "document/qhexdocument.h"
|
||||
#include <QObject>
|
||||
#include <QUndoCommand>
|
||||
|
||||
class BookMarkCommand : public QUndoCommand {
|
||||
public:
|
||||
BookMarkCommand(QHexDocument *doc, qint64 pos, QString comment,
|
||||
QUndoCommand *parent = nullptr);
|
||||
|
||||
protected:
|
||||
QHexDocument *m_doc;
|
||||
QString m_comment;
|
||||
qint64 m_pos;
|
||||
};
|
||||
|
||||
#endif // BOOKMARKCOMMAND_H
|
|
@ -0,0 +1,10 @@
|
|||
#include "bookmarkremovecommand.h"
|
||||
|
||||
BookMarkRemoveCommand::BookMarkRemoveCommand(QHexDocument *doc, qint64 pos,
|
||||
QString comment,
|
||||
QUndoCommand *parent)
|
||||
: BookMarkCommand(doc, pos, comment, parent) {}
|
||||
|
||||
void BookMarkRemoveCommand::redo() { m_doc->removeBookMark(m_pos); }
|
||||
|
||||
void BookMarkRemoveCommand::undo() { m_doc->addBookMark(m_pos, m_comment); }
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef BOOKMARKREMOVECOMMAND_H
|
||||
#define BOOKMARKREMOVECOMMAND_H
|
||||
|
||||
#include "bookmarkcommand.h"
|
||||
|
||||
class BookMarkRemoveCommand : public BookMarkCommand {
|
||||
public:
|
||||
BookMarkRemoveCommand(QHexDocument *doc, qint64 pos, QString comment,
|
||||
QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
};
|
||||
|
||||
#endif // BOOKMARKREMOVECOMMAND_H
|
|
@ -0,0 +1,11 @@
|
|||
#include "bookmarkreplacecommand.h"
|
||||
|
||||
BookMarkReplaceCommand::BookMarkReplaceCommand(QHexDocument *doc, qint64 pos,
|
||||
QString comment,
|
||||
QString oldcomment,
|
||||
QUndoCommand *parent)
|
||||
: BookMarkCommand(doc, pos, comment, parent), m_oldcomment(oldcomment) {}
|
||||
|
||||
void BookMarkReplaceCommand::redo() { m_doc->modBookMark(m_pos, m_comment); }
|
||||
|
||||
void BookMarkReplaceCommand::undo() { m_doc->modBookMark(m_pos, m_oldcomment); }
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef BOOKMARKREPLACECOMMAND_H
|
||||
#define BOOKMARKREPLACECOMMAND_H
|
||||
|
||||
#include "bookmarkcommand.h"
|
||||
|
||||
class BookMarkReplaceCommand : public BookMarkCommand {
|
||||
public:
|
||||
BookMarkReplaceCommand(QHexDocument *doc, qint64 pos, QString comment,
|
||||
QString oldcomment, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
protected:
|
||||
QString m_oldcomment;
|
||||
};
|
||||
|
||||
#endif // BOOKMARKREPLACECOMMAND_H
|
|
@ -7,8 +7,4 @@ MetaClearCommand::MetaClearCommand(QHexMetadata *hexmeta,
|
|||
|
||||
void MetaClearCommand::redo() { m_hexmeta->clear(); }
|
||||
|
||||
void MetaClearCommand::undo() {
|
||||
for (auto item : m_metas)
|
||||
m_hexmeta->metadata(item.begin, item.end, item.foreground, item.background,
|
||||
item.comment);
|
||||
}
|
||||
void MetaClearCommand::undo() { m_hexmeta->applyMetas(m_metas); }
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#include "qhexdocument.h"
|
||||
#include "buffer/qfilebuffer.h"
|
||||
#include "commands/bookmarkaddcommand.h"
|
||||
#include "commands/bookmarkclearcommand.h"
|
||||
#include "commands/bookmarkremovecommand.h"
|
||||
#include "commands/bookmarkreplacecommand.h"
|
||||
#include "commands/insertcommand.h"
|
||||
#include "commands/removecommand.h"
|
||||
#include "commands/replacecommand.h"
|
||||
|
@ -37,9 +41,49 @@ void QHexDocument::getBookMarks(QList<BookMarkStruct> &bookmarks) {
|
|||
bookmarks.append(this->bookmarks);
|
||||
}
|
||||
|
||||
void QHexDocument::addBookMark(QString comment) {
|
||||
BookMarkStruct b{m_cursor->position().offset(), comment};
|
||||
bookmarks.append(b);
|
||||
void QHexDocument::AddBookMark(qint64 pos, QString comment) {
|
||||
m_undostack.push(new BookMarkAddCommand(this, pos, comment));
|
||||
}
|
||||
|
||||
void QHexDocument::ModBookMark(qint64 pos, QString comment) {
|
||||
m_undostack.push(
|
||||
new BookMarkReplaceCommand(this, pos, comment, bookMarkComment(pos)));
|
||||
}
|
||||
|
||||
void QHexDocument::ClearBookMark() {
|
||||
m_undostack.push(new BookMarkClearCommand(this, getAllBookMarks()));
|
||||
}
|
||||
|
||||
bool QHexDocument::addBookMark(qint64 pos, QString comment) {
|
||||
if (!existBookMark(pos)) {
|
||||
BookMarkStruct b{pos, comment};
|
||||
bookmarks.append(b);
|
||||
emit bookMarkChanged();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString QHexDocument::bookMarkComment(qint64 pos) {
|
||||
if (pos > 0 && pos < m_buffer->length()) {
|
||||
for (auto item : bookmarks) {
|
||||
if (item.pos == pos) {
|
||||
return item.comment;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
BookMarkStruct QHexDocument::bookMark(qint64 pos) {
|
||||
if (pos > 0 && pos < m_buffer->length()) {
|
||||
for (auto item : bookmarks) {
|
||||
if (item.pos == pos) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return BookMarkStruct{-1, ""};
|
||||
}
|
||||
|
||||
BookMarkStruct QHexDocument::bookMark(int index) {
|
||||
|
@ -52,13 +96,49 @@ BookMarkStruct QHexDocument::bookMark(int index) {
|
|||
}
|
||||
}
|
||||
|
||||
void QHexDocument::removeBookMark(int index) {
|
||||
if (index >= 0 && index < bookmarks.count()) {
|
||||
bookmarks.removeAt(index);
|
||||
void QHexDocument::RemoveBookMark(int index) {
|
||||
auto b = bookmarks.at(index);
|
||||
m_undostack.push(new BookMarkRemoveCommand(this, b.pos, b.comment));
|
||||
}
|
||||
|
||||
void QHexDocument::removeBookMark(qint64 pos) {
|
||||
if (pos >= 0 && pos < m_buffer->length()) {
|
||||
int index = 0;
|
||||
for (auto item : bookmarks) {
|
||||
if (pos == item.pos) {
|
||||
bookmarks.removeAt(index);
|
||||
emit bookMarkChanged();
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QHexDocument::clearBookMark() { bookmarks.clear(); }
|
||||
void QHexDocument::removeBookMark(int index) {
|
||||
if (index >= 0 && index < bookmarks.count()) {
|
||||
bookmarks.removeAt(index);
|
||||
emit bookMarkChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool QHexDocument::modBookMark(qint64 pos, QString comment) {
|
||||
if (pos > 0 && pos < m_buffer->length()) {
|
||||
for (auto &item : bookmarks) {
|
||||
if (item.pos == pos) {
|
||||
item.comment = comment;
|
||||
emit bookMarkChanged();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QHexDocument::clearBookMark() {
|
||||
bookmarks.clear();
|
||||
emit bookMarkChanged();
|
||||
}
|
||||
|
||||
void QHexDocument::gotoBookMark(int index) {
|
||||
if (index >= 0 && index < bookmarks.count()) {
|
||||
|
@ -67,6 +147,19 @@ void QHexDocument::gotoBookMark(int index) {
|
|||
}
|
||||
}
|
||||
|
||||
bool QHexDocument::existBookMark(qint64 pos) {
|
||||
for (auto item : bookmarks) {
|
||||
if (item.pos == pos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QHexDocument::existBookMark() {
|
||||
return existBookMark(m_cursor->position().offset());
|
||||
}
|
||||
|
||||
bool QHexDocument::existBookMark(int &index) {
|
||||
auto curpos = m_cursor->position().offset();
|
||||
int i = 0;
|
||||
|
@ -84,6 +177,7 @@ QList<BookMarkStruct> QHexDocument::getAllBookMarks() { return bookmarks; }
|
|||
|
||||
void QHexDocument::applyBookMarks(QList<BookMarkStruct> books) {
|
||||
bookmarks.append(books);
|
||||
emit bookMarkChanged();
|
||||
}
|
||||
|
||||
void QHexDocument::FindAllBytes(qint64 begin, qint64 end, QByteArray b,
|
||||
|
|
|
@ -48,15 +48,28 @@ public:
|
|||
bool isLocked();
|
||||
bool isSaved();
|
||||
|
||||
void addBookMark(QString comment);
|
||||
//----------------------------------
|
||||
void AddBookMark(qint64 pos, QString comment);
|
||||
void RemoveBookMark(int index);
|
||||
void ModBookMark(qint64 pos, QString comment);
|
||||
void ClearBookMark();
|
||||
//----------------------------------
|
||||
|
||||
bool addBookMark(qint64 pos, QString comment);
|
||||
bool modBookMark(qint64 pos, QString comment);
|
||||
BookMarkStruct bookMark(int index);
|
||||
BookMarkStruct bookMark(qint64 pos);
|
||||
QString bookMarkComment(qint64 pos);
|
||||
QList<BookMarkStruct> getAllBookMarks();
|
||||
void applyBookMarks(QList<BookMarkStruct> books);
|
||||
void removeBookMark(int index);
|
||||
void removeBookMark(qint64 pos);
|
||||
void clearBookMark();
|
||||
void getBookMarks(QList<BookMarkStruct> &bookmarks);
|
||||
void gotoBookMark(int index);
|
||||
bool existBookMark(int &index);
|
||||
bool existBookMark();
|
||||
bool existBookMark(qint64 pos);
|
||||
|
||||
void FindAllBytes(qint64 begin, qint64 end, QByteArray b,
|
||||
QList<quint64> &results, int maxCount = -1);
|
||||
|
@ -113,6 +126,7 @@ signals:
|
|||
/*================================*/
|
||||
|
||||
void documentSaved(bool saved); // added by wingsummer
|
||||
void bookMarkChanged(); // added by wingsummer
|
||||
void canUndoChanged(bool canUndo);
|
||||
void canRedoChanged(bool canRedo);
|
||||
void documentChanged();
|
||||
|
|
|
@ -139,11 +139,14 @@ void QHexView::establishSignal(QHexDocument *doc) {
|
|||
connect(doc, &QHexDocument::canUndoChanged, this, &QHexView::canUndoChanged);
|
||||
connect(doc, &QHexDocument::canRedoChanged, this, &QHexView::canRedoChanged);
|
||||
connect(doc, &QHexDocument::documentSaved, this, &QHexView::documentSaved);
|
||||
connect(doc, &QHexDocument::bookMarkChanged, this,
|
||||
&QHexView::documentBookMarkChanged);
|
||||
|
||||
emit canUndoChanged(doc->canUndo());
|
||||
emit canRedoChanged(doc->canRedo());
|
||||
emit cursorLocationChanged();
|
||||
emit documentSwitched();
|
||||
emit documentBookMarkChanged();
|
||||
emit documentSaved(doc->isSaved());
|
||||
emit documentKeepSize(doc->isKeepSize());
|
||||
emit documentLockedFile(doc->isLocked());
|
||||
|
|
|
@ -59,6 +59,7 @@ signals:
|
|||
void documentSaved(bool saved);
|
||||
void documentLockedFile(bool locked);
|
||||
void documentKeepSize(bool keep);
|
||||
void documentBookMarkChanged();
|
||||
|
||||
/*=============================*/
|
||||
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
|神末shenmo|打赏捐助|Deepin 论坛|
|
||||
|lv36|打赏捐助|Deepin 论坛|
|
||||
|
||||
## 代码贡献者
|
||||
|
||||
  维护一个好用的工具并不是一个人能做到了,更重要的是大家共同维护,如下是对本仓库代码有贡献的同志,特此感谢:
|
||||
|
||||
|昵称|贡献|
|
||||
|:--:|:--:|
|
||||
|神末shenmo|修复 ubuntu 下的显示问题|
|
||||
|
||||
### 软件架构
|
||||
|
||||
* TestPlugin : 虽然名字表面意思是测试插件,但它是编写该软件支持的插件一个非常重要的教程,重要性不可忽略。
|
||||
|
|
|
@ -38,8 +38,7 @@ ErrFile AppManager::openFile(QString file, bool readonly) {
|
|||
void AppManager::openFiles(QStringList files) {
|
||||
if (mWindow) {
|
||||
for (auto file : files) {
|
||||
if (mWindow->openWorkSpace(file) != ErrFile::Success)
|
||||
mWindow->openFile(file);
|
||||
openFile(file);
|
||||
}
|
||||
//通过dbus接口从任务栏激活窗口
|
||||
if (!Q_LIKELY(Utilities::activeWindowFromDock(mWindow->winId()))) {
|
||||
|
|
|
@ -483,7 +483,8 @@ MainWindow::MainWindow(DMainWindow *parent) {
|
|||
&MainWindow::on_hexeditor_customContextMenuRequested);
|
||||
connect(hexeditor, &QHexView::documentSwitched, this,
|
||||
&MainWindow::on_documentSwitched);
|
||||
|
||||
connect(hexeditor, &QHexView::documentBookMarkChanged, this,
|
||||
&MainWindow::on_bookmarkChanged);
|
||||
status = new DStatusBar(this);
|
||||
status->setEnabled(false);
|
||||
this->setStatusBar(status);
|
||||
|
@ -512,15 +513,18 @@ MainWindow::MainWindow(DMainWindow *parent) {
|
|||
iSetBaseAddr->setToolTip(tr("SetaddressBase"));
|
||||
connect(iSetBaseAddr, &DIconButton::clicked, [=] {
|
||||
DInputDialog d;
|
||||
auto num = d.getText(this, tr("addressBase"), tr("inputAddressBase"));
|
||||
bool b = false;
|
||||
qulonglong qnum = num.toULongLong(&b, 0);
|
||||
bool b;
|
||||
auto num = d.getText(this, tr("addressBase"), tr("inputAddressBase"),
|
||||
QLineEdit::Normal, QString(), &b);
|
||||
if (b) {
|
||||
hexeditor->setAddressBase(qnum);
|
||||
} else {
|
||||
if (num.length() > 0) {
|
||||
auto d = DMessageManager::instance();
|
||||
d->sendMessage(this, ICONRES("mAddr"), tr("ErrBaseAddress"));
|
||||
qulonglong qnum = num.toULongLong(&b, 0);
|
||||
if (b) {
|
||||
hexeditor->setAddressBase(qnum);
|
||||
} else {
|
||||
if (num.length() > 0) {
|
||||
auto d = DMessageManager::instance();
|
||||
d->sendMessage(this, ICONRES("mAddr"), tr("ErrBaseAddress"));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -693,6 +697,7 @@ MainWindow::MainWindow(DMainWindow *parent) {
|
|||
bookmarks = new DListWidget(this);
|
||||
bookmarks->setFocusPolicy(Qt::StrongFocus);
|
||||
connect(bookmarks, &DListWidget::itemDoubleClicked, [=]() {
|
||||
hexeditor->renderer()->enableCursor(true);
|
||||
hexeditor->document()->gotoBookMark(bookmarks->currentRow());
|
||||
});
|
||||
dw->setWidget(bookmarks);
|
||||
|
@ -1431,10 +1436,18 @@ ErrFile MainWindow::openFile(QString filename, bool readonly, int *openedindex,
|
|||
|
||||
hexfiles.push_back(hf);
|
||||
|
||||
QMimeDatabase db;
|
||||
auto t = db.mimeTypeForFile(p->isWorkspace ? workspace : filename);
|
||||
auto ico = t.iconName();
|
||||
tabs->addTab(QIcon::fromTheme(ico, QIcon(ico)), info.fileName());
|
||||
QIcon qicon;
|
||||
|
||||
if (p->isWorkspace) {
|
||||
qicon = ICONRES("pro");
|
||||
} else {
|
||||
QMimeDatabase db;
|
||||
auto t = db.mimeTypeForFile(filename);
|
||||
auto ico = t.iconName();
|
||||
qicon = QIcon::fromTheme(ico, QIcon(ico));
|
||||
}
|
||||
|
||||
tabs->addTab(qicon, info.fileName());
|
||||
auto index = hexfiles.count() - 1;
|
||||
tabs->setCurrentIndex(index);
|
||||
tabs->setTabToolTip(index, filename);
|
||||
|
@ -2001,19 +2014,11 @@ void MainWindow::on_savesel() {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_documentSwitched() {
|
||||
iReadWrite->setPixmap(hexeditor->isReadOnly() ? infoReadonly : infoWriteable);
|
||||
void MainWindow::on_bookmarkChanged() {
|
||||
auto doc = hexeditor->document();
|
||||
QList<BookMarkStruct> bookmaps;
|
||||
bookmarks->clear();
|
||||
auto doc = hexeditor->document();
|
||||
doc->getBookMarks(bookmaps);
|
||||
|
||||
if (hexfiles.count()) {
|
||||
iw->setPixmap(doc->isWorkspace ? infow : infouw);
|
||||
} else {
|
||||
iw->setPixmap(infouw);
|
||||
}
|
||||
|
||||
for (auto item : bookmaps) {
|
||||
QListWidgetItem *litem = new QListWidgetItem;
|
||||
litem->setIcon(ICONRES("bookmark"));
|
||||
|
@ -2023,6 +2028,15 @@ void MainWindow::on_documentSwitched() {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_documentSwitched() {
|
||||
iReadWrite->setPixmap(hexeditor->isReadOnly() ? infoReadonly : infoWriteable);
|
||||
if (hexfiles.count()) {
|
||||
iw->setPixmap(hexeditor->document()->isWorkspace ? infow : infouw);
|
||||
} else {
|
||||
iw->setPixmap(infouw);
|
||||
}
|
||||
}
|
||||
|
||||
ErrFile MainWindow::save(int index) {
|
||||
if (index >= 0 && index < hexfiles.count()) {
|
||||
auto f = hexfiles.at(index);
|
||||
|
@ -2042,6 +2056,9 @@ ErrFile MainWindow::save(int index) {
|
|||
hexeditor->document()->metadata()->getallMetas());
|
||||
if (!b)
|
||||
return ErrFile::WorkSpaceUnSaved;
|
||||
f.doc->isWorkspace = true;
|
||||
iw->setPixmap(infow);
|
||||
tabs->setTabIcon(index, ICONRES("pro"));
|
||||
} else {
|
||||
auto b = WorkSpaceManager::saveWorkSpace(
|
||||
f.filename + PROEXT, f.filename,
|
||||
|
@ -2050,6 +2067,9 @@ ErrFile MainWindow::save(int index) {
|
|||
if (!b)
|
||||
return ErrFile::WorkSpaceUnSaved;
|
||||
hexfiles[index].workspace = f.filename + PROEXT;
|
||||
f.doc->isWorkspace = true;
|
||||
iw->setPixmap(infow);
|
||||
tabs->setTabIcon(index, ICONRES("pro"));
|
||||
}
|
||||
}
|
||||
return ErrFile::Success;
|
||||
|
@ -2094,6 +2114,9 @@ ErrFile MainWindow::saveAs(QString filename, int index) {
|
|||
if (!b)
|
||||
return ErrFile::WorkSpaceUnSaved;
|
||||
hexfiles[index].workspace = filename + PROEXT;
|
||||
f.doc->isWorkspace = true;
|
||||
iw->setPixmap(infow);
|
||||
tabs->setTabIcon(index, ICONRES("pro"));
|
||||
}
|
||||
return ErrFile::Success;
|
||||
}
|
||||
|
@ -2190,23 +2213,21 @@ void MainWindow::on_bookmark() {
|
|||
int index = -1;
|
||||
if (doc->existBookMark(index)) {
|
||||
auto b = doc->bookMark(index);
|
||||
auto comment = DInputDialog::getText(
|
||||
this, tr("BookMark"), tr("InputComment"), QLineEdit::Normal, b.comment);
|
||||
if (!comment.isEmpty()) {
|
||||
auto item = bookmarks->item(index);
|
||||
item->setText(comment);
|
||||
bool ok;
|
||||
auto comment =
|
||||
DInputDialog::getText(this, tr("BookMark"), tr("InputComment"),
|
||||
QLineEdit::Normal, b.comment, &ok);
|
||||
if (ok) {
|
||||
doc->ModBookMark(b.pos, comment);
|
||||
}
|
||||
} else {
|
||||
bool ok;
|
||||
auto comment =
|
||||
DInputDialog ::getText(this, tr("BookMark"), tr("InputComment"));
|
||||
if (!comment.isEmpty()) {
|
||||
hexeditor->document()->addBookMark(comment);
|
||||
QListWidgetItem *item = new QListWidgetItem;
|
||||
item->setIcon(ICONRES("bookmark"));
|
||||
item->setText(comment);
|
||||
item->setToolTip(QString(tr("Addr : 0x%1"))
|
||||
.arg(doc->cursor()->position().offset(), 0, 16));
|
||||
bookmarks->addItem(item);
|
||||
DInputDialog ::getText(this, tr("BookMark"), tr("InputComment"),
|
||||
QLineEdit::Normal, QString(), &ok);
|
||||
if (ok) {
|
||||
auto pos = qint64(hexeditor->currentOffset());
|
||||
doc->AddBookMark(pos, comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2216,17 +2237,13 @@ void MainWindow::on_bookmarkdel() {
|
|||
auto doc = hexeditor->document();
|
||||
int index = -1;
|
||||
if (doc->existBookMark(index)) {
|
||||
doc->removeBookMark(index);
|
||||
auto item = bookmarks->item(index);
|
||||
bookmarks->removeItemWidget(item);
|
||||
delete item; // make the removed item disapeared from the list widgets
|
||||
doc->RemoveBookMark(index);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_bookmarkcls() {
|
||||
CheckEnabled;
|
||||
hexeditor->document()->clearBookMark();
|
||||
bookmarks->clear();
|
||||
hexeditor->document()->ClearBookMark();
|
||||
}
|
||||
|
||||
void MainWindow::on_encoding() {
|
||||
|
@ -2290,9 +2307,10 @@ void MainWindow::on_restoreLayout() { m_settings->loadWindowState(this, true); }
|
|||
|
||||
void MainWindow::on_fill() {
|
||||
CheckEnabled;
|
||||
auto in = DInputDialog::getText(this, tr("Fill"), tr("PleaseInputFill"));
|
||||
if (in.length() != 0) {
|
||||
bool b = false;
|
||||
bool b;
|
||||
auto in = DInputDialog::getText(this, tr("Fill"), tr("PleaseInputFill"),
|
||||
QLineEdit::Normal, QString(), &b);
|
||||
if (b) {
|
||||
auto ch = char(in.toULongLong(&b, 0));
|
||||
if (b) {
|
||||
auto doc = hexeditor->document();
|
||||
|
|
|
@ -200,6 +200,7 @@ private:
|
|||
void on_loadplg();
|
||||
void on_encoding();
|
||||
void on_openworkspace();
|
||||
void on_bookmarkChanged();
|
||||
|
||||
private:
|
||||
QList<HexFile> hexfiles;
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
|
@ -51,7 +51,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
a.setOrganizationName("WingCloud");
|
||||
a.setApplicationName(QObject::tr("WingHexExplorer"));
|
||||
a.setApplicationVersion("1.3.0");
|
||||
a.setApplicationVersion("1.4.0");
|
||||
a.setProductIcon(QIcon(":/images/icon.png"));
|
||||
a.setProductName(QObject::tr("WingHexExplorer"));
|
||||
a.setApplicationDescription(QObject::tr("AppDescription"));
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
<file>images/mark.png</file>
|
||||
<file>images/wiki.png</file>
|
||||
<file>images/clearhis.png</file>
|
||||
<file>images/pro.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/resources">
|
||||
<file>settings.json</file>
|
||||
|
|
Loading…
Reference in New Issue