fix: 优化界面提示;修复与工作区相关的若干个问题;
This commit is contained in:
parent
5d78503b58
commit
bef7f232f3
|
@ -15,6 +15,7 @@ void AppendCommand::undo() {
|
||||||
m_doc->insertBookMarkAdjustRevert(offset, m_length);
|
m_doc->insertBookMarkAdjustRevert(offset, m_length);
|
||||||
m_doc->metadata()->insertAdjustRevert(offset, m_length);
|
m_doc->metadata()->insertAdjustRevert(offset, m_length);
|
||||||
m_cursor->setPos(offset, m_nibbleindex);
|
m_cursor->setPos(offset, m_nibbleindex);
|
||||||
|
HexCommand::undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppendCommand::redo() {
|
void AppendCommand::redo() {
|
||||||
|
@ -27,4 +28,5 @@ void AppendCommand::redo() {
|
||||||
} else {
|
} else {
|
||||||
m_cursor->setPos(offset + m_length, m_nibbleindex);
|
m_cursor->setPos(offset + m_length, m_nibbleindex);
|
||||||
}
|
}
|
||||||
|
HexCommand::redo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,3 +4,10 @@ HexCommand::HexCommand(QHexDocument *doc, QHexCursor *cursor, int nibbleindex,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: QUndoCommand(parent), m_doc(doc), m_cursor(cursor), m_offset(0),
|
: QUndoCommand(parent), m_doc(doc), m_cursor(cursor), m_offset(0),
|
||||||
m_length(0), m_nibbleindex(nibbleindex) {}
|
m_length(0), m_nibbleindex(nibbleindex) {}
|
||||||
|
|
||||||
|
void HexCommand::undo() {
|
||||||
|
Q_ASSERT(m_doc->m_bytesModFlag > 0);
|
||||||
|
m_doc->m_bytesModFlag--;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HexCommand::redo() { m_doc->m_bytesModFlag++; }
|
||||||
|
|
|
@ -11,6 +11,9 @@ public:
|
||||||
HexCommand(QHexDocument *doc, QHexCursor *cursor, int nibbleindex,
|
HexCommand(QHexDocument *doc, QHexCursor *cursor, int nibbleindex,
|
||||||
QUndoCommand *parent = nullptr);
|
QUndoCommand *parent = nullptr);
|
||||||
|
|
||||||
|
void undo() override;
|
||||||
|
void redo() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHexDocument *m_doc;
|
QHexDocument *m_doc;
|
||||||
QHexCursor *m_cursor;
|
QHexCursor *m_cursor;
|
||||||
|
|
|
@ -14,6 +14,7 @@ void InsertCommand::undo() {
|
||||||
m_doc->insertBookMarkAdjustRevert(m_offset, m_length);
|
m_doc->insertBookMarkAdjustRevert(m_offset, m_length);
|
||||||
m_doc->metadata()->insertAdjustRevert(m_offset, m_length);
|
m_doc->metadata()->insertAdjustRevert(m_offset, m_length);
|
||||||
m_cursor->setPos(m_offset, m_nibbleindex);
|
m_cursor->setPos(m_offset, m_nibbleindex);
|
||||||
|
HexCommand::undo();
|
||||||
}
|
}
|
||||||
void InsertCommand::redo() {
|
void InsertCommand::redo() {
|
||||||
m_doc->_insert(m_offset, m_data);
|
m_doc->_insert(m_offset, m_data);
|
||||||
|
@ -24,4 +25,5 @@ void InsertCommand::redo() {
|
||||||
} else {
|
} else {
|
||||||
m_cursor->setPos(m_offset + m_length, m_nibbleindex);
|
m_cursor->setPos(m_offset + m_length, m_nibbleindex);
|
||||||
}
|
}
|
||||||
|
HexCommand::redo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ void RemoveCommand::undo() {
|
||||||
m_cursor->setPos(m_offset, 0);
|
m_cursor->setPos(m_offset, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
HexCommand::undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveCommand::redo() {
|
void RemoveCommand::redo() {
|
||||||
|
@ -29,4 +30,5 @@ void RemoveCommand::redo() {
|
||||||
m_doc->_remove(m_offset, m_length);
|
m_doc->_remove(m_offset, m_length);
|
||||||
_rmbms = m_doc->removeBookMarkAdjust(m_offset, m_length);
|
_rmbms = m_doc->removeBookMarkAdjust(m_offset, m_length);
|
||||||
_rmMetas = m_doc->metadata()->removeAdjust(m_offset, m_length);
|
_rmMetas = m_doc->metadata()->removeAdjust(m_offset, m_length);
|
||||||
|
HexCommand::redo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ ReplaceCommand::ReplaceCommand(QHexDocument *doc, qsizetype offset,
|
||||||
const QByteArray &data, QHexCursor *cursor,
|
const QByteArray &data, QHexCursor *cursor,
|
||||||
int nibbleindex, QUndoCommand *parent)
|
int nibbleindex, QUndoCommand *parent)
|
||||||
: HexCommand(doc, cursor, nibbleindex, parent) {
|
: HexCommand(doc, cursor, nibbleindex, parent) {
|
||||||
|
|
||||||
m_offset = offset;
|
m_offset = offset;
|
||||||
m_data = data;
|
m_data = data;
|
||||||
m_length = data.length();
|
m_length = data.length();
|
||||||
|
@ -15,6 +14,7 @@ ReplaceCommand::ReplaceCommand(QHexDocument *doc, qsizetype offset,
|
||||||
void ReplaceCommand::undo() {
|
void ReplaceCommand::undo() {
|
||||||
m_doc->_replace(m_offset, m_olddata);
|
m_doc->_replace(m_offset, m_olddata);
|
||||||
m_cursor->setPos(m_offset, m_nibbleindex);
|
m_cursor->setPos(m_offset, m_nibbleindex);
|
||||||
|
HexCommand::undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplaceCommand::redo() {
|
void ReplaceCommand::redo() {
|
||||||
|
@ -24,4 +24,5 @@ void ReplaceCommand::redo() {
|
||||||
} else {
|
} else {
|
||||||
m_cursor->setPos(m_offset + m_length, !m_nibbleindex);
|
m_cursor->setPos(m_offset + m_length, !m_nibbleindex);
|
||||||
}
|
}
|
||||||
|
HexCommand::redo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@ MetaReplaceCommand::MetaReplaceCommand(QHexMetadata *hexmeta,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: MetaCommand(hexmeta, meta, parent), m_old(oldmeta) {}
|
: MetaCommand(hexmeta, meta, parent), m_old(oldmeta) {}
|
||||||
|
|
||||||
void MetaReplaceCommand::undo() { m_hexmeta->modifyMetadata(m_meta, m_old); }
|
void MetaReplaceCommand::undo() { m_hexmeta->modifyMetadata(m_old, m_meta); }
|
||||||
|
|
||||||
void MetaReplaceCommand::redo() { m_hexmeta->modifyMetadata(m_old, m_meta); }
|
void MetaReplaceCommand::redo() { m_hexmeta->modifyMetadata(m_meta, m_old); }
|
||||||
|
|
|
@ -115,8 +115,6 @@ public:
|
||||||
|
|
||||||
qsizetype currentSelectionLength() const;
|
qsizetype currentSelectionLength() const;
|
||||||
|
|
||||||
bool atEnd() const;
|
|
||||||
|
|
||||||
bool isLineSelected(qsizetype line) const;
|
bool isLineSelected(qsizetype line) const;
|
||||||
bool isSelected(const QHexPosition &pos) const;
|
bool isSelected(const QHexPosition &pos) const;
|
||||||
bool hasSelection() const;
|
bool hasSelection() const;
|
||||||
|
|
|
@ -205,6 +205,8 @@ void QHexDocument::removeBookMarkAdjustRevert(
|
||||||
|
|
||||||
bool QHexDocument::isDocSaved() { return m_isSaved; }
|
bool QHexDocument::isDocSaved() { return m_isSaved; }
|
||||||
|
|
||||||
|
bool QHexDocument::isUndoByteModified() { return m_bytesModFlag > 0; }
|
||||||
|
|
||||||
void QHexDocument::setDocSaved(bool b) {
|
void QHexDocument::setDocSaved(bool b) {
|
||||||
if (b) {
|
if (b) {
|
||||||
m_undostack->setClean();
|
m_undostack->setClean();
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
class QHexDocument : public QObject {
|
class QHexDocument : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
friend class HexCommand;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit QHexDocument(QHexBuffer *buffer,
|
explicit QHexDocument(QHexBuffer *buffer,
|
||||||
bool readonly = false); // modified by wingsummer
|
bool readonly = false); // modified by wingsummer
|
||||||
|
@ -79,7 +81,9 @@ public:
|
||||||
void findAllBytes(
|
void findAllBytes(
|
||||||
qsizetype begin, qsizetype end, QByteArray b, QList<qsizetype> &results,
|
qsizetype begin, qsizetype end, QByteArray b, QList<qsizetype> &results,
|
||||||
const std::function<bool()> &pred = [] { return true; });
|
const std::function<bool()> &pred = [] { return true; });
|
||||||
|
|
||||||
bool isDocSaved();
|
bool isDocSaved();
|
||||||
|
bool isUndoByteModified();
|
||||||
void setDocSaved(bool b = true);
|
void setDocSaved(bool b = true);
|
||||||
|
|
||||||
void setMetafgVisible(bool b);
|
void setMetafgVisible(bool b);
|
||||||
|
@ -222,7 +226,10 @@ signals:
|
||||||
private:
|
private:
|
||||||
QHexBuffer *m_buffer;
|
QHexBuffer *m_buffer;
|
||||||
QHexMetadata *m_metadata;
|
QHexMetadata *m_metadata;
|
||||||
|
|
||||||
QUndoStack *m_undostack;
|
QUndoStack *m_undostack;
|
||||||
|
size_t m_bytesModFlag = 0;
|
||||||
|
|
||||||
quintptr m_baseaddress;
|
quintptr m_baseaddress;
|
||||||
quint8 m_areaindent;
|
quint8 m_areaindent;
|
||||||
quint8 m_hexlinewidth;
|
quint8 m_hexlinewidth;
|
||||||
|
|
|
@ -272,6 +272,10 @@ void QHexMetadata::applyMetas(const QVector<QHexMetadataItem> &metas) {
|
||||||
for (auto &meta : metas) {
|
for (auto &meta : metas) {
|
||||||
m_metadata.mergeAdd(meta);
|
m_metadata.mergeAdd(meta);
|
||||||
}
|
}
|
||||||
|
for (auto &meta : m_metadata) {
|
||||||
|
addMetaLines(meta);
|
||||||
|
}
|
||||||
|
emit metadataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QHexMetadata::hasMetadata() { return m_metadata.count() > 0; }
|
bool QHexMetadata::hasMetadata() { return m_metadata.count() > 0; }
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -2,8 +2,9 @@
|
||||||
"Id": "WingAngelAPI",
|
"Id": "WingAngelAPI",
|
||||||
"Name": "WingAngelAPI",
|
"Name": "WingAngelAPI",
|
||||||
"Author": "wingsummer",
|
"Author": "wingsummer",
|
||||||
"Version": "0.0.1",
|
"Version": "2.1.0",
|
||||||
"Vendor": "WingCloudStudio",
|
"Vendor": "WingCloudStudio",
|
||||||
"Copyright": "wingsummer",
|
"Copyright": "wingsummer",
|
||||||
"License": "AGPL-3.0"
|
"License": "AGPL-3.0",
|
||||||
|
"Url": "https://github.com/Wing-summer/WingHexExplorer2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,25 +85,26 @@ bool WorkSpaceManager::loadWorkSpace(const QString &filename, QString &file,
|
||||||
auto nend = end.toString().toLongLong(&b);
|
auto nend = end.toString().toLongLong(&b);
|
||||||
if (!b || nend >= maxbytes || nend < 0)
|
if (!b || nend >= maxbytes || nend < 0)
|
||||||
continue;
|
continue;
|
||||||
auto nf = fgcolor.toString().toUInt(&b, 16);
|
|
||||||
if (!b)
|
static auto NO_COLOR = QStringLiteral("-");
|
||||||
continue;
|
|
||||||
auto nb = bgcolor.toString().toUInt(&b, 16);
|
QColor fcolor, bcolor;
|
||||||
if (!b)
|
auto fgn = fgcolor.toString();
|
||||||
continue;
|
if (fgn != NO_COLOR) {
|
||||||
auto fcolor = QColor::fromRgba(nf);
|
fcolor = QColor(fgn);
|
||||||
auto bcolor = QColor::fromRgba(nb);
|
}
|
||||||
|
|
||||||
|
auto bgn = bgcolor.toString();
|
||||||
|
if (bgn != NO_COLOR) {
|
||||||
|
bcolor = QColor(bgn);
|
||||||
|
}
|
||||||
|
|
||||||
QHexMetadataItem metaitem;
|
QHexMetadataItem metaitem;
|
||||||
metaitem.begin = nbegin;
|
metaitem.begin = nbegin;
|
||||||
metaitem.end = nend;
|
metaitem.end = nend;
|
||||||
metaitem.comment = comment.toString();
|
metaitem.comment = comment.toString();
|
||||||
metaitem.foreground = fcolor.alpha() > 0
|
metaitem.foreground = fcolor;
|
||||||
? fcolor.toHsv()
|
metaitem.background = bcolor;
|
||||||
: fcolor;
|
|
||||||
metaitem.background = bcolor.alpha() > 0
|
|
||||||
? fcolor.toHsv()
|
|
||||||
: bcolor;
|
|
||||||
metas.append(metaitem);
|
metas.append(metaitem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,6 +165,14 @@ bool WorkSpaceManager::loadWorkSpace(const QString &filename, QString &file,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString WorkSpaceManager::getColorString(const QColor &color) {
|
||||||
|
static auto NO_COLOR = QStringLiteral("-");
|
||||||
|
if (color.isValid()) {
|
||||||
|
return color.name();
|
||||||
|
}
|
||||||
|
return NO_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
bool WorkSpaceManager::saveWorkSpace(
|
bool WorkSpaceManager::saveWorkSpace(
|
||||||
const QString &filename, const QString &file,
|
const QString &filename, const QString &file,
|
||||||
const QMap<qsizetype, QString> &bookmarklist,
|
const QMap<qsizetype, QString> &bookmarklist,
|
||||||
|
@ -190,8 +199,8 @@ bool WorkSpaceManager::saveWorkSpace(
|
||||||
obj.insert("begin", QString::number(meta.begin));
|
obj.insert("begin", QString::number(meta.begin));
|
||||||
obj.insert("end", QString::number(meta.end));
|
obj.insert("end", QString::number(meta.end));
|
||||||
obj.insert("comment", meta.comment);
|
obj.insert("comment", meta.comment);
|
||||||
obj.insert("fgcolor", QString::number(meta.foreground.rgba(), 16));
|
obj.insert("fgcolor", getColorString(meta.foreground));
|
||||||
obj.insert("bgcolor", QString::number(meta.background.rgba(), 16));
|
obj.insert("bgcolor", getColorString(meta.background));
|
||||||
metas.append(obj);
|
metas.append(obj);
|
||||||
}
|
}
|
||||||
jobj.insert("metas", metas);
|
jobj.insert("metas", metas);
|
||||||
|
|
|
@ -47,6 +47,9 @@ public:
|
||||||
QMap<qsizetype, QString> &bookmarks,
|
QMap<qsizetype, QString> &bookmarks,
|
||||||
QVector<QHexMetadataItem> &metas,
|
QVector<QHexMetadataItem> &metas,
|
||||||
WorkSpaceInfo &infos);
|
WorkSpaceInfo &infos);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString static getColorString(const QColor &color);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WORKSPACEMANAGER_H
|
#endif // WORKSPACEMANAGER_H
|
||||||
|
|
|
@ -465,24 +465,6 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile file(fileName);
|
|
||||||
|
|
||||||
switch (m_docType) {
|
|
||||||
case DocumentType::RegionFile: {
|
|
||||||
if (!ignoreMd5 && Utilities::getMd5(m_fileName) != m_md5) {
|
|
||||||
return ErrFile::SourceFileChanged;
|
|
||||||
}
|
|
||||||
if (!file.open(QFile::ReadWrite)) {
|
|
||||||
return ErrFile::Permission;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
default: {
|
|
||||||
if (!file.open(QFile::WriteOnly)) {
|
|
||||||
return ErrFile::Permission;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (workSpaceAttr == SaveWorkSpaceAttr::ForceWorkSpace ||
|
if (workSpaceAttr == SaveWorkSpaceAttr::ForceWorkSpace ||
|
||||||
(workSpaceAttr == SaveWorkSpaceAttr::AutoWorkSpace &&
|
(workSpaceAttr == SaveWorkSpaceAttr::AutoWorkSpace &&
|
||||||
(m_isWorkSpace || hasMeta()))) {
|
(m_isWorkSpace || hasMeta()))) {
|
||||||
|
@ -499,18 +481,43 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc->saveTo(&file, true)) {
|
if (doc->isUndoByteModified()) {
|
||||||
file.close();
|
QFile file(fileName);
|
||||||
|
|
||||||
if (!isExport) {
|
switch (m_docType) {
|
||||||
m_fileName = QFileInfo(fileName).absoluteFilePath();
|
case DocumentType::RegionFile: {
|
||||||
doc->setDocSaved();
|
if (!ignoreMd5 && Utilities::getMd5(m_fileName) != m_md5) {
|
||||||
|
return ErrFile::SourceFileChanged;
|
||||||
|
}
|
||||||
|
if (!file.open(QFile::ReadWrite)) {
|
||||||
|
return ErrFile::Permission;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
default: {
|
||||||
|
if (!file.open(QFile::WriteOnly)) {
|
||||||
|
return ErrFile::Permission;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ErrFile::Success;
|
if (doc->saveTo(&file, true)) {
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
if (!isExport) {
|
||||||
|
m_fileName = QFileInfo(fileName).absoluteFilePath();
|
||||||
|
doc->setDocSaved();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ErrFile::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ErrFile::Permission;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
doc->setDocSaved();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ErrFile::Permission;
|
return ErrFile::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrFile EditorView::reload() {
|
ErrFile EditorView::reload() {
|
||||||
|
|
|
@ -49,4 +49,6 @@ void QListViewExt::setModel(QAbstractItemModel *model) {
|
||||||
vbar->blockSignals(false);
|
vbar->blockSignals(false);
|
||||||
|
|
||||||
QListView::setModel(model);
|
QListView::setModel(model);
|
||||||
|
|
||||||
|
emit modelChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ public:
|
||||||
explicit QListViewExt(QWidget *parent = nullptr);
|
explicit QListViewExt(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setModel(QAbstractItemModel *model) override;
|
void setModel(QAbstractItemModel *model) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void modelChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QLISTVIEWEXT_H
|
#endif // QLISTVIEWEXT_H
|
||||||
|
|
|
@ -49,4 +49,6 @@ void QTableViewExt::setModel(QAbstractItemModel *model) {
|
||||||
vbar->blockSignals(false);
|
vbar->blockSignals(false);
|
||||||
|
|
||||||
QTableView::setModel(model);
|
QTableView::setModel(model);
|
||||||
|
|
||||||
|
emit modelChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ public:
|
||||||
explicit QTableViewExt(QWidget *parent = nullptr);
|
explicit QTableViewExt(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setModel(QAbstractItemModel *model) override;
|
void setModel(QAbstractItemModel *model) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void modelChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QTABLEVIEWEXT_H
|
#endif // QTABLEVIEWEXT_H
|
||||||
|
|
|
@ -127,6 +127,14 @@ MainWindow::MainWindow(SplashDialog *splash) : FramelessMainWindow() {
|
||||||
m_status->addWidget(l);
|
m_status->addWidget(l);
|
||||||
m_status->addWidget(m_lblsellen);
|
m_status->addWidget(m_lblsellen);
|
||||||
|
|
||||||
|
_status = new QLabel(m_status);
|
||||||
|
m_status->addPermanentWidget(_status);
|
||||||
|
|
||||||
|
auto separator = new QFrame(m_status);
|
||||||
|
separator->setFrameShape(QFrame::VLine);
|
||||||
|
separator->setFrameShadow(QFrame::Sunken);
|
||||||
|
m_status->addPermanentWidget(separator);
|
||||||
|
|
||||||
auto disableStyle =
|
auto disableStyle =
|
||||||
QStringLiteral("border:none;background:transparent;");
|
QStringLiteral("border:none;background:transparent;");
|
||||||
|
|
||||||
|
@ -547,6 +555,14 @@ MainWindow::buildUpFindResultDock(ads::CDockManager *dock,
|
||||||
m_findresult->setContextMenuPolicy(
|
m_findresult->setContextMenuPolicy(
|
||||||
Qt::ContextMenuPolicy::CustomContextMenu);
|
Qt::ContextMenuPolicy::CustomContextMenu);
|
||||||
|
|
||||||
|
auto se = [=]() {
|
||||||
|
auto model = qobject_cast<FindResultModel *>(m_findresult->model());
|
||||||
|
if (model) {
|
||||||
|
m_find->setWindowTitle(tr("FindResult") + QStringLiteral(" (") +
|
||||||
|
model->encoding() + QStringLiteral(")"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
auto menu = new QMenu(tr("Encoding"), this);
|
auto menu = new QMenu(tr("Encoding"), this);
|
||||||
menu->setIcon(ICONRES(QStringLiteral("encoding")));
|
menu->setIcon(ICONRES(QStringLiteral("encoding")));
|
||||||
auto aGroup = new QActionGroup(this);
|
auto aGroup = new QActionGroup(this);
|
||||||
|
@ -556,6 +572,7 @@ MainWindow::buildUpFindResultDock(ads::CDockManager *dock,
|
||||||
auto model = qobject_cast<FindResultModel *>(m_findresult->model());
|
auto model = qobject_cast<FindResultModel *>(m_findresult->model());
|
||||||
if (model) {
|
if (model) {
|
||||||
model->setEncoding(l);
|
model->setEncoding(l);
|
||||||
|
se();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
aGroup->addAction(a);
|
aGroup->addAction(a);
|
||||||
|
@ -620,8 +637,10 @@ MainWindow::buildUpFindResultDock(ads::CDockManager *dock,
|
||||||
});
|
});
|
||||||
|
|
||||||
auto dw = buildDockWidget(dock, QStringLiteral("FindResult"),
|
auto dw = buildDockWidget(dock, QStringLiteral("FindResult"),
|
||||||
tr("FindResult"), m_findresult);
|
tr("FindResult") + QStringLiteral(" (ASCII)"),
|
||||||
|
m_findresult);
|
||||||
m_find = dw;
|
m_find = dw;
|
||||||
|
connect(m_findresult, &QTableViewExt::modelChanged, this, se);
|
||||||
|
|
||||||
return dock->addDockWidget(area, dw, areaw);
|
return dock->addDockWidget(area, dw, areaw);
|
||||||
}
|
}
|
||||||
|
@ -857,6 +876,20 @@ MainWindow::buildUpDecodingStrShowDock(ads::CDockManager *dock,
|
||||||
auto dw = buildDockWidget(dock, QStringLiteral("DecodeText"),
|
auto dw = buildDockWidget(dock, QStringLiteral("DecodeText"),
|
||||||
tr("DecodeText") + QStringLiteral(" (ASCII)"),
|
tr("DecodeText") + QStringLiteral(" (ASCII)"),
|
||||||
m_txtDecode);
|
m_txtDecode);
|
||||||
|
|
||||||
|
auto menu = m_txtDecode->createStandardContextMenu();
|
||||||
|
menu->addSeparator();
|
||||||
|
auto a = new QAction(tr("Encoding"), this);
|
||||||
|
a->setIcon(ICONRES(QStringLiteral("encoding")));
|
||||||
|
connect(a, &QAction::triggered, this, &MainWindow::on_encoding);
|
||||||
|
menu->addAction(a);
|
||||||
|
|
||||||
|
m_txtDecode->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(m_txtDecode, &QTextBrowser::customContextMenuRequested, this,
|
||||||
|
[=](const QPoint &pos) {
|
||||||
|
menu->popup(m_txtDecode->viewport()->mapToGlobal(pos));
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_txtDecode, &QTextBrowser::windowTitleChanged, dw,
|
connect(m_txtDecode, &QTextBrowser::windowTitleChanged, dw,
|
||||||
&QDockWidget::setWindowTitle);
|
&QDockWidget::setWindowTitle);
|
||||||
return dock->addDockWidget(area, dw, areaw);
|
return dock->addDockWidget(area, dw, areaw);
|
||||||
|
@ -1332,10 +1365,6 @@ RibbonTabContent *MainWindow::buildEditPage(RibbonTabContent *tab) {
|
||||||
pannel, QStringLiteral("jmp"), tr("Goto"), &MainWindow::on_gotoline,
|
pannel, QStringLiteral("jmp"), tr("Goto"), &MainWindow::on_gotoline,
|
||||||
shortcuts.keySequence(QKeySequences::Key::GOTO));
|
shortcuts.keySequence(QKeySequences::Key::GOTO));
|
||||||
|
|
||||||
addPannelAction(pannel, QStringLiteral("encoding"), tr("Encoding"),
|
|
||||||
&MainWindow::on_encoding,
|
|
||||||
shortcuts.keySequence(QKeySequences::Key::ENCODING));
|
|
||||||
|
|
||||||
m_editStateWidgets << addPannelAction(pannel, QStringLiteral("sum"),
|
m_editStateWidgets << addPannelAction(pannel, QStringLiteral("sum"),
|
||||||
tr("CheckSum"),
|
tr("CheckSum"),
|
||||||
&MainWindow::on_checksum);
|
&MainWindow::on_checksum);
|
||||||
|
@ -1873,6 +1902,8 @@ void MainWindow::installPluginEditorWidgets() {
|
||||||
m_editorViewWidgets.clear();
|
m_editorViewWidgets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::showStatus(const QString &status) { _status->setText(status); }
|
||||||
|
|
||||||
EditorView *MainWindow::newfileGUI() {
|
EditorView *MainWindow::newfileGUI() {
|
||||||
if (!newOpenFileSafeCheck()) {
|
if (!newOpenFileSafeCheck()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2263,6 +2294,7 @@ void MainWindow::on_findfile() {
|
||||||
|
|
||||||
ExecAsync<EditorView::FindError>(
|
ExecAsync<EditorView::FindError>(
|
||||||
[this, r]() -> EditorView::FindError {
|
[this, r]() -> EditorView::FindError {
|
||||||
|
this->showStatus(tr("Finding..."));
|
||||||
return currentEditor()->find(r);
|
return currentEditor()->find(r);
|
||||||
},
|
},
|
||||||
[this](EditorView::FindError err) {
|
[this](EditorView::FindError err) {
|
||||||
|
@ -2287,6 +2319,8 @@ void MainWindow::on_findfile() {
|
||||||
m_findEncoding.value(result->encoding())->setChecked(true);
|
m_findEncoding.value(result->encoding())->setChecked(true);
|
||||||
}
|
}
|
||||||
m_find->raise();
|
m_find->raise();
|
||||||
|
|
||||||
|
this->showStatus({});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3077,7 +3111,7 @@ bool MainWindow::newOpenFileSafeCheck() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::registerEditorView(EditorView *editor) {
|
void MainWindow::registerEditorView(EditorView *editor, const QString &ws) {
|
||||||
for (auto &w : m_editorViewWidgetsBuffer) {
|
for (auto &w : m_editorViewWidgetsBuffer) {
|
||||||
editor->registerView(w->id(), w->create(editor));
|
editor->registerView(w->id(), w->create(editor));
|
||||||
}
|
}
|
||||||
|
@ -3090,7 +3124,7 @@ void MainWindow::registerEditorView(EditorView *editor) {
|
||||||
editor->setFontSize(set.editorfontSize());
|
editor->setFontSize(set.editorfontSize());
|
||||||
|
|
||||||
connectEditorView(editor);
|
connectEditorView(editor);
|
||||||
m_views.insert(editor, {});
|
m_views.insert(editor, ws);
|
||||||
auto ev = m_toolBtneditors.value(ToolButtonIndex::EDITOR_VIEWS);
|
auto ev = m_toolBtneditors.value(ToolButtonIndex::EDITOR_VIEWS);
|
||||||
auto menu = ev->menu();
|
auto menu = ev->menu();
|
||||||
Q_ASSERT(menu);
|
Q_ASSERT(menu);
|
||||||
|
@ -3155,7 +3189,7 @@ void MainWindow::connectEditorView(EditorView *editor) {
|
||||||
o.foreground = m.foreGroundColor();
|
o.foreground = m.foreGroundColor();
|
||||||
o.background = m.backGroundColor();
|
o.background = m.backGroundColor();
|
||||||
o.comment = m.comment();
|
o.comment = m.comment();
|
||||||
mi->ModifyMetadata(meta, o);
|
mi->ModifyMetadata(o, meta);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast::toast(this, NAMEICONRES(QStringLiteral("metadata")),
|
Toast::toast(this, NAMEICONRES(QStringLiteral("metadata")),
|
||||||
|
@ -3178,8 +3212,47 @@ void MainWindow::connectEditorView(EditorView *editor) {
|
||||||
if (ret == QMessageBox::Cancel) {
|
if (ret == QMessageBox::Cancel) {
|
||||||
return;
|
return;
|
||||||
} else if (ret == QMessageBox::Yes) {
|
} else if (ret == QMessageBox::Yes) {
|
||||||
if (saveEditor(editor, {}, false) == ErrFile::Success) {
|
auto ret = saveEditor(editor, {}, false);
|
||||||
|
switch (ret) {
|
||||||
|
case WingHex::Success:
|
||||||
|
// ok, no need to report
|
||||||
closeEditor(editor, m_isOnClosing);
|
closeEditor(editor, m_isOnClosing);
|
||||||
|
break;
|
||||||
|
case WingHex::Permission: {
|
||||||
|
auto btn = WingMessageBox::critical(
|
||||||
|
this, tr("Error"), tr("FilePermissionSure2Quit"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (btn == QMessageBox::Yes) {
|
||||||
|
closeEditor(editor, true);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case WingHex::Error:
|
||||||
|
case WingHex::UnSaved:
|
||||||
|
case WingHex::NotExist:
|
||||||
|
case WingHex::AlreadyOpened:
|
||||||
|
case WingHex::IsNewFile:
|
||||||
|
case WingHex::IsDirver:
|
||||||
|
case WingHex::SourceFileChanged:
|
||||||
|
case WingHex::ClonedFile:
|
||||||
|
case WingHex::InvalidFormat:
|
||||||
|
case WingHex::TooManyOpenedFile:
|
||||||
|
case WingHex::NotAllowedInNoneGUIThread: {
|
||||||
|
// unknown error
|
||||||
|
auto btn = WingMessageBox::critical(
|
||||||
|
this, tr("Error"), tr("UnknownErrorSure2Quit"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (btn == QMessageBox::Yes) {
|
||||||
|
closeEditor(editor, true);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case WingHex::WorkSpaceUnSaved: {
|
||||||
|
auto btn = WingMessageBox::critical(
|
||||||
|
this, tr("Error"), tr("WorkSpaceUnSavedSure2Quit"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (btn == QMessageBox::Yes) {
|
||||||
|
closeEditor(editor, true);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
closeEditor(editor, true);
|
closeEditor(editor, true);
|
||||||
|
@ -3423,8 +3496,7 @@ ErrFile MainWindow::openWorkSpace(const QString &file, EditorView **editor) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_views.insert(ev, file);
|
registerEditorView(ev, file);
|
||||||
registerEditorView(ev);
|
|
||||||
if (editor) {
|
if (editor) {
|
||||||
*editor = ev;
|
*editor = ev;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,8 @@ private:
|
||||||
void buildUpSettingDialog();
|
void buildUpSettingDialog();
|
||||||
void installPluginEditorWidgets();
|
void installPluginEditorWidgets();
|
||||||
|
|
||||||
|
void showStatus(const QString &status);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EditorView *newfileGUI();
|
EditorView *newfileGUI();
|
||||||
|
|
||||||
|
@ -238,7 +240,7 @@ private:
|
||||||
EditorView *findEditorView(const QString &filename);
|
EditorView *findEditorView(const QString &filename);
|
||||||
|
|
||||||
bool newOpenFileSafeCheck();
|
bool newOpenFileSafeCheck();
|
||||||
void registerEditorView(EditorView *editor);
|
void registerEditorView(EditorView *editor, const QString &ws = {});
|
||||||
|
|
||||||
void connectEditorView(EditorView *editor);
|
void connectEditorView(EditorView *editor);
|
||||||
void swapEditor(EditorView *old, EditorView *cur);
|
void swapEditor(EditorView *old, EditorView *cur);
|
||||||
|
@ -497,6 +499,7 @@ private:
|
||||||
private:
|
private:
|
||||||
Ribbon *m_ribbon = nullptr;
|
Ribbon *m_ribbon = nullptr;
|
||||||
ads::CDockManager *m_dock = nullptr;
|
ads::CDockManager *m_dock = nullptr;
|
||||||
|
QLabel *_status = nullptr;
|
||||||
|
|
||||||
QString m_encoding;
|
QString m_encoding;
|
||||||
|
|
||||||
|
|
|
@ -122,14 +122,14 @@ QColor MetaDialog::foreGroundColor() {
|
||||||
if (cforeground->isChecked())
|
if (cforeground->isChecked())
|
||||||
return _foreground;
|
return _foreground;
|
||||||
else
|
else
|
||||||
return QColor(qRgba(0, 0, 0, 0));
|
return QColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor MetaDialog::backGroundColor() {
|
QColor MetaDialog::backGroundColor() {
|
||||||
if (cbackground->isChecked())
|
if (cbackground->isChecked())
|
||||||
return _background;
|
return _background;
|
||||||
else
|
else
|
||||||
return QColor::fromRgba(qRgba(0, 0, 0, 0));
|
return QColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaDialog::setComment(QString comment) {
|
void MetaDialog::setComment(QString comment) {
|
||||||
|
|
|
@ -112,14 +112,18 @@ void PluginSettingDialog::on_devlist_currentRowChanged(int currentRow) {
|
||||||
|
|
||||||
auto info = plgsys.getPluginInfo(plg);
|
auto info = plgsys.getPluginInfo(plg);
|
||||||
ui->txtd->clear();
|
ui->txtd->clear();
|
||||||
ui->txtd->append(tr("ID") + " : " + info.id);
|
ui->txtd->append(getWrappedText(tr("ID") + " : " + info.id));
|
||||||
ui->txtd->append(tr("Name") + " : " + plg->pluginName());
|
ui->txtd->append(getWrappedText(tr("Name") + " : " + plg->pluginName()));
|
||||||
ui->txtd->append(tr("License") + " : " + info.license);
|
ui->txtd->append(getWrappedText(tr("License") + " : " + info.license));
|
||||||
ui->txtd->append(tr("Author") + " : " + info.author);
|
ui->txtd->append(getWrappedText(tr("Author") + " : " + info.author));
|
||||||
ui->txtd->append(tr("Vendor") + " : " + info.vendor);
|
ui->txtd->append(getWrappedText(tr("Vendor") + " : " + info.vendor));
|
||||||
ui->txtd->append(tr("Version") + " : " + info.version.toString());
|
ui->txtd->append(
|
||||||
ui->txtd->append(tr("Comment") + " : " + plg->pluginComment());
|
getWrappedText(tr("Version") + " : " + info.version.toString()));
|
||||||
ui->txtd->append(tr("URL") + " : " + info.url);
|
ui->txtd->append(
|
||||||
|
getWrappedText(tr("Comment") + " : " + plg->pluginComment()));
|
||||||
|
ui->txtd->append(getWrappedText(
|
||||||
|
tr("URL") + " : " + QStringLiteral("<a href=\"") + info.url +
|
||||||
|
QStringLiteral("\">") + info.url + QStringLiteral("</a>")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginSettingDialog::on_plglist_currentRowChanged(int currentRow) {
|
void PluginSettingDialog::on_plglist_currentRowChanged(int currentRow) {
|
||||||
|
@ -132,20 +136,30 @@ void PluginSettingDialog::on_plglist_currentRowChanged(int currentRow) {
|
||||||
|
|
||||||
auto info = plgsys.getPluginInfo(plg);
|
auto info = plgsys.getPluginInfo(plg);
|
||||||
ui->txtc->clear();
|
ui->txtc->clear();
|
||||||
ui->txtc->append(tr("ID") + " : " + info.id);
|
|
||||||
ui->txtc->append(tr("Name") + " : " + plg->pluginName());
|
ui->txtc->append(getWrappedText(tr("ID") + " : " + info.id));
|
||||||
ui->txtc->append(tr("License") + " : " + info.license);
|
ui->txtc->append(getWrappedText(tr("Name") + " : " + plg->pluginName()));
|
||||||
ui->txtc->append(tr("Author") + " : " + info.author);
|
ui->txtc->append(getWrappedText(tr("License") + " : " + info.license));
|
||||||
ui->txtc->append(tr("Vendor") + " : " + info.vendor);
|
ui->txtc->append(getWrappedText(tr("Author") + " : " + info.author));
|
||||||
ui->txtc->append(tr("Version") + " : " + info.version.toString());
|
ui->txtc->append(getWrappedText(tr("Vendor") + " : " + info.vendor));
|
||||||
ui->txtc->append(tr("Comment") + " : " + plg->pluginComment());
|
ui->txtc->append(
|
||||||
|
getWrappedText(tr("Version") + " : " + info.version.toString()));
|
||||||
|
ui->txtc->append(
|
||||||
|
getWrappedText(tr("Comment") + " : " + plg->pluginComment()));
|
||||||
if (!info.dependencies.isEmpty()) {
|
if (!info.dependencies.isEmpty()) {
|
||||||
ui->txtc->append(tr("pluginDependencies:"));
|
ui->txtc->append(getWrappedText(tr("pluginDependencies:")));
|
||||||
for (auto &d : info.dependencies) {
|
for (auto &d : info.dependencies) {
|
||||||
ui->txtc->append(QString(4, ' ') + tr("PUID:") + d.puid);
|
ui->txtc->append(
|
||||||
ui->txtc->append(QString(4, ' ') + tr("Version:") +
|
getWrappedText(QString(4, ' ') + tr("PUID:") + d.puid));
|
||||||
d.version.toString());
|
ui->txtc->append(getWrappedText(QString(4, ' ') + tr("Version:") +
|
||||||
|
d.version.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui->txtc->append(tr("URL") + " : " + info.url);
|
ui->txtc->append(getWrappedText(
|
||||||
|
tr("URL") + " : " + QStringLiteral("<a href=\"") + info.url +
|
||||||
|
QStringLiteral("\">") + info.url + QStringLiteral("</a> ")));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PluginSettingDialog::getWrappedText(const QString &str) {
|
||||||
|
return QStringLiteral("<a>") + str + QStringLiteral("</a>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,9 @@ public:
|
||||||
private slots:
|
private slots:
|
||||||
void on_devlist_currentRowChanged(int currentRow);
|
void on_devlist_currentRowChanged(int currentRow);
|
||||||
void on_plglist_currentRowChanged(int currentRow);
|
void on_plglist_currentRowChanged(int currentRow);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString getWrappedText(const QString &str);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLUGINSETTINGDIALOG_H
|
#endif // PLUGINSETTINGDIALOG_H
|
||||||
|
|
|
@ -118,7 +118,11 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QTextBrowser" name="txtc"/>
|
<widget class="QTextBrowser" name="txtc">
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -154,7 +158,11 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QTextBrowser" name="txtd"/>
|
<widget class="QTextBrowser" name="txtd">
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
Loading…
Reference in New Issue