Compare commits
7 Commits
fecbcf821e
...
a55888b0eb
Author | SHA1 | Date |
---|---|---|
|
a55888b0eb | |
|
606e55c057 | |
|
58cabdfe08 | |
|
fc4d28f681 | |
|
90241e89ff | |
|
3b4d1a1d4b | |
|
5a83a68465 |
|
@ -65,8 +65,7 @@ add_library(
|
|||
QHexEdit2/chunks.cpp
|
||||
QHexEdit2/chunks.h
|
||||
qhexview.h
|
||||
qhexview.cpp
|
||||
)
|
||||
qhexview.cpp)
|
||||
|
||||
set_target_properties(
|
||||
QHexView
|
||||
|
@ -74,6 +73,8 @@ set_target_properties(
|
|||
CXX_STANDARD 17
|
||||
CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
target_compile_definitions(QHexView PUBLIC QHEXVIEW_FIND_LIMIT=1000)
|
||||
|
||||
target_link_libraries(
|
||||
QHexView PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Concurrent)
|
||||
|
|
|
@ -414,8 +414,8 @@ void QHexDocument::applyBookMarks(const QMap<qsizetype, QString> &books) {
|
|||
emit documentChanged();
|
||||
}
|
||||
|
||||
void QHexDocument::findAllBytes(qsizetype begin, qsizetype end, QByteArray b,
|
||||
QList<qsizetype> &results,
|
||||
void QHexDocument::findAllBytes(qsizetype begin, qsizetype end,
|
||||
const QByteArray &b, QList<qsizetype> &results,
|
||||
const std::function<bool()> &pred) {
|
||||
results.clear();
|
||||
if (!b.length())
|
||||
|
@ -424,20 +424,59 @@ void QHexDocument::findAllBytes(qsizetype begin, qsizetype end, QByteArray b,
|
|||
qsizetype e = end > begin ? end : -1;
|
||||
auto offset = b.size();
|
||||
while (pred()) {
|
||||
p = m_buffer->indexOf(b, p);
|
||||
p = findNext(p, b);
|
||||
if (p < 0 || (e > 0 && p > e)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (results.size() ==
|
||||
std::numeric_limits<QList<qsizetype>::size_type>::max()) {
|
||||
if (results.size() > QHEXVIEW_FIND_LIMIT) {
|
||||
break;
|
||||
}
|
||||
results.append(p);
|
||||
p += offset + 1;
|
||||
p += offset;
|
||||
}
|
||||
}
|
||||
|
||||
qsizetype QHexDocument::findAllBytesExt(qsizetype begin, qsizetype end,
|
||||
const QString &pattern,
|
||||
QList<qsizetype> &results,
|
||||
const std::function<bool()> &pred) {
|
||||
results.clear();
|
||||
auto patterns = parseConvertPattern(pattern);
|
||||
if (patterns.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
qsizetype p = begin > 0 ? begin : 0;
|
||||
qsizetype e = end > begin ? end : -1;
|
||||
|
||||
qsizetype offset = 0;
|
||||
for (auto &p : patterns) {
|
||||
if (std::holds_alternative<QByteArray>(p)) {
|
||||
offset += std::get<QByteArray>(p).length();
|
||||
} else if (std::holds_alternative<size_t>(p)) {
|
||||
offset += std::get<size_t>(p);
|
||||
} else if (std::holds_alternative<HexWildItem>(p)) {
|
||||
offset += 1;
|
||||
}
|
||||
}
|
||||
|
||||
while (pred()) {
|
||||
p = findNextExt(p, pattern);
|
||||
if (p < 0 || (e > 0 && p > e)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (results.size() > QHEXVIEW_FIND_LIMIT) {
|
||||
break;
|
||||
}
|
||||
results.append(p);
|
||||
p += offset;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
bool QHexDocument::insert(qsizetype offset, uchar b) {
|
||||
if (m_keepsize || m_readonly || m_islocked ||
|
||||
(offset < m_buffer->length() && m_metadata->hasMetadata()))
|
||||
|
@ -499,6 +538,287 @@ bool QHexDocument::_remove(qsizetype offset, qsizetype len) {
|
|||
return true;
|
||||
}
|
||||
|
||||
qsizetype QHexDocument::findNextExt(qsizetype begin,
|
||||
const QList<FindStep> &patterns) {
|
||||
auto op = [this](qsizetype &pos, const FindStep &step,
|
||||
qsizetype *begin = nullptr) -> bool {
|
||||
if (pos < 0 || pos >= length()) {
|
||||
return false;
|
||||
}
|
||||
if (std::holds_alternative<QByteArray>(step)) {
|
||||
auto v = std::get<QByteArray>(step);
|
||||
auto len = v.length();
|
||||
auto r = findNext(pos, v);
|
||||
if (r >= 0) {
|
||||
if (begin) {
|
||||
*begin = r;
|
||||
} else {
|
||||
if (r != pos) {
|
||||
pos = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
pos = r + len;
|
||||
return true;
|
||||
} else {
|
||||
pos = -1;
|
||||
return false;
|
||||
}
|
||||
} else if (std::holds_alternative<HexWildItem>(step)) {
|
||||
auto v = std::get<HexWildItem>(step);
|
||||
auto wc = uchar(at(pos));
|
||||
pos += 1;
|
||||
|
||||
if (v.higher == '?') {
|
||||
if ((wc & 0xf) == v.lower) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ((wc >> 4) == v.higher) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (std::holds_alternative<size_t>(step)) {
|
||||
auto v = std::get<size_t>(step);
|
||||
pos += v;
|
||||
if (v + pos < length()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
while (begin < length()) {
|
||||
auto pos = begin;
|
||||
|
||||
auto p = patterns.cbegin();
|
||||
auto r = op(pos, *p, &begin);
|
||||
if (!r) {
|
||||
if (pos < 0) {
|
||||
return -1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
++p;
|
||||
|
||||
bool ok = true;
|
||||
for (; p != patterns.cend(); ++p) {
|
||||
auto r = op(pos, *p);
|
||||
if (!r) {
|
||||
ok = false;
|
||||
if (pos < 0) {
|
||||
return -1;
|
||||
}
|
||||
begin = pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
return begin;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
qsizetype QHexDocument::findPreviousExt(qsizetype begin,
|
||||
const QList<FindStep> &patterns) {
|
||||
auto op = [this](qsizetype &pos, const FindStep &step,
|
||||
qsizetype *begin = nullptr) -> bool {
|
||||
if (pos < 0 || pos >= length()) {
|
||||
return false;
|
||||
}
|
||||
if (std::holds_alternative<QByteArray>(step)) {
|
||||
auto v = std::get<QByteArray>(step);
|
||||
auto len = v.length();
|
||||
auto r = findPrevious(pos, v);
|
||||
if (r >= 0) {
|
||||
if (begin) {
|
||||
*begin = r;
|
||||
} else {
|
||||
if (r + len != pos) {
|
||||
pos = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
pos = r - len;
|
||||
return true;
|
||||
} else {
|
||||
pos = -1;
|
||||
return false;
|
||||
}
|
||||
} else if (std::holds_alternative<HexWildItem>(step)) {
|
||||
auto v = std::get<HexWildItem>(step);
|
||||
auto wc = uchar(at(pos));
|
||||
pos -= 1;
|
||||
|
||||
if (v.higher == '?') {
|
||||
if ((wc & 0xf) == v.lower) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ((wc >> 4) == v.higher) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (std::holds_alternative<size_t>(step)) {
|
||||
auto v = std::get<size_t>(step);
|
||||
pos -= v;
|
||||
if (v - pos >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
while (begin >= 0) {
|
||||
auto pos = begin;
|
||||
|
||||
auto p = patterns.crbegin();
|
||||
auto r = op(pos, *p, &begin);
|
||||
if (!r) {
|
||||
if (pos < 0) {
|
||||
return -1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
++p;
|
||||
|
||||
bool ok = true;
|
||||
for (; p != patterns.crend(); ++p) {
|
||||
auto r = op(pos, *p);
|
||||
if (!r) {
|
||||
ok = false;
|
||||
if (pos < 0) {
|
||||
return -1;
|
||||
}
|
||||
begin = pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
return begin;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
QList<QHexDocument::FindStep>
|
||||
QHexDocument::parseConvertPattern(const QString &pattern) {
|
||||
// process hex pattern
|
||||
QList<HexWildItem> words;
|
||||
std::optional<uchar> higher;
|
||||
for (auto pchar = pattern.cbegin(); pchar != pattern.cend(); ++pchar) {
|
||||
if (pchar->isSpace()) {
|
||||
if (higher) {
|
||||
return {};
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
auto c = pchar->unicode();
|
||||
if (c >= '0' && c <= '9') {
|
||||
if (higher) {
|
||||
HexWildItem item;
|
||||
item.higher = higher.value();
|
||||
item.lower = uchar(c) - '0';
|
||||
words.append(item);
|
||||
higher.reset();
|
||||
} else {
|
||||
higher = uchar(c) - '0';
|
||||
}
|
||||
} else if (c >= 'A' && c <= 'F') {
|
||||
if (higher) {
|
||||
HexWildItem item;
|
||||
item.higher = higher.value();
|
||||
item.lower = uchar(c) - 'A' + 10;
|
||||
words.append(item);
|
||||
higher.reset();
|
||||
} else {
|
||||
higher = uchar(c) - 'A' + 10;
|
||||
}
|
||||
} else if (c >= 'a' && c <= 'f') {
|
||||
if (higher) {
|
||||
HexWildItem item;
|
||||
item.higher = higher.value();
|
||||
item.lower = uchar(c) - 'a' + 10;
|
||||
words.append(item);
|
||||
higher.reset();
|
||||
} else {
|
||||
higher = uchar(c) - 'a' + 10;
|
||||
}
|
||||
} else if (c == '?') {
|
||||
if (higher) {
|
||||
HexWildItem item;
|
||||
item.higher = higher.value();
|
||||
item.lower = '?';
|
||||
words.append(item);
|
||||
higher.reset();
|
||||
} else {
|
||||
higher = '?';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (higher) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!words.isEmpty()) {
|
||||
QList<FindStep> steps;
|
||||
|
||||
// parsing...
|
||||
QByteArray buffer;
|
||||
size_t len = 0;
|
||||
for (auto pw = words.cbegin(); pw != words.cend(); ++pw) {
|
||||
auto higher = pw->higher;
|
||||
auto lower = pw->lower;
|
||||
if (higher == '?' || lower == '?') {
|
||||
if (higher == '?' && lower == '?') {
|
||||
if (!buffer.isEmpty()) {
|
||||
steps.append(buffer);
|
||||
buffer.clear();
|
||||
}
|
||||
len++;
|
||||
} else {
|
||||
if (len != 0) {
|
||||
steps.append(len);
|
||||
len = 0;
|
||||
}
|
||||
if (!buffer.isEmpty()) {
|
||||
steps.append(buffer);
|
||||
buffer.clear();
|
||||
}
|
||||
HexWildItem item;
|
||||
item.higher = higher;
|
||||
item.lower = lower;
|
||||
steps.append(item);
|
||||
}
|
||||
} else {
|
||||
if (len != 0) {
|
||||
steps.append(len);
|
||||
len = 0;
|
||||
}
|
||||
buffer.append(char(pw->higher << 4 | pw->lower));
|
||||
}
|
||||
}
|
||||
|
||||
// clean up
|
||||
if (len != 0) {
|
||||
steps.append(len);
|
||||
}
|
||||
if (!buffer.isEmpty()) {
|
||||
steps.append(buffer);
|
||||
}
|
||||
return steps;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
/*======================*/
|
||||
|
||||
// modified by wingsummer
|
||||
|
@ -728,20 +1048,39 @@ bool QHexDocument::saveTo(QIODevice *device, bool cleanUndo) {
|
|||
return true;
|
||||
}
|
||||
|
||||
qsizetype QHexDocument::searchForward(qsizetype begin, const QByteArray &ba) {
|
||||
qsizetype QHexDocument::findNext(qsizetype begin, const QByteArray &ba) {
|
||||
if (begin < 0) {
|
||||
return -1;
|
||||
}
|
||||
return m_buffer->indexOf(ba, begin);
|
||||
}
|
||||
|
||||
qsizetype QHexDocument::searchBackward(qsizetype begin, const QByteArray &ba) {
|
||||
qsizetype QHexDocument::findPrevious(qsizetype begin, const QByteArray &ba) {
|
||||
if (begin < 0) {
|
||||
return -1;
|
||||
}
|
||||
return m_buffer->lastIndexOf(ba, begin);
|
||||
}
|
||||
|
||||
qsizetype QHexDocument::findNextExt(qsizetype begin, const QString &pattern) {
|
||||
auto patterns = parseConvertPattern(pattern);
|
||||
if (patterns.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return findNextExt(begin, patterns);
|
||||
}
|
||||
|
||||
qsizetype QHexDocument::findPreviousExt(qsizetype begin,
|
||||
const QString &pattern) {
|
||||
auto patterns = parseConvertPattern(pattern);
|
||||
if (patterns.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return findPreviousExt(begin, patterns);
|
||||
}
|
||||
|
||||
QHexDocument *QHexDocument::fromLargeFile(const QString &filename,
|
||||
bool readonly) {
|
||||
|
||||
|
|
|
@ -103,7 +103,13 @@ public:
|
|||
bool existBookMark(qsizetype pos);
|
||||
|
||||
void findAllBytes(
|
||||
qsizetype begin, qsizetype end, QByteArray b, QList<qsizetype> &results,
|
||||
qsizetype begin, qsizetype end, const QByteArray &b,
|
||||
QList<qsizetype> &results,
|
||||
const std::function<bool()> &pred = [] { return true; });
|
||||
|
||||
qsizetype findAllBytesExt(
|
||||
qsizetype begin, qsizetype end, const QString &pattern,
|
||||
QList<qsizetype> &results,
|
||||
const std::function<bool()> &pred = [] { return true; });
|
||||
|
||||
bool isDocSaved();
|
||||
|
@ -179,8 +185,11 @@ public slots:
|
|||
/*================================*/
|
||||
// added by wingsummer
|
||||
|
||||
qsizetype searchForward(qsizetype begin, const QByteArray &ba);
|
||||
qsizetype searchBackward(qsizetype begin, const QByteArray &ba);
|
||||
qsizetype findNext(qsizetype begin, const QByteArray &ba);
|
||||
qsizetype findPrevious(qsizetype begin, const QByteArray &ba);
|
||||
|
||||
qsizetype findNextExt(qsizetype begin, const QString &pattern);
|
||||
qsizetype findPreviousExt(qsizetype begin, const QString &pattern);
|
||||
|
||||
bool insert(qsizetype offset, uchar b);
|
||||
bool insert(qsizetype offset, const QByteArray &data);
|
||||
|
@ -194,6 +203,20 @@ public slots:
|
|||
bool _replace(qsizetype offset, const QByteArray &data);
|
||||
bool _remove(qsizetype offset, qsizetype len);
|
||||
|
||||
private:
|
||||
// AB
|
||||
struct HexWildItem {
|
||||
uchar higher; // A
|
||||
uchar lower; // B
|
||||
};
|
||||
|
||||
// std::variant< find-content, hex with wildcard, all-wildcards >
|
||||
using FindStep = std::variant<QByteArray, HexWildItem, size_t>;
|
||||
|
||||
QList<FindStep> parseConvertPattern(const QString &pattern);
|
||||
qsizetype findNextExt(qsizetype begin, const QList<FindStep> &patterns);
|
||||
qsizetype findPreviousExt(qsizetype begin, const QList<FindStep> &patterns);
|
||||
|
||||
/*================================*/
|
||||
|
||||
/*================================*/
|
||||
|
|
|
@ -104,29 +104,6 @@ void QHexMetadata::Clear() {
|
|||
}
|
||||
}
|
||||
|
||||
QUndoCommand *QHexMetadata::MakeColor(QUndoCommand *parent, qsizetype begin,
|
||||
qsizetype end, const QColor &fgcolor,
|
||||
const QColor &bgcolor) {
|
||||
return MakeMetadata(parent, begin, end, fgcolor, bgcolor, QString());
|
||||
}
|
||||
|
||||
QUndoCommand *QHexMetadata::MakeForeground(QUndoCommand *parent,
|
||||
qsizetype begin, qsizetype end,
|
||||
const QColor &fgcolor) {
|
||||
return MakeMetadata(parent, begin, end, fgcolor, QColor(), QString());
|
||||
}
|
||||
|
||||
QUndoCommand *QHexMetadata::MakeBackground(QUndoCommand *parent,
|
||||
qsizetype begin, qsizetype end,
|
||||
const QColor &bgcolor) {
|
||||
return MakeMetadata(parent, begin, end, QColor(), bgcolor, QString());
|
||||
}
|
||||
|
||||
QUndoCommand *QHexMetadata::MakeComment(QUndoCommand *parent, qsizetype begin,
|
||||
qsizetype end, const QString &comment) {
|
||||
return MakeMetadata(parent, begin, end, QColor(), QColor(), comment);
|
||||
}
|
||||
|
||||
QUndoCommand *
|
||||
QHexMetadata::MakeModifyMetadata(QUndoCommand *parent,
|
||||
const QHexMetadataItem &newmeta,
|
||||
|
|
|
@ -197,16 +197,6 @@ public:
|
|||
const QColor &bgcolor, const QString &comment);
|
||||
void Clear();
|
||||
|
||||
QUndoCommand *MakeColor(QUndoCommand *parent, qsizetype begin,
|
||||
qsizetype end, const QColor &fgcolor,
|
||||
const QColor &bgcolor);
|
||||
QUndoCommand *MakeForeground(QUndoCommand *parent, qsizetype begin,
|
||||
qsizetype end, const QColor &fgcolor);
|
||||
QUndoCommand *MakeBackground(QUndoCommand *parent, qsizetype begin,
|
||||
qsizetype end, const QColor &bgcolor);
|
||||
QUndoCommand *MakeComment(QUndoCommand *parent, qsizetype begin,
|
||||
qsizetype end, const QString &comment);
|
||||
|
||||
QUndoCommand *MakeModifyMetadata(QUndoCommand *parent,
|
||||
const QHexMetadataItem &newmeta,
|
||||
const QHexMetadataItem &oldmeta);
|
||||
|
|
|
@ -157,14 +157,18 @@ bool QHexRenderer::hitTest(const QPoint &pt, QHexPosition *position,
|
|||
this->documentLastLine());
|
||||
position->lineWidth = quint8(this->hexLineWidth());
|
||||
|
||||
auto hspace = m_fontmetrics.horizontalAdvance(' ') / 2;
|
||||
|
||||
if (area == QHexRenderer::HexArea) {
|
||||
int relx = pt.x() - this->getHexColumnX() - this->borderSize();
|
||||
auto relx =
|
||||
pt.x() - hspace - this->getHexColumnX() - this->borderSize();
|
||||
int column = int(relx / this->getCellWidth());
|
||||
position->column = column / 3;
|
||||
// first char is nibble 1, 2nd and space are 0
|
||||
position->nibbleindex = (column % 3 == 0) ? 1 : 0;
|
||||
} else {
|
||||
int relx = pt.x() - this->getAsciiColumnX() - this->borderSize();
|
||||
auto relx =
|
||||
pt.x() - hspace - this->getAsciiColumnX() - this->borderSize();
|
||||
position->column = int(relx / this->getCellWidth());
|
||||
position->nibbleindex = 1;
|
||||
}
|
||||
|
@ -240,7 +244,7 @@ QString QHexRenderer::hexString(qsizetype line, QByteArray *rawline) const {
|
|||
if (rawline)
|
||||
*rawline = lrawline;
|
||||
|
||||
return lrawline.toHex(' ').toUpper() + QStringLiteral(" ");
|
||||
return toHexSequence(lrawline);
|
||||
}
|
||||
|
||||
// modified by wingsummer
|
||||
|
@ -316,11 +320,42 @@ void QHexRenderer::unprintableChars(QByteArray &ascii) const {
|
|||
}
|
||||
}
|
||||
|
||||
QByteArray QHexRenderer::toHexSequence(const QByteArray &arr) {
|
||||
if (arr.isEmpty()) {
|
||||
return QByteArray(1, '\t');
|
||||
}
|
||||
const int length = arr.size() * 4;
|
||||
QByteArray hex(length, Qt::Uninitialized);
|
||||
char *hexData = hex.data();
|
||||
const uchar *data = (const uchar *)arr.data();
|
||||
for (int i = 0, o = 1; i < arr.size(); ++i) {
|
||||
hexData[o++] = toHexUpper(data[i] >> 4);
|
||||
hexData[o++] = toHexUpper(data[i] & 0xf);
|
||||
if (o < length) {
|
||||
hexData[o++] = '\t';
|
||||
}
|
||||
if (o < length) {
|
||||
hexData[o++] = '\t';
|
||||
}
|
||||
}
|
||||
|
||||
hex.front() = '\t';
|
||||
return hex;
|
||||
}
|
||||
|
||||
char QHexRenderer::toHexUpper(uint value) noexcept {
|
||||
return "0123456789ABCDEF"[value & 0xF];
|
||||
}
|
||||
|
||||
void QHexRenderer::applyDocumentStyles(QPainter *painter,
|
||||
QTextDocument *textdocument) const {
|
||||
textdocument->setDocumentMargin(0);
|
||||
textdocument->setUndoRedoEnabled(false);
|
||||
textdocument->setDefaultFont(painter->font());
|
||||
auto font = painter->font();
|
||||
textdocument->setDefaultFont(font);
|
||||
auto textopt = textdocument->defaultTextOption();
|
||||
textopt.setTabStopDistance(QFontMetricsF(font).horizontalAdvance(' ') / 2);
|
||||
textdocument->setDefaultTextOption(textopt);
|
||||
}
|
||||
|
||||
void QHexRenderer::applyBasicStyle(QTextCursor &textcursor,
|
||||
|
@ -392,9 +427,8 @@ void QHexRenderer::applyMetadata(QTextCursor &textcursor, qsizetype line,
|
|||
}
|
||||
|
||||
textcursor.setPosition(int(mi.start * factor));
|
||||
textcursor.movePosition(
|
||||
QTextCursor::Right, QTextCursor::KeepAnchor,
|
||||
int((mi.length * factor) - (factor > 1 ? 1 : 0)));
|
||||
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
|
||||
int((mi.length * factor)));
|
||||
textcursor.mergeCharFormat(charformat);
|
||||
}
|
||||
}
|
||||
|
@ -522,10 +556,6 @@ void QHexRenderer::applySelection(const QVector<QHexMetadata::MetaInfo> &metas,
|
|||
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
|
||||
mlen * factor);
|
||||
|
||||
if (factor == Hex)
|
||||
textcursor.movePosition(QTextCursor::Left,
|
||||
QTextCursor::KeepAnchor, 1);
|
||||
|
||||
if (!strikeOut) {
|
||||
QColor fg, bg = charfmt.background().color();
|
||||
|
||||
|
@ -555,26 +585,12 @@ void QHexRenderer::applySelection(const QVector<QHexMetadata::MetaInfo> &metas,
|
|||
textcursor.mergeCharFormat(charfmt_meta);
|
||||
textcursor.clearSelection();
|
||||
totallen -= mlen;
|
||||
|
||||
if (totallen > 0) {
|
||||
if (factor == Hex) {
|
||||
textcursor.movePosition(QTextCursor::Right,
|
||||
QTextCursor::KeepAnchor, 1);
|
||||
textcursor.mergeCharFormat(charfmt);
|
||||
textcursor.clearSelection();
|
||||
}
|
||||
}
|
||||
|
||||
fmtBegin = mi.end - startLineOffset + 1;
|
||||
}
|
||||
|
||||
if (totallen > 0) {
|
||||
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
|
||||
totallen * factor);
|
||||
if (factor == Hex)
|
||||
textcursor.movePosition(QTextCursor::Left,
|
||||
QTextCursor::KeepAnchor, 1);
|
||||
|
||||
textcursor.mergeCharFormat(charfmt);
|
||||
textcursor.clearSelection();
|
||||
}
|
||||
|
@ -582,9 +598,6 @@ void QHexRenderer::applySelection(const QVector<QHexMetadata::MetaInfo> &metas,
|
|||
textcursor.setPosition(lineStart * factor);
|
||||
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
|
||||
totallen * factor);
|
||||
if (factor == Hex)
|
||||
textcursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor,
|
||||
1);
|
||||
textcursor.mergeCharFormat(charfmt);
|
||||
}
|
||||
}
|
||||
|
@ -620,10 +633,19 @@ void QHexRenderer::applyCursorHex(QTextCursor &textcursor,
|
|||
return;
|
||||
|
||||
textcursor.clearSelection();
|
||||
textcursor.setPosition(m_cursor->currentColumn() * 3);
|
||||
|
||||
if ((m_selectedarea == QHexRenderer::HexArea) && !m_cursor->currentNibble())
|
||||
textcursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor);
|
||||
auto col = m_cursor->currentColumn();
|
||||
textcursor.setPosition(col * Factor::Hex);
|
||||
|
||||
if (m_selectedarea == QHexRenderer::HexArea) {
|
||||
if (m_cursor->currentNibble()) {
|
||||
textcursor.movePosition(QTextCursor::Right,
|
||||
QTextCursor::MoveAnchor);
|
||||
} else {
|
||||
textcursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor,
|
||||
2);
|
||||
}
|
||||
}
|
||||
|
||||
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
||||
|
||||
|
@ -706,7 +728,7 @@ void QHexRenderer::applyBookMark(QTextCursor &textcursor, qsizetype line,
|
|||
return;
|
||||
|
||||
auto pos = m_document->getLineBookmarksPos(line);
|
||||
for (auto item : pos) {
|
||||
for (auto &item : pos) {
|
||||
textcursor.setPosition(int((item % hexLineWidth()) * factor) + 2);
|
||||
auto charformat = textcursor.charFormat();
|
||||
textcursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor,
|
||||
|
@ -754,21 +776,27 @@ void QHexRenderer::drawString(QPainter *painter, const QRect &linerect,
|
|||
void QHexRenderer::drawHeader(QPainter *painter) {
|
||||
QRect rect = QRect(0, 0, this->getEndColumnX(),
|
||||
this->headerLineCount() * this->lineHeight());
|
||||
QString hexheader;
|
||||
|
||||
for (quint8 i = 0; i < this->hexLineWidth(); i++)
|
||||
hexheader.append(
|
||||
QString("%1 ")
|
||||
.arg(QString::number(i, 16).rightJustified(2, QChar('0')))
|
||||
.toUpper());
|
||||
auto len = this->hexLineWidth();
|
||||
QString hexheader;
|
||||
hexheader.reserve(len * 3);
|
||||
for (quint8 i = 0; i < len; i++) {
|
||||
hexheader.append(toHexUpper(i >> 4));
|
||||
hexheader.append(toHexUpper(i & 0xf));
|
||||
hexheader.append(' ');
|
||||
}
|
||||
|
||||
auto font = painter->font();
|
||||
auto space = QFontMetricsF(font).horizontalAdvance(' ') / 2;
|
||||
|
||||
QRect addressrect = rect;
|
||||
addressrect.setWidth(this->getHexColumnX());
|
||||
|
||||
QRect hexrect = rect;
|
||||
|
||||
hexrect.setX(m_addressVisible ? this->getHexColumnX() + this->borderSize()
|
||||
: this->borderSize());
|
||||
hexrect.setX(m_addressVisible
|
||||
? (this->getHexColumnX() + this->borderSize() + space)
|
||||
: this->borderSize());
|
||||
hexrect.setWidth(this->getNCellsWidth(hexLineWidth() * 3));
|
||||
|
||||
QRect asciirect = rect;
|
||||
|
|
|
@ -119,9 +119,13 @@ private:
|
|||
int getNCellsWidth(int n) const;
|
||||
void unprintableChars(QByteArray &ascii) const;
|
||||
|
||||
private:
|
||||
static QByteArray toHexSequence(const QByteArray &arr);
|
||||
static char toHexUpper(uint value) noexcept;
|
||||
|
||||
private:
|
||||
// modified by wingsummer
|
||||
enum Factor { String = 1, Hex = 3 };
|
||||
enum Factor { String = 1, Hex = 4 };
|
||||
|
||||
void applyDocumentStyles(QPainter *painter,
|
||||
QTextDocument *textdocument) const;
|
||||
|
|
|
@ -336,21 +336,21 @@ void QHexView::setCopyLimit(qsizetype newCopylimit) {
|
|||
|
||||
qreal QHexView::scaleRate() const { return m_scaleRate; }
|
||||
|
||||
qsizetype QHexView::searchForward(qsizetype begin, const QByteArray &ba) {
|
||||
qsizetype QHexView::findNext(qsizetype begin, const QByteArray &ba) {
|
||||
if (begin < 0) {
|
||||
begin = m_cursor->position().offset();
|
||||
}
|
||||
return m_document->searchForward(begin, ba);
|
||||
return m_document->findNext(begin, ba);
|
||||
}
|
||||
|
||||
qsizetype QHexView::searchBackward(qsizetype begin, const QByteArray &ba) {
|
||||
qsizetype QHexView::findPrevious(qsizetype begin, const QByteArray &ba) {
|
||||
qsizetype startPos;
|
||||
if (begin < 0) {
|
||||
startPos = m_cursor->position().offset() - 1;
|
||||
} else {
|
||||
startPos = begin;
|
||||
}
|
||||
return m_document->searchBackward(startPos, ba);
|
||||
return m_document->findPrevious(startPos, ba);
|
||||
}
|
||||
|
||||
bool QHexView::RemoveSelection(int nibbleindex) {
|
||||
|
|
|
@ -122,8 +122,8 @@ public:
|
|||
void setScaleRate(qreal rate);
|
||||
qreal scaleRate() const;
|
||||
|
||||
qsizetype searchForward(qsizetype begin, const QByteArray &ba);
|
||||
qsizetype searchBackward(qsizetype begin, const QByteArray &ba);
|
||||
qsizetype findNext(qsizetype begin, const QByteArray &ba);
|
||||
qsizetype findPrevious(qsizetype begin, const QByteArray &ba);
|
||||
|
||||
bool RemoveSelection(int nibbleindex = 1);
|
||||
bool removeSelection();
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6689d14c203eed390ae7bb64f56a983cfd7dff9c
|
||||
Subproject commit c37b5ed7364f4fc1c58e92d13399cd04656e6572
|
|
@ -8,7 +8,7 @@ set(CMAKE_AUTORCC ON)
|
|||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(PROJECT_VERSION "2.1.0")
|
||||
set(PROJECT_VERSION "2.2.0")
|
||||
|
||||
find_package(
|
||||
QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network Concurrent
|
||||
|
@ -165,8 +165,6 @@ set(DIALOG_SRC
|
|||
src/dialog/colorpickerdialog.h
|
||||
src/dialog/colorpickerdialog.cpp
|
||||
src/dialog/colorpickerdialog.ui
|
||||
src/dialog/showtextdialog.h
|
||||
src/dialog/showtextdialog.cpp
|
||||
src/dialog/splashdialog.ui
|
||||
src/dialog/splashdialog.cpp
|
||||
src/dialog/splashdialog.h
|
||||
|
@ -207,7 +205,9 @@ set(CONTROL_SRC
|
|||
src/control/qtlonglongspinbox.cpp
|
||||
src/control/qtlonglongspinbox.h
|
||||
src/control/dockwidgettab.h
|
||||
src/control/dockwidgettab.cpp)
|
||||
src/control/dockwidgettab.cpp
|
||||
src/control/qhextextedit.h
|
||||
src/control/qhextextedit.cpp)
|
||||
|
||||
set(CLASS_SRC
|
||||
src/class/logger.cpp
|
||||
|
@ -235,8 +235,6 @@ set(CLASS_SRC
|
|||
src/class/languagemanager.cpp
|
||||
src/class/settingmanager.h
|
||||
src/class/settingmanager.cpp
|
||||
src/class/wingprogressdialog.h
|
||||
src/class/wingprogressdialog.cpp
|
||||
src/class/asdebugger.h
|
||||
src/class/asdebugger.cpp
|
||||
src/class/scriptconsolemachine.h
|
||||
|
@ -282,7 +280,11 @@ set(CLASS_SRC
|
|||
src/class/diffutil.cpp
|
||||
src/class/clickcallback.h
|
||||
src/class/crashhandler.h
|
||||
src/class/crashhandler.cpp)
|
||||
src/class/crashhandler.cpp
|
||||
src/class/pluginsystem.h
|
||||
src/class/pluginsystem.cpp
|
||||
src/class/inspectqtloghelper.h
|
||||
src/class/inspectqtloghelper.cpp)
|
||||
|
||||
set(INTERNAL_PLG_SRC
|
||||
src/class/wingangelapi.h src/class/wingangelapi.cpp
|
||||
|
@ -373,11 +375,6 @@ set(CODEEDIT_WIDGET
|
|||
src/qcodeeditwidget/formatconfigmodel.h
|
||||
src/qcodeeditwidget/formatconfigmodel.cpp)
|
||||
|
||||
set(PLUGIN_SRC
|
||||
src/plugin/iwingplugin.h src/plugin/iwingpluginbase.h
|
||||
src/plugin/iwingdevice.h src/plugin/pluginsystem.cpp
|
||||
src/plugin/pluginsystem.h src/plugin/settingpage.h)
|
||||
|
||||
# localization support
|
||||
file(
|
||||
GLOB_RECURSE TS_FILES
|
||||
|
@ -470,7 +467,6 @@ set(PROJECT_SOURCES
|
|||
${INTERNAL_PLG_SRC}
|
||||
${MODEL_SRC}
|
||||
${DIALOG_SRC}
|
||||
${PLUGIN_SRC}
|
||||
${CONTROL_SRC}
|
||||
${SETTING_SRC}
|
||||
${SCRIPT_ADDON_SRC}
|
||||
|
@ -522,6 +518,7 @@ target_link_libraries(
|
|||
Qt${QT_VERSION_MAJOR}::Xml
|
||||
cpptrace::cpptrace
|
||||
QtSingleApplication::QtSingleApplication
|
||||
WingPlugin
|
||||
QHexView
|
||||
QCodeEditor2
|
||||
QJsonModel
|
||||
|
@ -576,3 +573,4 @@ if(${QT_VERSION_MAJOR} EQUAL 6)
|
|||
install(SCRIPT ${deploy_script})
|
||||
endif()
|
||||
endif()
|
||||
add_subdirectory(WingPlugin)
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
|
||||
  如果你想将本软件的代码用于闭源的商业代码,想要解除`GPL`系列的必须开源的限制,请必须亲自咨询我,商讨商业授权相关事宜。
|
||||
|
||||
  对于插件开发相关的,对应的开源协议就不一样了。只针对本仓库下的`src/plugin/iwingplugin.h`、`src/plugin/iwingpluginbase.h`、`src/plugin/iwingdevice.h`和`src/plugin/settingpage.h`遵守`BSD 3-Clause`协议,以允许想要做闭源和商业开发。对于本仓库下的`TestPlugin`的代码(除`TranslationUtils.cmake`这一个文件遵守`BSD 3-Clause`)遵守`MIT`协议。
|
||||
  对于插件开发相关的,对应的开源协议就不一样了。只针对本仓库下的`WingPlugin`的代码遵守`BSD 3-Clause`协议,以允许闭源商业开发。对于本仓库下的`TestPlugin`的代码(除`TranslationUtils.cmake`这一个文件遵守`BSD 3-Clause`)遵守`MIT`协议。
|
||||
|
||||
### 使用声明
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ This software complies with the `AGPL-3.0` agreement. Please do not use it for p
|
|||
|
||||
If you want to use the code of this software for closed-source commercial code and want to lift the restriction of the `GPL` series that it must be open source, please consult me in person to discuss commercial licensing matters.
|
||||
|
||||
For plugin development, the corresponding open source agreements are different. Only `src/plugin/iwingplugin.h`, `src/plugin/iwingpluginbase.h`, `src/plugin/iwingdevice.h` and `src/plugin/settingpage.h` in this repository comply with the `BSD 3-Clause` agreement to allow closed-source and commercial development. The code of `TestPlugin` in this repository (except the file `TranslationUtils.cmake` which complies with `BSD 3-Clause`) complies with the `MIT` agreement.
|
||||
For plugin development, the corresponding open source agreements are different. Only the code of `WingPlugin` in this repository comply with the `BSD 3-Clause` agreement to allow closed-source commercial development. The code of `TestPlugin` in this repository (except the file `TranslationUtils.cmake` which complies with `BSD 3-Clause`) complies with the `MIT` agreement.
|
||||
|
||||
### Usage Statement
|
||||
|
||||
|
|
|
@ -18,39 +18,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
|||
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
option(TEST_MODE TRUE)
|
||||
|
||||
# Set the location where the SDK is stored. Only iwingplugin.h and settingpage.h
|
||||
# are required.
|
||||
|
||||
# 设置存放 SDK 的位置,只须 iwingplugin.h 和 settingpage.h 存在
|
||||
|
||||
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
set(WINGHEX_SDK "${CMAKE_CURRENT_SOURCE_DIR}/../src/plugin")
|
||||
|
||||
set(PLUGIN_INTERFACE_BASE_FOUND FALSE)
|
||||
set(PLUGIN_INTERFACE_FOUND FALSE)
|
||||
set(PLUGIN_SETPAGE_FOUND FALSE)
|
||||
if(EXISTS "${WINGHEX_SDK}/iwingpluginbase.h")
|
||||
set(PLUGIN_INTERFACE_BASE_FOUND TRUE)
|
||||
endif()
|
||||
if(EXISTS "${WINGHEX_SDK}/iwingdevice.h")
|
||||
set(PLUGIN_INTERFACE_FOUND TRUE)
|
||||
endif()
|
||||
if(EXISTS "${WINGHEX_SDK}/settingpage.h")
|
||||
set(PLUGIN_SETPAGE_FOUND TRUE)
|
||||
endif()
|
||||
if(PLUGIN_INTERFACE_FOUND
|
||||
AND PLUGIN_INTERFACE_BASE_FOUND
|
||||
AND PLUGIN_SETPAGE_FOUND)
|
||||
message(STATUS "${WINGHEX_SDK} is valid SDK path")
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid SDK path!")
|
||||
endif()
|
||||
|
||||
set(WINGHEX_SDK_HEADER
|
||||
"${WINGHEX_SDK}/iwingdevice.h" "${WINGHEX_SDK}/iwingpluginbase.h"
|
||||
"${WINGHEX_SDK}/settingpage.h")
|
||||
include_directories(${WINGHEX_SDK})
|
||||
|
||||
# For Qt
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
|
||||
find_package(
|
||||
|
@ -81,7 +48,6 @@ add_plugin_translations_resource(QM_RES shmem ${QM_FILES})
|
|||
|
||||
add_library(
|
||||
ShareMemoryDrv SHARED
|
||||
${WINGHEX_SDK_HEADER}
|
||||
sharememorydrv.h
|
||||
sharememorydrv.cpp
|
||||
ShareMemoryDrv.json
|
||||
|
@ -112,4 +78,4 @@ if(TEST_MODE)
|
|||
$<TARGET_FILE:ShareMemoryDrv> ${WINGHEX_DRV_PATH})
|
||||
endif()
|
||||
|
||||
target_link_libraries(ShareMemoryDrv PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
target_link_libraries(ShareMemoryDrv PRIVATE Qt${QT_VERSION_MAJOR}::Widgets WingPlugin)
|
||||
|
|
|
@ -4,27 +4,27 @@
|
|||
<context>
|
||||
<name>SharedMemoryDriver</name>
|
||||
<message>
|
||||
<location filename="../sharememorydrv.cpp" line="42"/>
|
||||
<location filename="../sharememorydrv.cpp" line="38"/>
|
||||
<source>SharedMemoryDriver</source>
|
||||
<translation>共享内存驱动</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sharememorydrv.cpp" line="46"/>
|
||||
<location filename="../sharememorydrv.cpp" line="42"/>
|
||||
<source>An extension for opening sshared memory in WingHexExplorer2.</source>
|
||||
<translation>一个提供羽云十六进制编辑器2的插件打开共享内存的驱动</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sharememorydrv.cpp" line="66"/>
|
||||
<location filename="../sharememorydrv.cpp" line="62"/>
|
||||
<source>ShareMemory</source>
|
||||
<translation>共享内存</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sharememorydrv.cpp" line="76"/>
|
||||
<location filename="../sharememorydrv.cpp" line="71"/>
|
||||
<source>SharedMemory</source>
|
||||
<translation>共享内存</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sharememorydrv.cpp" line="76"/>
|
||||
<location filename="../sharememorydrv.cpp" line="71"/>
|
||||
<source>PleaseInputID:</source>
|
||||
<translation>请输入标识:</translation>
|
||||
</message>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef SHAREDMEMORY_H
|
||||
#define SHAREDMEMORY_H
|
||||
|
||||
#include "iwingdevice.h"
|
||||
#include "WingPlugin/iwingdevice.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QSharedMemory>
|
||||
|
|
|
@ -25,10 +25,6 @@ SharedMemoryDriver::~SharedMemoryDriver() {}
|
|||
|
||||
int SharedMemoryDriver::sdkVersion() const { return WingHex::SDKVERSION; }
|
||||
|
||||
const QString SharedMemoryDriver::signature() const {
|
||||
return WingHex::WINGSUMMER;
|
||||
}
|
||||
|
||||
bool SharedMemoryDriver::init(const std::unique_ptr<QSettings> &set) {
|
||||
Q_UNUSED(set);
|
||||
return true;
|
||||
|
@ -72,9 +68,8 @@ QIcon SharedMemoryDriver::supportedFileIcon() const {
|
|||
|
||||
QString SharedMemoryDriver::onOpenFileBegin() {
|
||||
bool ok;
|
||||
auto id =
|
||||
emit inputbox.getText(nullptr, tr("SharedMemory"), tr("PleaseInputID:"),
|
||||
QLineEdit::Normal, {}, &ok);
|
||||
auto id = dlgGetText(nullptr, tr("SharedMemory"), tr("PleaseInputID:"),
|
||||
QLineEdit::Normal, {}, &ok);
|
||||
if (!ok) {
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef SHAREDMEMORYDRIVER_H
|
||||
#define SHAREDMEMORYDRIVER_H
|
||||
|
||||
#include "iwingdevice.h"
|
||||
#include "WingPlugin/iwingdevice.h"
|
||||
|
||||
class SharedMemoryDriver final : public WingHex::IWingDevice {
|
||||
Q_OBJECT
|
||||
|
@ -35,7 +35,6 @@ public:
|
|||
// IWingPlugin interface
|
||||
public:
|
||||
virtual int sdkVersion() const override;
|
||||
virtual const QString signature() const override;
|
||||
virtual bool init(const std::unique_ptr<QSettings> &set) override;
|
||||
virtual void unload(std::unique_ptr<QSettings> &set) override;
|
||||
virtual const QString pluginName() const override;
|
||||
|
|
|
@ -18,39 +18,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
|||
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
option(TEST_MODE TRUE)
|
||||
|
||||
# Set the location where the SDK is stored. Only iwingplugin.h and settingpage.h
|
||||
# are required.
|
||||
|
||||
# 设置存放 SDK 的位置,只须 iwingplugin.h 和 settingpage.h 存在
|
||||
|
||||
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
set(WINGHEX_SDK "${CMAKE_CURRENT_SOURCE_DIR}/../src/plugin")
|
||||
|
||||
set(PLUGIN_INTERFACE_BASE_FOUND FALSE)
|
||||
set(PLUGIN_INTERFACE_FOUND FALSE)
|
||||
set(PLUGIN_SETPAGE_FOUND FALSE)
|
||||
if(EXISTS "${WINGHEX_SDK}/iwingpluginbase.h")
|
||||
set(PLUGIN_INTERFACE_BASE_FOUND TRUE)
|
||||
endif()
|
||||
if(EXISTS "${WINGHEX_SDK}/iwingplugin.h")
|
||||
set(PLUGIN_INTERFACE_FOUND TRUE)
|
||||
endif()
|
||||
if(EXISTS "${WINGHEX_SDK}/settingpage.h")
|
||||
set(PLUGIN_SETPAGE_FOUND TRUE)
|
||||
endif()
|
||||
if(PLUGIN_INTERFACE_FOUND
|
||||
AND PLUGIN_INTERFACE_BASE_FOUND
|
||||
AND PLUGIN_SETPAGE_FOUND)
|
||||
message(STATUS "${WINGHEX_SDK} is valid SDK path")
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid SDK path!")
|
||||
endif()
|
||||
|
||||
set(WINGHEX_SDK_HEADER
|
||||
"${WINGHEX_SDK}/iwingplugin.h" "${WINGHEX_SDK}/iwingpluginbase.h"
|
||||
"${WINGHEX_SDK}/settingpage.h")
|
||||
include_directories(${WINGHEX_SDK})
|
||||
|
||||
# For Qt
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
|
||||
find_package(
|
||||
|
@ -77,7 +44,6 @@ add_plugin_translations_resource(QM_RES TestPlugin ${QM_FILES})
|
|||
|
||||
add_library(
|
||||
TestPlugin SHARED
|
||||
${WINGHEX_SDK_HEADER}
|
||||
testplugin.h
|
||||
testplugin.cpp
|
||||
TestPlugin.json
|
||||
|
@ -125,4 +91,4 @@ if(TEST_MODE)
|
|||
${WINGHEX_PLUGIN_PATH})
|
||||
endif()
|
||||
|
||||
target_link_libraries(TestPlugin PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
target_link_libraries(TestPlugin PRIVATE Qt${QT_VERSION_MAJOR}::Widgets WingPlugin)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
CtlTestForm::CtlTestForm(WingHex::IWingPlugin *plg, QTextBrowser *br,
|
||||
QWidget *parent)
|
||||
: QWidget(parent), ui(new Ui::CtlTestForm), _plg(plg), _br(br) {
|
||||
: WingHex::WingPluginWidget(plg, parent), ui(new Ui::CtlTestForm), _br(br) {
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,8 @@ CtlTestForm::~CtlTestForm() { delete ui; }
|
|||
|
||||
void CtlTestForm::on_btnInt8_clicked() {
|
||||
bool ok;
|
||||
auto ret = emit _plg->inputbox.getInt(this, QStringLiteral("Test"),
|
||||
tr("PleaseInputInt8"), 0, INT8_MIN,
|
||||
UINT8_MAX, 1, &ok);
|
||||
auto ret = dlgGetInt(this, QStringLiteral("Test"), tr("PleaseInputInt8"), 0,
|
||||
INT8_MIN, UINT8_MAX, 1, &ok);
|
||||
if (ok) {
|
||||
auto buffer = qint8(ret);
|
||||
if (ui->rbInsert->isChecked()) {
|
||||
|
@ -56,9 +55,8 @@ void CtlTestForm::on_btnInt8_clicked() {
|
|||
|
||||
void CtlTestForm::on_btnInt16_clicked() {
|
||||
bool ok;
|
||||
auto ret = emit _plg->inputbox.getInt(this, QStringLiteral("Test"),
|
||||
tr("PleaseInputInt16"), 0, INT16_MIN,
|
||||
UINT16_MAX, 1, &ok);
|
||||
auto ret = dlgGetInt(this, QStringLiteral("Test"), tr("PleaseInputInt16"),
|
||||
0, INT16_MIN, UINT16_MAX, 1, &ok);
|
||||
if (ok) {
|
||||
auto buffer = qint16(ret);
|
||||
if (ui->rbInsert->isChecked()) {
|
||||
|
@ -81,9 +79,8 @@ void CtlTestForm::on_btnInt16_clicked() {
|
|||
|
||||
void CtlTestForm::on_btnInt32_clicked() {
|
||||
bool ok;
|
||||
auto ret = emit _plg->inputbox.getInt(this, QStringLiteral("Test"),
|
||||
tr("PleaseInputInt32"), 0, INT32_MIN,
|
||||
UINT32_MAX, 1, &ok);
|
||||
auto ret = dlgGetInt(this, QStringLiteral("Test"), tr("PleaseInputInt32"),
|
||||
0, INT32_MIN, INT32_MAX, 1, &ok);
|
||||
if (ok) {
|
||||
auto buffer = qint32(ret);
|
||||
if (ui->rbInsert->isChecked()) {
|
||||
|
@ -106,9 +103,8 @@ void CtlTestForm::on_btnInt32_clicked() {
|
|||
|
||||
void CtlTestForm::on_btnInt64_clicked() {
|
||||
bool ok;
|
||||
auto ret = emit _plg->inputbox.getText(
|
||||
this, QStringLiteral("Test"), tr("PleaseInputInt64"), QLineEdit::Normal,
|
||||
QStringLiteral("0"), &ok);
|
||||
auto ret = dlgGetText(this, QStringLiteral("Test"), tr("PleaseInputInt64"),
|
||||
QLineEdit::Normal, QStringLiteral("0"), &ok);
|
||||
if (ok) {
|
||||
auto buffer = qint64(ret.toULongLong(&ok));
|
||||
if (ok) {
|
||||
|
@ -134,9 +130,9 @@ void CtlTestForm::on_btnInt64_clicked() {
|
|||
void CtlTestForm::on_btnFloat_clicked() {
|
||||
bool ok;
|
||||
auto limit = std::numeric_limits<float>();
|
||||
auto ret = emit _plg->inputbox.getDouble(
|
||||
this, QStringLiteral("Test"), tr("PleaseInputFloat"), 0, limit.min(),
|
||||
limit.max(), 0.0, &ok);
|
||||
auto ret =
|
||||
dlgGetDouble(this, QStringLiteral("Test"), tr("PleaseInputFloat"), 0,
|
||||
limit.min(), limit.max(), 0.0, &ok);
|
||||
if (ok) {
|
||||
auto buffer = float(ret);
|
||||
if (ui->rbInsert->isChecked()) {
|
||||
|
@ -160,9 +156,9 @@ void CtlTestForm::on_btnFloat_clicked() {
|
|||
void CtlTestForm::on_btnDouble_clicked() {
|
||||
bool ok;
|
||||
auto limit = std::numeric_limits<double>();
|
||||
auto ret = emit _plg->inputbox.getDouble(
|
||||
this, QStringLiteral("Test"), tr("PleaseInputFloat"), 0, limit.min(),
|
||||
limit.max(), 0.0, &ok);
|
||||
auto ret =
|
||||
dlgGetDouble(this, QStringLiteral("Test"), tr("PleaseInputFloat"), 0,
|
||||
limit.min(), limit.max(), 0.0, &ok);
|
||||
if (ok) {
|
||||
auto buffer = double(ret);
|
||||
if (ui->rbInsert->isChecked()) {
|
||||
|
@ -185,9 +181,9 @@ void CtlTestForm::on_btnDouble_clicked() {
|
|||
|
||||
void CtlTestForm::on_btnString_clicked() {
|
||||
bool ok;
|
||||
auto buffer = emit _plg->inputbox.getText(
|
||||
this, QStringLiteral("Test"), tr("PleaseInputString"),
|
||||
QLineEdit::Normal, WingHex::WINGSUMMER, &ok);
|
||||
auto buffer =
|
||||
dlgGetText(this, QStringLiteral("Test"), tr("PleaseInputString"),
|
||||
QLineEdit::Normal, "wingsummer", &ok);
|
||||
if (ok) {
|
||||
if (ui->rbInsert->isChecked()) {
|
||||
ok = insertContent(ui->sbOffset->value(), buffer);
|
||||
|
@ -201,9 +197,9 @@ void CtlTestForm::on_btnString_clicked() {
|
|||
|
||||
void CtlTestForm::on_btnByteArray_clicked() {
|
||||
bool ok;
|
||||
auto ret = emit _plg->inputbox.getText(
|
||||
this, QStringLiteral("Test"), tr("PleaseInputByteArray(00 23 5A)"),
|
||||
QLineEdit::Normal, QStringLiteral("00"), &ok);
|
||||
auto ret = dlgGetText(this, QStringLiteral("Test"),
|
||||
tr("PleaseInputByteArray(00 23 5A)"),
|
||||
QLineEdit::Normal, QStringLiteral("00"), &ok);
|
||||
if (ok) {
|
||||
auto buffer = QByteArray::fromHex(ret.toUtf8());
|
||||
if (buffer.isEmpty()) {
|
||||
|
|
|
@ -22,15 +22,14 @@
|
|||
#define CTLTESTFORM_H
|
||||
|
||||
#include <QTextBrowser>
|
||||
#include <QWidget>
|
||||
|
||||
#include "iwingplugin.h"
|
||||
#include "WingPlugin/wingpluginwidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class CtlTestForm;
|
||||
}
|
||||
|
||||
class CtlTestForm : public QWidget {
|
||||
class CtlTestForm : public WingHex::WingPluginWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -58,30 +57,29 @@ private slots:
|
|||
private:
|
||||
template <typename T>
|
||||
bool writeContent(qsizetype offset, const T &value) {
|
||||
Q_ASSERT(_plg);
|
||||
if constexpr (std::is_integral_v<T>) {
|
||||
if constexpr (sizeof(T) == sizeof(qint8)) {
|
||||
return emit _plg->controller.writeInt8(offset, value);
|
||||
return writeInt8(offset, value);
|
||||
} else if constexpr (sizeof(T) == sizeof(qint16)) {
|
||||
return emit _plg->controller.writeInt16(offset, value);
|
||||
return writeInt16(offset, value);
|
||||
} else if constexpr (sizeof(T) == sizeof(qint32)) {
|
||||
return emit _plg->controller.writeInt32(offset, value);
|
||||
return writeInt32(offset, value);
|
||||
} else if constexpr (sizeof(T) == sizeof(qint64)) {
|
||||
return emit _plg->controller.writeInt64(offset, value);
|
||||
return writeInt64(offset, value);
|
||||
} else {
|
||||
static_assert(false, "unsupported writeContent");
|
||||
return false;
|
||||
}
|
||||
} else if constexpr (std::is_floating_point_v<T>) {
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
return emit _plg->controller.writeFloat(offset, value);
|
||||
return writeFloat(offset, value);
|
||||
} else {
|
||||
return emit _plg->controller.writeDouble(offset, value);
|
||||
return writeDouble(offset, value);
|
||||
}
|
||||
} else if constexpr (std::is_same_v<T, QString>) {
|
||||
return emit _plg->controller.writeString(offset, value);
|
||||
return writeString(offset, value);
|
||||
} else if constexpr (std::is_same_v<T, QByteArray>) {
|
||||
return emit _plg->controller.writeBytes(offset, value);
|
||||
return writeBytes(offset, value);
|
||||
} else {
|
||||
static_assert(false, "unsupported writeContent");
|
||||
return false;
|
||||
|
@ -90,30 +88,29 @@ private:
|
|||
|
||||
template <typename T>
|
||||
bool insertContent(qsizetype offset, const T &value) {
|
||||
Q_ASSERT(_plg);
|
||||
if constexpr (std::is_integral_v<T>) {
|
||||
if constexpr (sizeof(T) == sizeof(qint8)) {
|
||||
return emit _plg->controller.insertInt8(offset, value);
|
||||
return insertInt8(offset, value);
|
||||
} else if constexpr (sizeof(T) == sizeof(qint16)) {
|
||||
return emit _plg->controller.insertInt16(offset, value);
|
||||
return insertInt16(offset, value);
|
||||
} else if constexpr (sizeof(T) == sizeof(qint32)) {
|
||||
return emit _plg->controller.insertInt32(offset, value);
|
||||
return insertInt32(offset, value);
|
||||
} else if constexpr (sizeof(T) == sizeof(qint64)) {
|
||||
return emit _plg->controller.insertInt64(offset, value);
|
||||
return insertInt64(offset, value);
|
||||
} else {
|
||||
static_assert(false, "unsupported insertContent");
|
||||
return false;
|
||||
}
|
||||
} else if constexpr (std::is_floating_point_v<T>) {
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
return emit _plg->controller.insertFloat(offset, value);
|
||||
return insertFloat(offset, value);
|
||||
} else {
|
||||
return emit _plg->controller.insertDouble(offset, value);
|
||||
return insertDouble(offset, value);
|
||||
}
|
||||
} else if constexpr (std::is_same_v<T, QString>) {
|
||||
return emit _plg->controller.insertString(offset, value);
|
||||
return insertString(offset, value);
|
||||
} else if constexpr (std::is_same_v<T, QByteArray>) {
|
||||
return emit _plg->controller.insertBytes(offset, value);
|
||||
return insertBytes(offset, value);
|
||||
} else {
|
||||
static_assert(false, "unsupported insertContent");
|
||||
return false;
|
||||
|
@ -122,30 +119,29 @@ private:
|
|||
|
||||
template <typename T>
|
||||
bool appendContent(const T &value) {
|
||||
Q_ASSERT(_plg);
|
||||
if constexpr (std::is_integral_v<T>) {
|
||||
if constexpr (sizeof(T) == sizeof(qint8)) {
|
||||
return emit _plg->controller.appendInt8(value);
|
||||
return appendInt8(value);
|
||||
} else if constexpr (sizeof(T) == sizeof(qint16)) {
|
||||
return emit _plg->controller.appendInt16(value);
|
||||
return appendInt16(value);
|
||||
} else if constexpr (sizeof(T) == sizeof(qint32)) {
|
||||
return emit _plg->controller.appendInt32(value);
|
||||
return appendInt32(value);
|
||||
} else if constexpr (sizeof(T) == sizeof(qint64)) {
|
||||
return emit _plg->controller.appendInt64(value);
|
||||
return appendInt64(value);
|
||||
} else {
|
||||
static_assert(false, "unsupported appendContent");
|
||||
return false;
|
||||
}
|
||||
} else if constexpr (std::is_floating_point_v<T>) {
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
return emit _plg->controller.appendFloat(value);
|
||||
return appendFloat(value);
|
||||
} else {
|
||||
return emit _plg->controller.appendDouble(value);
|
||||
return appendDouble(value);
|
||||
}
|
||||
} else if constexpr (std::is_same_v<T, QString>) {
|
||||
return emit _plg->controller.appendString(value);
|
||||
return appendString(value);
|
||||
} else if constexpr (std::is_same_v<T, QByteArray>) {
|
||||
return emit _plg->controller.appendBytes(value);
|
||||
return appendBytes(value);
|
||||
} else {
|
||||
static_assert(false, "unsupported appendContent");
|
||||
return false;
|
||||
|
@ -155,7 +151,6 @@ private:
|
|||
private:
|
||||
Ui::CtlTestForm *ui;
|
||||
|
||||
WingHex::IWingPlugin *_plg;
|
||||
QTextBrowser *_br;
|
||||
};
|
||||
|
||||
|
|
|
@ -34,38 +34,38 @@
|
|||
<translation>类型</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ctltestform.cpp" line="35"/>
|
||||
<location filename="../ctltestform.cpp" line="34"/>
|
||||
<source>PleaseInputInt8</source>
|
||||
<translation>请输入8位整数</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ctltestform.cpp" line="60"/>
|
||||
<location filename="../ctltestform.cpp" line="58"/>
|
||||
<source>PleaseInputInt16</source>
|
||||
<translation>请输入16位整数</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ctltestform.cpp" line="85"/>
|
||||
<location filename="../ctltestform.cpp" line="82"/>
|
||||
<source>PleaseInputInt32</source>
|
||||
<translation>请输入32位整数</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ctltestform.cpp" line="110"/>
|
||||
<location filename="../ctltestform.cpp" line="106"/>
|
||||
<source>PleaseInputInt64</source>
|
||||
<translation>请输入64位整数</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ctltestform.cpp" line="138"/>
|
||||
<location filename="../ctltestform.cpp" line="164"/>
|
||||
<location filename="../ctltestform.cpp" line="134"/>
|
||||
<location filename="../ctltestform.cpp" line="160"/>
|
||||
<source>PleaseInputFloat</source>
|
||||
<translation>请输入单精度浮点数</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ctltestform.cpp" line="189"/>
|
||||
<location filename="../ctltestform.cpp" line="185"/>
|
||||
<source>PleaseInputString</source>
|
||||
<translation>请输入字符串</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ctltestform.cpp" line="205"/>
|
||||
<location filename="../ctltestform.cpp" line="201"/>
|
||||
<source>PleaseInputByteArray(00 23 5A)</source>
|
||||
<translation>请输入字节数组(举例:00 23 5A)</translation>
|
||||
</message>
|
||||
|
@ -272,23 +272,23 @@
|
|||
<translation>数据可视化</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testform.cpp" line="344"/>
|
||||
<location filename="../testform.cpp" line="355"/>
|
||||
<location filename="../testform.cpp" line="340"/>
|
||||
<location filename="../testform.cpp" line="349"/>
|
||||
<source>UpdateTextTreeError</source>
|
||||
<translation>更新文本树失败</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testform.cpp" line="370"/>
|
||||
<location filename="../testform.cpp" line="364"/>
|
||||
<source>UpdateTextListByModelError</source>
|
||||
<translation>通过模型更新文本列表失败</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testform.cpp" line="380"/>
|
||||
<location filename="../testform.cpp" line="374"/>
|
||||
<source>UpdateTextTableByModelError</source>
|
||||
<translation>通过模型更新文本表格失败</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testform.cpp" line="391"/>
|
||||
<location filename="../testform.cpp" line="385"/>
|
||||
<source>UpdateTextTreeByModelError</source>
|
||||
<translation>通过模型更新文本树失败</translation>
|
||||
</message>
|
||||
|
@ -296,60 +296,60 @@
|
|||
<context>
|
||||
<name>TestPlugin</name>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="208"/>
|
||||
<location filename="../testplugin.cpp" line="207"/>
|
||||
<source>Test</source>
|
||||
<translation>测试</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="220"/>
|
||||
<location filename="../testplugin.cpp" line="229"/>
|
||||
<location filename="../testplugin.cpp" line="234"/>
|
||||
<location filename="../testplugin.cpp" line="315"/>
|
||||
<location filename="../testplugin.cpp" line="219"/>
|
||||
<location filename="../testplugin.cpp" line="228"/>
|
||||
<location filename="../testplugin.cpp" line="233"/>
|
||||
<location filename="../testplugin.cpp" line="314"/>
|
||||
<source>TestPlugin</source>
|
||||
<translation>测试插件</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="238"/>
|
||||
<location filename="../testplugin.cpp" line="237"/>
|
||||
<source>Button - </source>
|
||||
<translation>按钮 - </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="242"/>
|
||||
<location filename="../testplugin.cpp" line="241"/>
|
||||
<source>Click</source>
|
||||
<translation>点击</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="318"/>
|
||||
<location filename="../testplugin.cpp" line="317"/>
|
||||
<source>A Test Plugin for WingHexExplorer2.</source>
|
||||
<translation>一个用来测试羽云十六进制编辑器2的插件</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="356"/>
|
||||
<location filename="../testplugin.cpp" line="364"/>
|
||||
<location filename="../testplugin.cpp" line="373"/>
|
||||
<location filename="../testplugin.cpp" line="394"/>
|
||||
<location filename="../testplugin.cpp" line="410"/>
|
||||
<location filename="../testplugin.cpp" line="417"/>
|
||||
<location filename="../testplugin.cpp" line="424"/>
|
||||
<location filename="../testplugin.cpp" line="431"/>
|
||||
<location filename="../testplugin.cpp" line="439"/>
|
||||
<location filename="../testplugin.cpp" line="470"/>
|
||||
<location filename="../testplugin.cpp" line="478"/>
|
||||
<location filename="../testplugin.cpp" line="486"/>
|
||||
<location filename="../testplugin.cpp" line="494"/>
|
||||
<location filename="../testplugin.cpp" line="503"/>
|
||||
<location filename="../testplugin.cpp" line="510"/>
|
||||
<location filename="../testplugin.cpp" line="355"/>
|
||||
<location filename="../testplugin.cpp" line="363"/>
|
||||
<location filename="../testplugin.cpp" line="372"/>
|
||||
<location filename="../testplugin.cpp" line="393"/>
|
||||
<location filename="../testplugin.cpp" line="409"/>
|
||||
<location filename="../testplugin.cpp" line="416"/>
|
||||
<location filename="../testplugin.cpp" line="423"/>
|
||||
<location filename="../testplugin.cpp" line="430"/>
|
||||
<location filename="../testplugin.cpp" line="438"/>
|
||||
<location filename="../testplugin.cpp" line="468"/>
|
||||
<location filename="../testplugin.cpp" line="476"/>
|
||||
<location filename="../testplugin.cpp" line="484"/>
|
||||
<location filename="../testplugin.cpp" line="492"/>
|
||||
<location filename="../testplugin.cpp" line="501"/>
|
||||
<location filename="../testplugin.cpp" line="508"/>
|
||||
<source>InvalidParamsCount</source>
|
||||
<translation>无效参数个数</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="387"/>
|
||||
<location filename="../testplugin.cpp" line="403"/>
|
||||
<location filename="../testplugin.cpp" line="386"/>
|
||||
<location filename="../testplugin.cpp" line="402"/>
|
||||
<source>InvalidParam</source>
|
||||
<translation>非法参数</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="461"/>
|
||||
<location filename="../testplugin.cpp" line="459"/>
|
||||
<source>AllocArrayFailed</source>
|
||||
<translation>分配数组失败</translation>
|
||||
</message>
|
||||
|
@ -357,7 +357,7 @@
|
|||
<context>
|
||||
<name>TestPluginPage</name>
|
||||
<message>
|
||||
<location filename="../testpluginpage.cpp" line="16"/>
|
||||
<location filename="../testpluginpage.cpp" line="36"/>
|
||||
<source>TestPluginPage</source>
|
||||
<translation>测试插件页</translation>
|
||||
</message>
|
||||
|
@ -365,7 +365,7 @@
|
|||
<context>
|
||||
<name>TestWingEditorViewWidget</name>
|
||||
<message>
|
||||
<location filename="../testwingeditorviewwidget.cpp" line="28"/>
|
||||
<location filename="../testwingeditorviewwidget.cpp" line="48"/>
|
||||
<source>TestWingEditorView</source>
|
||||
<translation>测试插件编辑视图</translation>
|
||||
</message>
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
|
||||
ReaderTestForm::ReaderTestForm(WingHex::IWingPlugin *plg, QTextBrowser *br,
|
||||
QWidget *parent)
|
||||
: QWidget(parent), ui(new Ui::ReaderTestForm), _plg(plg), _br(br) {
|
||||
: WingHex::WingPluginWidget(plg, parent), ui(new Ui::ReaderTestForm),
|
||||
_br(br) {
|
||||
ui->setupUi(this);
|
||||
ui->sbOffset->setRange(0, INT_MAX);
|
||||
}
|
||||
|
@ -33,43 +34,42 @@ ReaderTestForm::ReaderTestForm(WingHex::IWingPlugin *plg, QTextBrowser *br,
|
|||
ReaderTestForm::~ReaderTestForm() { delete ui; }
|
||||
|
||||
void ReaderTestForm::on_btnReadInt8_clicked() {
|
||||
auto v = emit _plg->reader.readInt8(ui->sbOffset->value());
|
||||
auto v = readInt8(ui->sbOffset->value());
|
||||
_br->append(QStringLiteral("[ReadInt8] ") + QString::number(v));
|
||||
}
|
||||
|
||||
void ReaderTestForm::on_btnReadInt16_clicked() {
|
||||
auto v = emit _plg->reader.readInt16(ui->sbOffset->value());
|
||||
auto v = readInt16(ui->sbOffset->value());
|
||||
_br->append(QStringLiteral("[ReadInt16] ") + QString::number(v));
|
||||
}
|
||||
|
||||
void ReaderTestForm::on_btnReadInt32_clicked() {
|
||||
auto v = emit _plg->reader.readInt32(ui->sbOffset->value());
|
||||
auto v = readInt32(ui->sbOffset->value());
|
||||
_br->append(QStringLiteral("[ReadInt32] ") + QString::number(v));
|
||||
}
|
||||
|
||||
void ReaderTestForm::on_btnReadInt64_clicked() {
|
||||
auto v = emit _plg->reader.readInt64(ui->sbOffset->value());
|
||||
auto v = readInt64(ui->sbOffset->value());
|
||||
_br->append(QStringLiteral("[ReadInt64] ") + QString::number(v));
|
||||
}
|
||||
|
||||
void ReaderTestForm::on_btnReadFloat_clicked() {
|
||||
auto v = emit _plg->reader.readFloat(ui->sbOffset->value());
|
||||
auto v = readFloat(ui->sbOffset->value());
|
||||
_br->append(QStringLiteral("[ReadFloat] ") + QString::number(v));
|
||||
}
|
||||
|
||||
void ReaderTestForm::on_btnReadDouble_clicked() {
|
||||
auto v = emit _plg->reader.readDouble(ui->sbOffset->value());
|
||||
auto v = readDouble(ui->sbOffset->value());
|
||||
_br->append(QStringLiteral("[ReadDouble] ") + QString::number(v));
|
||||
}
|
||||
|
||||
void ReaderTestForm::on_btnReadString_clicked() {
|
||||
auto v = emit _plg->reader.readString(ui->sbOffset->value());
|
||||
auto v = readString(ui->sbOffset->value());
|
||||
_br->append(QStringLiteral("[ReadString] ") + v);
|
||||
}
|
||||
|
||||
void ReaderTestForm::on_btnReadByteArray_clicked() {
|
||||
auto v =
|
||||
emit _plg->reader.readBytes(ui->sbOffset->value(), ui->sbLen->value());
|
||||
auto v = readBytes(ui->sbOffset->value(), ui->sbLen->value());
|
||||
_br->append(QStringLiteral("[ReadByteArray] ") + v.toHex(' '));
|
||||
}
|
||||
|
||||
|
@ -78,63 +78,49 @@ void ReaderTestForm::on_btnStatus_clicked() {
|
|||
static auto strue = QStringLiteral("true");
|
||||
static auto sfalse = QStringLiteral("false");
|
||||
_br->clear();
|
||||
_br->append(QStringLiteral("[Status]") % lf %
|
||||
QStringLiteral("getSupportedEncodings: ") %
|
||||
(emit _plg->reader.getSupportedEncodings().join(';')) % lf %
|
||||
QStringLiteral("isCurrentDocEditing: ") %
|
||||
(emit _plg->reader.isCurrentDocEditing() ? strue : sfalse) %
|
||||
lf % QStringLiteral("currentDocFilename: ") %
|
||||
emit _plg->reader.currentDocFilename() % lf %
|
||||
QStringLiteral("isReadOnly: ") %
|
||||
(emit _plg->reader.isReadOnly() ? strue : sfalse) % lf %
|
||||
QStringLiteral("isKeepSize: ") %
|
||||
(emit _plg->reader.isKeepSize() ? strue : sfalse) % lf %
|
||||
QStringLiteral("isLocked: ") %
|
||||
(emit _plg->reader.isLocked() ? strue : sfalse) % lf %
|
||||
QStringLiteral("isModified: ") %
|
||||
(emit _plg->reader.isModified() ? strue : sfalse) % lf %
|
||||
QStringLiteral("stringVisible: ") %
|
||||
(emit _plg->reader.stringVisible() ? strue : sfalse) % lf %
|
||||
QStringLiteral("addressVisible: ") %
|
||||
(emit _plg->reader.addressVisible() ? strue : sfalse) % lf %
|
||||
QStringLiteral("headerVisible: ") %
|
||||
(emit _plg->reader.headerVisible() ? strue : sfalse) % lf %
|
||||
QStringLiteral("addressBase: ") % QStringLiteral("0x") %
|
||||
QString::number(emit _plg->reader.addressBase(), 16).toUpper() %
|
||||
lf % QStringLiteral("documentLines: ") %
|
||||
QString::number(emit _plg->reader.documentLines()) % lf %
|
||||
QStringLiteral("documentBytes: ") %
|
||||
QString::number(emit _plg->reader.documentBytes()) % lf %
|
||||
QStringLiteral("currentPos: ") %
|
||||
getPrintableHexPosition(emit _plg->reader.currentPos()) % lf %
|
||||
QStringLiteral("currentRow: ") %
|
||||
QString::number(emit _plg->reader.currentRow()) % lf %
|
||||
QStringLiteral("currentColumn: ") %
|
||||
QString::number(emit _plg->reader.currentColumn()) % lf %
|
||||
QStringLiteral("currentOffset: ") %
|
||||
QString::number(emit _plg->reader.currentOffset()) % lf %
|
||||
QStringLiteral("selectedLength: ") %
|
||||
QString::number(emit _plg->reader.selectedLength()));
|
||||
_br->append(
|
||||
QStringLiteral("[Status]") % lf %
|
||||
QStringLiteral("isCurrentDocEditing: ") %
|
||||
(isCurrentDocEditing() ? strue : sfalse) % lf %
|
||||
QStringLiteral("currentDocFilename: ") % currentDocFilename() % lf %
|
||||
QStringLiteral("isReadOnly: ") % (isReadOnly() ? strue : sfalse) % lf %
|
||||
QStringLiteral("isKeepSize: ") % (isKeepSize() ? strue : sfalse) % lf %
|
||||
QStringLiteral("isLocked: ") % (isLocked() ? strue : sfalse) % lf %
|
||||
QStringLiteral("isModified: ") % (isModified() ? strue : sfalse) % lf %
|
||||
QStringLiteral("stringVisible: ") % (stringVisible() ? strue : sfalse) %
|
||||
lf % QStringLiteral("addressVisible: ") %
|
||||
(addressVisible() ? strue : sfalse) % lf %
|
||||
QStringLiteral("headerVisible: ") % (headerVisible() ? strue : sfalse) %
|
||||
lf % QStringLiteral("addressBase: ") % QStringLiteral("0x") %
|
||||
QString::number(addressBase(), 16).toUpper() % lf %
|
||||
QStringLiteral("documentLines: ") % QString::number(documentLines()) %
|
||||
lf % QStringLiteral("documentBytes: ") %
|
||||
QString::number(documentBytes()) % lf % QStringLiteral("currentPos: ") %
|
||||
getPrintableHexPosition(currentPos()) % lf %
|
||||
QStringLiteral("currentRow: ") % QString::number(currentRow()) % lf %
|
||||
QStringLiteral("currentColumn: ") % QString::number(currentColumn()) %
|
||||
lf % QStringLiteral("currentOffset: ") %
|
||||
QString::number(currentOffset()) % lf %
|
||||
QStringLiteral("selectedLength: ") % QString::number(selectedLength()));
|
||||
|
||||
_br->append(QStringLiteral("[Selection]"));
|
||||
auto total = emit _plg->reader.selectionCount();
|
||||
auto total = selectionCount();
|
||||
_br->append(QStringLiteral("selectionCount: ") % QString::number(total));
|
||||
for (decltype(total) i = 0; i < total; ++i) {
|
||||
_br->append(QStringLiteral("{ ") % QString::number(i) %
|
||||
QStringLiteral(" }"));
|
||||
_br->append(
|
||||
QStringLiteral("selectionStart: ") %
|
||||
getPrintableHexPosition(emit _plg->reader.selectionStart(i)) % lf %
|
||||
QStringLiteral("selectionEnd: ") %
|
||||
getPrintableHexPosition(emit _plg->reader.selectionEnd(i)) % lf %
|
||||
QStringLiteral("selectionLength: ") %
|
||||
QString::number(emit _plg->reader.selectionLength(i)) % lf %
|
||||
QStringLiteral("selectedBytes: ") %
|
||||
(emit _plg->reader.selectedBytes(i)).toHex(' '));
|
||||
_br->append(QStringLiteral("selectionStart: ") %
|
||||
getPrintableHexPosition(selectionStart(i)) % lf %
|
||||
QStringLiteral("selectionEnd: ") %
|
||||
getPrintableHexPosition(selectionEnd(i)) % lf %
|
||||
QStringLiteral("selectionLength: ") %
|
||||
QString::number(selectionLength(i)) % lf %
|
||||
QStringLiteral("selectedBytes: ") %
|
||||
(selectedBytes(i)).toHex(' '));
|
||||
}
|
||||
|
||||
_br->append(QStringLiteral("[Selections]"));
|
||||
_br->append((emit _plg->reader.selectionBytes()).join('\n').toHex(' '));
|
||||
_br->append((selectionBytes()).join('\n').toHex(' '));
|
||||
}
|
||||
|
||||
QString
|
||||
|
|
|
@ -22,15 +22,14 @@
|
|||
#define READERTESTFORM_H
|
||||
|
||||
#include <QTextBrowser>
|
||||
#include <QWidget>
|
||||
|
||||
#include "iwingplugin.h"
|
||||
#include "WingPlugin/wingpluginwidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class ReaderTestForm;
|
||||
}
|
||||
|
||||
class ReaderTestForm : public QWidget {
|
||||
class ReaderTestForm : public WingHex::WingPluginWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -63,7 +62,6 @@ private:
|
|||
private:
|
||||
Ui::ReaderTestForm *ui;
|
||||
|
||||
WingHex::IWingPlugin *_plg;
|
||||
QTextBrowser *_br;
|
||||
};
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include "testform.h"
|
||||
#include "WingPlugin/iwingpluginbase.h"
|
||||
#include "ui_testform.h"
|
||||
|
||||
#include "ctltestform.h"
|
||||
|
@ -30,17 +31,18 @@
|
|||
#include <QMetaEnum>
|
||||
#include <QScrollArea>
|
||||
#include <QStandardItemModel>
|
||||
#include <QStringListModel>
|
||||
|
||||
TestForm::TestForm(WingHex::IWingPlugin *plg, QWidget *parent)
|
||||
: QWidget(parent), ui(new Ui::TestForm), _plg(plg) {
|
||||
: WingHex::WingPluginWidget(plg, parent), ui(new Ui::TestForm) {
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->teDataVisual->setAcceptRichText(false);
|
||||
|
||||
ui->saReader->widget()->layout()->addWidget(
|
||||
new ReaderTestForm(_plg, ui->tbReaderLogger, this));
|
||||
new ReaderTestForm(plg, ui->tbReaderLogger, this));
|
||||
ui->saCtl->widget()->layout()->addWidget(
|
||||
new CtlTestForm(_plg, ui->tbCtlLogger, this));
|
||||
new CtlTestForm(plg, ui->tbCtlLogger, this));
|
||||
|
||||
ui->spltReader->setSizes({300, 150});
|
||||
ui->spltCtl->setSizes({300, 150});
|
||||
|
@ -152,32 +154,32 @@ QFileDialog::Options TestForm::getFileDialogOptions() const {
|
|||
}
|
||||
|
||||
void TestForm::onDVClicked(const QModelIndex &index) {
|
||||
emit _plg->warn(QStringLiteral("[Test - Click] ") +
|
||||
index.model()->data(index).toString());
|
||||
logWarn(QStringLiteral("[Test - Click] ") +
|
||||
index.model()->data(index).toString());
|
||||
}
|
||||
|
||||
void TestForm::onDVDoubleClicked(const QModelIndex &index) {
|
||||
emit _plg->msgbox.warning(this, QStringLiteral("Test - DoubleClick"),
|
||||
index.model()->data(index).toString());
|
||||
msgWarning(this, QStringLiteral("Test - DoubleClick"),
|
||||
index.model()->data(index).toString());
|
||||
}
|
||||
|
||||
void TestForm::on_btnSendLog_clicked() {
|
||||
auto txt = ui->leLogText->text();
|
||||
switch (Level(ui->cbLogLevel->currentIndex())) {
|
||||
case q1ERROR:
|
||||
emit _plg->error(txt);
|
||||
logError(txt);
|
||||
break;
|
||||
case q2WARN:
|
||||
emit _plg->warn(txt);
|
||||
logWarn(txt);
|
||||
break;
|
||||
case q3INFO:
|
||||
emit _plg->info(txt);
|
||||
logInfo(txt);
|
||||
break;
|
||||
case q4DEBUG:
|
||||
emit _plg->debug(txt);
|
||||
logDebug(txt);
|
||||
break;
|
||||
case q5TRACE:
|
||||
emit _plg->trace(txt);
|
||||
logTrace(txt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -188,38 +190,37 @@ void TestForm::on_btnSendToast_clicked() {
|
|||
auto idx = ui->cbToastIcon->currentIndex();
|
||||
Q_ASSERT(idx >= 0);
|
||||
auto icon = ui->cbToastIcon->itemData(idx).value<QPixmap>();
|
||||
emit _plg->toast(icon, ui->leToastText->text());
|
||||
toast(icon, ui->leToastText->text());
|
||||
}
|
||||
|
||||
void TestForm::on_btnAboutQt_clicked() {
|
||||
emit _plg->msgbox.aboutQt(this, ui->leAboutTitle->text());
|
||||
msgAboutQt(this, ui->leAboutTitle->text());
|
||||
}
|
||||
|
||||
void TestForm::on_btnQuestion_clicked() {
|
||||
emit _plg->msgbox.question(
|
||||
msgQuestion(
|
||||
this, ui->leMsgTitle->text(), ui->leMsgText->text(), getMsgButtons(),
|
||||
QMessageBox::StandardButton(ui->cbMsgDefButton->currentData().toInt()));
|
||||
}
|
||||
|
||||
void TestForm::on_btnWarning_clicked() {
|
||||
emit _plg->msgbox.warning(
|
||||
msgWarning(
|
||||
this, ui->leMsgTitle->text(), ui->leMsgText->text(), getMsgButtons(),
|
||||
QMessageBox::StandardButton(ui->cbMsgDefButton->currentData().toInt()));
|
||||
}
|
||||
|
||||
void TestForm::on_btnCritical_clicked() {
|
||||
emit _plg->msgbox.critical(
|
||||
critical(
|
||||
this, ui->leMsgTitle->text(), ui->leMsgText->text(), getMsgButtons(),
|
||||
QMessageBox::StandardButton(ui->cbMsgDefButton->currentData().toInt()));
|
||||
}
|
||||
|
||||
void TestForm::on_btnAbout_clicked() {
|
||||
emit _plg->msgbox.about(this, ui->leMsgTitle->text(),
|
||||
ui->leMsgText->text());
|
||||
msgAbout(this, ui->leMsgTitle->text(), ui->leMsgText->text());
|
||||
}
|
||||
|
||||
void TestForm::on_btnMsgBox_clicked() {
|
||||
emit _plg->msgbox.msgbox(
|
||||
msgbox(
|
||||
this, ui->cbMsgIcon->currentData().value<QMessageBox::Icon>(),
|
||||
ui->leMsgTitle->text(), ui->leMsgText->text(), getMsgButtons(),
|
||||
QMessageBox::StandardButton(ui->cbMsgDefButton->currentData().toInt()));
|
||||
|
@ -227,9 +228,9 @@ void TestForm::on_btnMsgBox_clicked() {
|
|||
|
||||
void TestForm::on_btnText_clicked() {
|
||||
bool ok = false;
|
||||
auto ret = emit _plg->inputbox.getText(
|
||||
this, ui->leInputTitle->text(), ui->leInputLabel->text(),
|
||||
QLineEdit::Normal, __FUNCTION__, &ok);
|
||||
auto ret =
|
||||
dlgGetText(this, ui->leInputTitle->text(), ui->leInputLabel->text(),
|
||||
QLineEdit::Normal, __FUNCTION__, &ok);
|
||||
ui->tbInputLogger->append(
|
||||
QStringLiteral("[getText] ( ") %
|
||||
(ok ? QStringLiteral("true") : QStringLiteral("false")) %
|
||||
|
@ -238,9 +239,8 @@ void TestForm::on_btnText_clicked() {
|
|||
|
||||
void TestForm::on_btnMultiLineText_clicked() {
|
||||
bool ok = false;
|
||||
auto ret = emit _plg->inputbox.getMultiLineText(
|
||||
this, ui->leInputTitle->text(), ui->leInputLabel->text(), __FUNCTION__,
|
||||
&ok);
|
||||
auto ret = dlgGetMultiLineText(this, ui->leInputTitle->text(),
|
||||
ui->leInputLabel->text(), __FUNCTION__, &ok);
|
||||
ui->tbInputLogger->append(
|
||||
QStringLiteral("[getText] ( ") %
|
||||
(ok ? QStringLiteral("true") : QStringLiteral("false")) %
|
||||
|
@ -253,9 +253,8 @@ void TestForm::on_btnItem_clicked() {
|
|||
l.append(QStringLiteral("WingSummer WingHex2 - %1").arg(i));
|
||||
}
|
||||
bool ok = false;
|
||||
auto ret =
|
||||
emit _plg->inputbox.getItem(this, ui->leInputTitle->text(),
|
||||
ui->leInputLabel->text(), l, 0, true, &ok);
|
||||
auto ret = dlgGetItem(this, ui->leInputTitle->text(),
|
||||
ui->leInputLabel->text(), l, 0, true, &ok);
|
||||
ui->tbInputLogger->append(
|
||||
QStringLiteral("[getItem] ( ") %
|
||||
(ok ? QStringLiteral("true") : QStringLiteral("false")) %
|
||||
|
@ -264,9 +263,9 @@ void TestForm::on_btnItem_clicked() {
|
|||
|
||||
void TestForm::on_btnInt_clicked() {
|
||||
bool ok = false;
|
||||
auto ret = emit _plg->inputbox.getInt(this, ui->leInputTitle->text(),
|
||||
ui->leInputLabel->text(), 0, 0,
|
||||
WingHex::SDKVERSION, 1, &ok);
|
||||
auto ret =
|
||||
dlgGetInt(this, ui->leInputTitle->text(), ui->leInputLabel->text(), 0,
|
||||
0, WingHex::SDKVERSION, 1, &ok);
|
||||
ui->tbInputLogger->append(
|
||||
QStringLiteral("[getInt] ( ") %
|
||||
(ok ? QStringLiteral("true") : QStringLiteral("false")) %
|
||||
|
@ -275,10 +274,10 @@ void TestForm::on_btnInt_clicked() {
|
|||
|
||||
void TestForm::on_btnDouble_clicked() {
|
||||
bool ok = false;
|
||||
auto ret = emit _plg->inputbox.getDouble(
|
||||
this, ui->leInputTitle->text(), ui->leInputLabel->text(),
|
||||
QLineEdit::Normal, -double(WingHex::SDKVERSION), 0.0,
|
||||
double(WingHex::SDKVERSION), &ok);
|
||||
auto ret =
|
||||
dlgGetDouble(this, ui->leInputTitle->text(), ui->leInputLabel->text(),
|
||||
QLineEdit::Normal, -double(WingHex::SDKVERSION), 0.0,
|
||||
double(WingHex::SDKVERSION), &ok);
|
||||
ui->tbInputLogger->append(
|
||||
QStringLiteral("[getDouble] ( ") %
|
||||
(ok ? QStringLiteral("true") : QStringLiteral("false")) %
|
||||
|
@ -286,21 +285,21 @@ void TestForm::on_btnDouble_clicked() {
|
|||
}
|
||||
|
||||
void TestForm::on_btnExistingDirectory_clicked() {
|
||||
auto ret = emit _plg->filedlg.getExistingDirectory(
|
||||
this, ui->leFileCaption->text(), qApp->applicationDirPath(),
|
||||
getFileDialogOptions());
|
||||
auto ret = dlgGetExistingDirectory(this, ui->leFileCaption->text(),
|
||||
qApp->applicationDirPath(),
|
||||
getFileDialogOptions());
|
||||
ui->tbFileLogger->append(QStringLiteral("[getExistingDirectory] ") % ret);
|
||||
}
|
||||
|
||||
void TestForm::on_btnOpenFileName_clicked() {
|
||||
auto ret = emit _plg->filedlg.getOpenFileName(
|
||||
auto ret = dlgGetOpenFileName(
|
||||
this, ui->leFileCaption->text(), qApp->applicationDirPath(),
|
||||
ui->leFileFilter->text(), nullptr, getFileDialogOptions());
|
||||
ui->tbFileLogger->append(QStringLiteral("[getOpenFileName] ") % ret);
|
||||
}
|
||||
|
||||
void TestForm::on_btnOpenFileNames_clicked() {
|
||||
auto ret = emit _plg->filedlg.getOpenFileNames(
|
||||
auto ret = dlgGetOpenFileNames(
|
||||
this, ui->leFileCaption->text(), qApp->applicationDirPath(),
|
||||
ui->leFileFilter->text(), nullptr, getFileDialogOptions());
|
||||
ui->tbFileLogger->append(QStringLiteral("[getOpenFileName] ") %
|
||||
|
@ -308,14 +307,14 @@ void TestForm::on_btnOpenFileNames_clicked() {
|
|||
}
|
||||
|
||||
void TestForm::on_btnSaveFileName_clicked() {
|
||||
auto ret = emit _plg->filedlg.getSaveFileName(
|
||||
auto ret = dlgGetSaveFileName(
|
||||
this, ui->leFileCaption->text(), qApp->applicationDirPath(),
|
||||
ui->leFileFilter->text(), nullptr, getFileDialogOptions());
|
||||
ui->tbFileLogger->append(QStringLiteral("[getSaveFileName] ") % ret);
|
||||
}
|
||||
|
||||
void TestForm::on_btnGetColor_clicked() {
|
||||
auto ret = emit _plg->colordlg.getColor(ui->leColorCaption->text(), this);
|
||||
auto ret = dlgGetColor(ui->leColorCaption->text(), this);
|
||||
if (ret.isValid()) {
|
||||
ui->wColor->setStyleSheet(QStringLiteral("background-color:") +
|
||||
ret.name());
|
||||
|
@ -325,34 +324,29 @@ void TestForm::on_btnGetColor_clicked() {
|
|||
}
|
||||
|
||||
void TestForm::on_btnText_2_clicked() {
|
||||
emit _plg->visual.updateText(ui->teDataVisual->toPlainText(),
|
||||
QStringLiteral("TestForm"));
|
||||
dataVisualText(ui->teDataVisual->toPlainText(), QStringLiteral("TestForm"));
|
||||
}
|
||||
|
||||
void TestForm::on_btnTextList_clicked() {
|
||||
auto txts = ui->teDataVisual->toPlainText().split('\n');
|
||||
emit _plg->visual.updateTextList(txts, QStringLiteral("TestForm"), _click,
|
||||
_dblclick);
|
||||
dataVisualTextList(txts, QStringLiteral("TestForm"), _click, _dblclick);
|
||||
}
|
||||
|
||||
void TestForm::on_btnTextTree_clicked() {
|
||||
auto ret = emit _plg->visual.updateTextTree(ui->teDataVisual->toPlainText(),
|
||||
QStringLiteral("TestForm"),
|
||||
_click, _dblclick);
|
||||
auto ret =
|
||||
dataVisualTextTree(ui->teDataVisual->toPlainText(),
|
||||
QStringLiteral("TestForm"), _click, _dblclick);
|
||||
if (!ret) {
|
||||
emit _plg->msgbox.critical(this, QStringLiteral("Test"),
|
||||
tr("UpdateTextTreeError"));
|
||||
critical(this, QStringLiteral("Test"), tr("UpdateTextTreeError"));
|
||||
}
|
||||
}
|
||||
|
||||
void TestForm::on_btnTextTable_clicked() {
|
||||
auto ret = emit _plg->visual.updateTextTable(
|
||||
ui->teDataVisual->toPlainText(),
|
||||
{WingHex::WINGSUMMER, WingHex::WINGSUMMER}, {},
|
||||
auto ret = dataVisualTextTable(
|
||||
ui->teDataVisual->toPlainText(), {"wingsummer", "wingsummer"}, {},
|
||||
QStringLiteral("TestForm"), _click, _dblclick);
|
||||
if (!ret) {
|
||||
emit _plg->msgbox.critical(this, QStringLiteral("Test"),
|
||||
tr("UpdateTextTreeError"));
|
||||
critical(this, QStringLiteral("Test"), tr("UpdateTextTreeError"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,62 +354,62 @@ void TestForm::on_btnTextListByModel_clicked() {
|
|||
auto model = new QStringListModel;
|
||||
QStringList buffer;
|
||||
for (int i = 0; i < WingHex::SDKVERSION; ++i) {
|
||||
buffer.append(WingHex::WINGSUMMER % QString::number(i));
|
||||
buffer.append("wingsummer" % QString::number(i));
|
||||
}
|
||||
model->setStringList(buffer);
|
||||
auto ret = emit _plg->visual.updateTextListByModel(
|
||||
model, QStringLiteral("TestForm"), _click, _dblclick);
|
||||
auto ret = dataVisualTextListByModel(model, QStringLiteral("TestForm"),
|
||||
_click, _dblclick);
|
||||
if (!ret) {
|
||||
emit _plg->msgbox.critical(this, QStringLiteral("Test"),
|
||||
tr("UpdateTextListByModelError"));
|
||||
critical(this, QStringLiteral("Test"),
|
||||
tr("UpdateTextListByModelError"));
|
||||
}
|
||||
}
|
||||
|
||||
void TestForm::on_btnTextTableByModel_clicked() {
|
||||
auto model = new TestTableModel;
|
||||
auto ret = emit _plg->visual.updateTextTableByModel(
|
||||
model, QStringLiteral("TestForm"), _click, _dblclick);
|
||||
auto ret = dataVisualTextTableByModel(model, QStringLiteral("TestForm"),
|
||||
_click, _dblclick);
|
||||
if (!ret) {
|
||||
emit _plg->msgbox.critical(this, QStringLiteral("Test"),
|
||||
tr("UpdateTextTableByModelError"));
|
||||
critical(this, QStringLiteral("Test"),
|
||||
tr("UpdateTextTableByModelError"));
|
||||
}
|
||||
}
|
||||
|
||||
void TestForm::on_btnTextTreeByModel_clicked() {
|
||||
auto model = new QFileSystemModel;
|
||||
model->setRootPath(QDir::currentPath());
|
||||
auto ret = emit _plg->visual.updateTextTreeByModel(
|
||||
model, QStringLiteral("TestForm"), _click, _dblclick);
|
||||
auto ret = dataVisualTextTreeByModel(model, QStringLiteral("TestForm"),
|
||||
_click, _dblclick);
|
||||
if (!ret) {
|
||||
emit _plg->msgbox.critical(this, QStringLiteral("Test"),
|
||||
tr("UpdateTextTreeByModelError"));
|
||||
critical(this, QStringLiteral("Test"),
|
||||
tr("UpdateTextTreeByModelError"));
|
||||
}
|
||||
}
|
||||
|
||||
void TestForm::on_btnStatusVisible_clicked() {
|
||||
if (ui->rbLockedFile->isChecked()) {
|
||||
Q_UNUSED(emit _plg->controller.setLockedFile(true));
|
||||
Q_UNUSED(setLockedFile(true));
|
||||
} else if (ui->rbAddressVisible->isChecked()) {
|
||||
Q_UNUSED(emit _plg->controller.setAddressVisible(true));
|
||||
Q_UNUSED(setAddressVisible(true));
|
||||
} else if (ui->rbHeaderVisible->isChecked()) {
|
||||
Q_UNUSED(emit _plg->controller.setHeaderVisible(true));
|
||||
Q_UNUSED(setHeaderVisible(true));
|
||||
} else if (ui->rbKeepSize->isChecked()) {
|
||||
Q_UNUSED(emit _plg->controller.setKeepSize(true));
|
||||
Q_UNUSED(setKeepSize(true));
|
||||
} else if (ui->rbStringVisible->isChecked()) {
|
||||
Q_UNUSED(emit _plg->controller.setStringVisible(true));
|
||||
Q_UNUSED(setStringVisible(true));
|
||||
}
|
||||
}
|
||||
|
||||
void TestForm::on_btnStatusInvisible_clicked() {
|
||||
if (ui->rbLockedFile->isChecked()) {
|
||||
Q_UNUSED(emit _plg->controller.setLockedFile(false));
|
||||
Q_UNUSED(setLockedFile(false));
|
||||
} else if (ui->rbAddressVisible->isChecked()) {
|
||||
Q_UNUSED(emit _plg->controller.setAddressVisible(false));
|
||||
Q_UNUSED(setAddressVisible(false));
|
||||
} else if (ui->rbHeaderVisible->isChecked()) {
|
||||
Q_UNUSED(emit _plg->controller.setHeaderVisible(false));
|
||||
Q_UNUSED(setHeaderVisible(false));
|
||||
} else if (ui->rbKeepSize->isChecked()) {
|
||||
Q_UNUSED(emit _plg->controller.setKeepSize(false));
|
||||
Q_UNUSED(setKeepSize(false));
|
||||
} else if (ui->rbStringVisible->isChecked()) {
|
||||
Q_UNUSED(emit _plg->controller.setStringVisible(false));
|
||||
Q_UNUSED(setStringVisible(false));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,15 +21,13 @@
|
|||
#ifndef TESTFORM_H
|
||||
#define TESTFORM_H
|
||||
|
||||
#include "iwingplugin.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include "WingPlugin/wingpluginwidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class TestForm;
|
||||
}
|
||||
|
||||
class TestForm : public QWidget {
|
||||
class TestForm : public WingHex::WingPluginWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -130,10 +128,8 @@ private:
|
|||
private:
|
||||
Ui::TestForm *ui;
|
||||
|
||||
WingHex::WingPlugin::DataVisual::ClickedCallBack _click;
|
||||
WingHex::WingPlugin::DataVisual::DoubleClickedCallBack _dblclick;
|
||||
|
||||
WingHex::IWingPlugin *_plg;
|
||||
WingHex::ClickedCallBack _click;
|
||||
WingHex::ClickedCallBack _dblclick;
|
||||
};
|
||||
|
||||
#endif // TESTFORM_H
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "testwingeditorviewwidget.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMenu>
|
||||
|
||||
// 注意:所有提供的脚本接口函数都不是线程安全的,只是测试
|
||||
|
||||
|
@ -181,19 +182,17 @@ TestPlugin::~TestPlugin() { destoryTestShareMem(); }
|
|||
|
||||
int TestPlugin::sdkVersion() const { return WingHex::SDKVERSION; }
|
||||
|
||||
const QString TestPlugin::signature() const { return WingHex::WINGSUMMER; }
|
||||
|
||||
bool TestPlugin::init(const std::unique_ptr<QSettings> &set) {
|
||||
auto v = set->value("Test", 0).toInt();
|
||||
// 如果你之前启动过且正常推出,这个值一定是 5
|
||||
qDebug() << v;
|
||||
|
||||
// 和日志与 UI 相关的接口此时可用,剩余的 API 初始化成功才可用
|
||||
_tform = emit createDialog(new TestForm(this));
|
||||
_tform = createDialog(new TestForm(this));
|
||||
if (_tform == nullptr) {
|
||||
return false;
|
||||
}
|
||||
_tform->setWindowFlag(Qt::WindowStaysOnTopHint);
|
||||
|
||||
_tform->setMaximumHeight(500);
|
||||
|
||||
using TBInfo = WingHex::WingRibbonToolBoxInfo;
|
||||
|
@ -239,7 +238,7 @@ bool TestPlugin::init(const std::unique_ptr<QSettings> &set) {
|
|||
QStringLiteral("(%1, %2)").arg(i).arg(y));
|
||||
connect(tb, &QToolButton::clicked, this, [this] {
|
||||
auto tb = qobject_cast<QToolButton *>(sender());
|
||||
emit msgbox.information(nullptr, tr("Click"), tb->text());
|
||||
msgInformation(nullptr, tr("Click"), tb->text());
|
||||
});
|
||||
tbtb.tools.append(tb);
|
||||
}
|
||||
|
@ -287,7 +286,7 @@ bool TestPlugin::init(const std::unique_ptr<QSettings> &set) {
|
|||
auto a = new QAction(
|
||||
micon, QStringLiteral("Test - ") + QString::number(i), _tmenu);
|
||||
connect(a, &QAction::triggered, this, [this, a]() {
|
||||
emit msgbox.information(nullptr, QStringLiteral("Test"), a->text());
|
||||
msgInformation(nullptr, QStringLiteral("Test"), a->text());
|
||||
});
|
||||
_tmenu->addAction(a);
|
||||
}
|
||||
|
@ -447,9 +446,8 @@ TestPlugin::colorTable(const QList<void *> ¶ms) {
|
|||
|
||||
auto invoked =
|
||||
invokeService(QStringLiteral("WingAngelAPI"), "vector2AsArray",
|
||||
WINGAPI_RETURN_ARG(void *, array),
|
||||
WINGAPI_ARG(MetaType, MetaType::Color),
|
||||
WINGAPI_ARG(QVector<void *>, colors));
|
||||
WINGAPI_RETURN_ARG(array), WINGAPI_ARG(MetaType::Color),
|
||||
WINGAPI_ARG(colors));
|
||||
if (invoked) {
|
||||
if (array) {
|
||||
qDeleteAll(colors);
|
||||
|
@ -513,10 +511,10 @@ QVariant TestPlugin::testCrash(const QVariantList ¶ms) {
|
|||
return {};
|
||||
}
|
||||
|
||||
void TestPlugin::test_a() { emit debug(__FUNCTION__); }
|
||||
void TestPlugin::test_a() { logDebug(__FUNCTION__); }
|
||||
|
||||
void TestPlugin::test_b(const QString &b) {
|
||||
emit warn(__FUNCTION__ + QStringLiteral(" : ") % b);
|
||||
logWarn(__FUNCTION__ + QStringLiteral(" : ") % b);
|
||||
}
|
||||
|
||||
void TestPlugin::test_c(const QVector<int> &c) {
|
||||
|
@ -531,7 +529,7 @@ void TestPlugin::test_c(const QVector<int> &c) {
|
|||
|
||||
content += QStringLiteral(" }");
|
||||
|
||||
emit warn(content);
|
||||
logWarn(content);
|
||||
}
|
||||
|
||||
void TestPlugin::test_d(const QVariantHash &d) {
|
||||
|
@ -546,29 +544,30 @@ void TestPlugin::test_d(const QVariantHash &d) {
|
|||
content += hash.join(", ");
|
||||
}
|
||||
content += QStringLiteral(" }");
|
||||
emit warn(content);
|
||||
logWarn(content);
|
||||
}
|
||||
|
||||
bool TestPlugin::test_e() {
|
||||
emit warn(__FUNCTION__);
|
||||
logWarn(__FUNCTION__);
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray TestPlugin::test_f() {
|
||||
emit warn(__FUNCTION__);
|
||||
return WingHex::WINGSUMMER.toLatin1();
|
||||
logWarn(__FUNCTION__);
|
||||
return "wingsummer";
|
||||
}
|
||||
|
||||
QString TestPlugin::test_g() {
|
||||
emit warn(__FUNCTION__);
|
||||
return WingHex::WINGSUMMER;
|
||||
logWarn(__FUNCTION__);
|
||||
return "wingsummer";
|
||||
}
|
||||
|
||||
QVariantHash TestPlugin::test_h() {
|
||||
QVariantHash hash;
|
||||
auto t = WingHex::WINGSUMMER.length();
|
||||
constexpr auto str = "wingsummer";
|
||||
auto t = qstrlen(str);
|
||||
for (int i = 0; i < t; ++i) {
|
||||
hash.insert(WingHex::WINGSUMMER.at(i), i);
|
||||
hash.insert(QChar(str[i]), i);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
@ -605,8 +604,8 @@ void TestPlugin::destoryTestShareMem() {
|
|||
}
|
||||
|
||||
void TestPlugin::printLogTestSharedMemData() {
|
||||
emit warn(QByteArray(reinterpret_cast<const char *>(_tsharemem->data()), 20)
|
||||
.toHex(' '));
|
||||
logWarn(QByteArray(reinterpret_cast<const char *>(_tsharemem->data()), 20)
|
||||
.toHex(' '));
|
||||
}
|
||||
|
||||
void TestPlugin::setPluginMetaTestEnabled(bool b) {
|
||||
|
@ -614,7 +613,6 @@ void TestPlugin::setPluginMetaTestEnabled(bool b) {
|
|||
ENABLE_META = b;
|
||||
for (auto &i : TestWingEditorViewWidget::instances()) {
|
||||
i->setEnableMeta(b);
|
||||
emit i->docSaved(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -644,8 +642,8 @@ WingHex::IWingPlugin::RegisteredEvents TestPlugin::registeredEvents() const {
|
|||
|
||||
void TestPlugin::eventReady() {
|
||||
bool ret;
|
||||
emit invokeService(
|
||||
invokeService(
|
||||
QStringLiteral("WingAngelAPI"), "execCode", Qt::AutoConnection,
|
||||
WINGAPI_RETURN_ARG(bool, ret),
|
||||
WINGAPI_ARG(QString, R"(print("Hello, this is TestPlugin!");)"));
|
||||
WINGAPI_RETURN_ARG(ret),
|
||||
WINGAPI_ARG(QString(R"(print("Hello, this is TestPlugin!");)")));
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#ifndef TESTPLUGIN_H
|
||||
#define TESTPLUGIN_H
|
||||
|
||||
#include "iwingplugin.h"
|
||||
#include "WingPlugin/iwingplugin.h"
|
||||
|
||||
#include <QSharedMemory>
|
||||
|
||||
|
@ -41,7 +41,6 @@ public:
|
|||
// IWingPlugin interface (必须)
|
||||
public:
|
||||
virtual int sdkVersion() const override;
|
||||
virtual const QString signature() const override;
|
||||
virtual bool init(const std::unique_ptr<QSettings> &set) override;
|
||||
virtual void unload(std::unique_ptr<QSettings> &set) override;
|
||||
virtual const QString pluginName() const override;
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
** of this software and associated documentation files (the "Software"), to deal
|
||||
** in the Software without restriction, including without limitation the rights
|
||||
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
** copies of the Software, and to permit persons to whom the Software is
|
||||
** furnished to do so.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
** THE SOFTWARE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "testpluginpage.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
|
|
@ -1,7 +1,27 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
** of this software and associated documentation files (the "Software"), to deal
|
||||
** in the Software without restriction, including without limitation the rights
|
||||
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
** copies of the Software, and to permit persons to whom the Software is
|
||||
** furnished to do so.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
** THE SOFTWARE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef TESTPLUGINPAGE_H
|
||||
#define TESTPLUGINPAGE_H
|
||||
|
||||
#include "settingpage.h"
|
||||
#include "WingPlugin/settingpage.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
** of this software and associated documentation files (the "Software"), to deal
|
||||
** in the Software without restriction, including without limitation the rights
|
||||
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
** copies of the Software, and to permit persons to whom the Software is
|
||||
** furnished to do so.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
** THE SOFTWARE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "testsettingpage.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
|
|
@ -1,7 +1,27 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
** of this software and associated documentation files (the "Software"), to deal
|
||||
** in the Software without restriction, including without limitation the rights
|
||||
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
** copies of the Software, and to permit persons to whom the Software is
|
||||
** furnished to do so.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
** THE SOFTWARE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef TESTSETTINGPAGE_H
|
||||
#define TESTSETTINGPAGE_H
|
||||
|
||||
#include "settingpage.h"
|
||||
#include "WingPlugin/settingpage.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
|
|
|
@ -1,6 +1,25 @@
|
|||
#include "testtablemodel.h"
|
||||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
** of this software and associated documentation files (the "Software"), to deal
|
||||
** in the Software without restriction, including without limitation the rights
|
||||
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
** copies of the Software, and to permit persons to whom the Software is
|
||||
** furnished to do so.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
** THE SOFTWARE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "iwingplugin.h"
|
||||
#include "testtablemodel.h"
|
||||
#include "WingPlugin/iwingpluginbase.h"
|
||||
|
||||
TestTableModel::TestTableModel(QObject *parent) : QAbstractTableModel(parent) {}
|
||||
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
** of this software and associated documentation files (the "Software"), to deal
|
||||
** in the Software without restriction, including without limitation the rights
|
||||
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
** copies of the Software, and to permit persons to whom the Software is
|
||||
** furnished to do so.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
** THE SOFTWARE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef TESTTABLEMODEL_H
|
||||
#define TESTTABLEMODEL_H
|
||||
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
** of this software and associated documentation files (the "Software"), to deal
|
||||
** in the Software without restriction, including without limitation the rights
|
||||
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
** copies of the Software, and to permit persons to whom the Software is
|
||||
** furnished to do so.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
** THE SOFTWARE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "testwingeditorviewwidget.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
@ -33,9 +53,8 @@ QString TestWingEditorViewWidget::Creator::id() const {
|
|||
}
|
||||
|
||||
void TestWingEditorViewWidget::toggled(bool isVisible) {
|
||||
plugin()->emit warn(
|
||||
__FUNCTION__ + QStringLiteral(": ") +
|
||||
(isVisible ? QStringLiteral("true") : QStringLiteral("false")));
|
||||
logWarn(__FUNCTION__ + QStringLiteral(": ") +
|
||||
(isVisible ? QStringLiteral("true") : QStringLiteral("false")));
|
||||
}
|
||||
|
||||
WingHex::WingEditorViewWidget *TestWingEditorViewWidget::clone() {
|
||||
|
@ -43,20 +62,16 @@ WingHex::WingEditorViewWidget *TestWingEditorViewWidget::clone() {
|
|||
}
|
||||
|
||||
void TestWingEditorViewWidget::loadState(const QByteArray &state) {
|
||||
plugin()->emit warn(__FUNCTION__ + QStringLiteral(": ") +
|
||||
QString::fromUtf8(state));
|
||||
logWarn(__FUNCTION__ + QStringLiteral(": ") + QString::fromUtf8(state));
|
||||
}
|
||||
|
||||
bool TestWingEditorViewWidget::hasUnsavedState() { return m_unSaved; }
|
||||
|
||||
QByteArray TestWingEditorViewWidget::saveState() {
|
||||
return WingHex::WINGSUMMER.toUtf8();
|
||||
}
|
||||
QByteArray TestWingEditorViewWidget::saveState() { return "wingsummer"; }
|
||||
|
||||
void TestWingEditorViewWidget::onWorkSpaceNotify(bool isWorkSpace) {
|
||||
plugin()->emit warn(
|
||||
__FUNCTION__ + QStringLiteral(": ") +
|
||||
(isWorkSpace ? QStringLiteral("true") : QStringLiteral("false")));
|
||||
logWarn(__FUNCTION__ + QStringLiteral(": ") +
|
||||
(isWorkSpace ? QStringLiteral("true") : QStringLiteral("false")));
|
||||
}
|
||||
|
||||
QList<TestWingEditorViewWidget *> TestWingEditorViewWidget::instances() {
|
||||
|
|
|
@ -1,7 +1,27 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
** of this software and associated documentation files (the "Software"), to deal
|
||||
** in the Software without restriction, including without limitation the rights
|
||||
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
** copies of the Software, and to permit persons to whom the Software is
|
||||
** furnished to do so.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
** THE SOFTWARE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef TESTWINGEDITORVIEWWIDGET_H
|
||||
#define TESTWINGEDITORVIEWWIDGET_H
|
||||
|
||||
#include "iwingplugin.h"
|
||||
#include "WingPlugin/iwingplugin.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(WingPlugin LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
|
||||
|
||||
add_library(
|
||||
WingPlugin SHARED
|
||||
iwingplugin.cpp
|
||||
iwingplugin.h
|
||||
iwingpluginbase.h
|
||||
iwingpluginbase.cpp
|
||||
wingplugin_global.h
|
||||
wingcore.h
|
||||
wingplugincalls.h
|
||||
wingplugincalls.cpp
|
||||
wingplugincalls_p.h
|
||||
wingeditorviewwidget.h
|
||||
wingeditorviewwidget.cpp
|
||||
settingpage.h
|
||||
iwingdevice.h
|
||||
iwingdevice.cpp
|
||||
settingpage.cpp
|
||||
iwingpluginbasecalls.h
|
||||
iwingpluginbasecalls.cpp
|
||||
iwingplugincalls.h
|
||||
iwingplugincalls.cpp
|
||||
wingplugincallconvertor.h
|
||||
wingplugincallconvertor.cpp
|
||||
wingpluginwidget.h
|
||||
wingpluginwidget.cpp)
|
||||
|
||||
target_link_libraries(WingPlugin PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
target_include_directories(WingPlugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
|
||||
target_compile_definitions(WingPlugin PRIVATE WINGPLUGIN_LIBRARY)
|
|
@ -1,21 +1,21 @@
|
|||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2019-2022, Pedro López-Cabanillas
|
||||
Copyright (c) 2018, the respective contributors, as shown by the AUTHORS file.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
|
@ -26,4 +26,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,33 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "iwingdevice.h"
|
||||
|
||||
using namespace WingHex;
|
||||
|
||||
IWingDevice::IWingDevice(QObject *parent) : IWingPluginBase() {}
|
||||
|
||||
QIcon IWingDevice::supportedFileIcon() const { return {}; }
|
||||
|
||||
QString IWingDevice::onOpenFileBegin() { return {}; }
|
||||
|
||||
WingIODevice::WingIODevice(QObject *parent) : QIODevice(parent) {}
|
||||
|
||||
bool WingIODevice::keepSize() const { return false; }
|
|
@ -23,29 +23,32 @@
|
|||
|
||||
#include "iwingpluginbase.h"
|
||||
|
||||
#include <optional>
|
||||
#include <QIODevice>
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
class WingIODevice : public QIODevice {
|
||||
class WINGPLUGIN_EXPORT WingIODevice : public QIODevice {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WingIODevice(QObject *parent = nullptr) : QIODevice(parent) {}
|
||||
WingIODevice(QObject *parent = nullptr);
|
||||
|
||||
// can not change size during editing (default: changing-abled)
|
||||
virtual bool keepSize() const { return false; };
|
||||
virtual bool keepSize() const;
|
||||
};
|
||||
|
||||
class IWingDevice : public IWingPluginBase {
|
||||
class WINGPLUGIN_EXPORT IWingDevice : public IWingPluginBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IWingDevice(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
virtual QString supportedFileExtDisplayName() const = 0;
|
||||
|
||||
virtual QIcon supportedFileIcon() const { return {}; };
|
||||
virtual QIcon supportedFileIcon() const;
|
||||
|
||||
public:
|
||||
virtual QString onOpenFileBegin() { return {}; }
|
||||
virtual QString onOpenFileBegin();
|
||||
|
||||
virtual WingIODevice *onOpenFile(const QString &path) = 0;
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "iwingplugin.h"
|
||||
|
||||
using namespace WingHex;
|
||||
|
||||
IWingPlugin::IWingPlugin() : IWingPluginBase(), IWingPluginCalls(this) {}
|
||||
|
||||
QVariant IWingPlugin::getScriptCallError(int errCode, const QString &msg) {
|
||||
ScriptCallError err;
|
||||
|
||||
err.errorCode = errCode;
|
||||
err.errmsg = msg;
|
||||
|
||||
return QVariant::fromValue(err);
|
||||
}
|
||||
|
||||
IWingPlugin::RegisteredEvents IWingPlugin::registeredEvents() const {
|
||||
return RegisteredEvent::None;
|
||||
}
|
||||
|
||||
QMenu *IWingPlugin::registeredHexContextMenu() const { return nullptr; }
|
||||
|
||||
QList<WingRibbonToolBoxInfo> IWingPlugin::registeredRibbonTools() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
QHash<SettingPage *, bool> IWingPlugin::registeredSettingPages() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
QList<QSharedPointer<WingEditorViewWidget::Creator>>
|
||||
IWingPlugin::registeredEditorViewWidgets() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
QHash<QString, QList<QPair<QString, int>>>
|
||||
IWingPlugin::registeredScriptEnums() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
QStringList IWingPlugin::registerScriptMarcos() const { return {}; }
|
||||
|
||||
void IWingPlugin::eventSelectionChanged(const QByteArrayList &selections,
|
||||
bool isPreview) {
|
||||
Q_UNUSED(selections);
|
||||
Q_UNUSED(isPreview);
|
||||
}
|
||||
|
||||
void IWingPlugin::eventCursorPositionChanged(const HexPosition &pos) {
|
||||
Q_UNUSED(pos);
|
||||
}
|
||||
|
||||
void IWingPlugin::eventPluginFile(PluginFileEvent e, FileType type,
|
||||
const QString &newfileName, int handle,
|
||||
const QString &oldfileName) {
|
||||
Q_UNUSED(e);
|
||||
Q_UNUSED(newfileName);
|
||||
Q_UNUSED(oldfileName);
|
||||
Q_UNUSED(handle);
|
||||
Q_UNUSED(type);
|
||||
}
|
||||
|
||||
void IWingPlugin::eventReady() {}
|
||||
|
||||
bool IWingPlugin::eventClosing() { return true; }
|
||||
|
||||
bool IWingPlugin::eventOnScriptPragma(const QString &script,
|
||||
const QStringList &comments) {
|
||||
Q_UNUSED(script);
|
||||
Q_UNUSED(comments);
|
||||
return false;
|
||||
}
|
||||
|
||||
void IWingPlugin::eventOnScriptPragmaInit() {}
|
||||
|
||||
QHash<QString, IWingPlugin::UNSAFE_SCFNPTR>
|
||||
IWingPlugin::registeredScriptUnsafeFns() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
QHash<QString, IWingPlugin::ScriptFnInfo>
|
||||
IWingPlugin::registeredScriptFns() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
ScriptCallError IWingPlugin::generateScriptCallError(int errCode,
|
||||
const QString &msg) {
|
||||
ScriptCallError err;
|
||||
|
||||
err.errorCode = errCode;
|
||||
err.errmsg = msg;
|
||||
|
||||
return err;
|
||||
}
|
|
@ -0,0 +1,223 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef IWINGPLUGIN_H
|
||||
#define IWINGPLUGIN_H
|
||||
|
||||
#include "WingPlugin/iwingplugincalls.h"
|
||||
#include "iwingpluginbase.h"
|
||||
#include "wingeditorviewwidget.h"
|
||||
#include "wingplugin_global.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
class IWingPlugin;
|
||||
|
||||
struct WINGPLUGIN_EXPORT SenderInfo {
|
||||
QString plgcls;
|
||||
QString puid;
|
||||
QVariant meta;
|
||||
};
|
||||
|
||||
struct WINGPLUGIN_EXPORT WingRibbonToolBoxInfo {
|
||||
struct WINGPLUGIN_EXPORT RibbonCatagories {
|
||||
const QString FILE = QStringLiteral("File");
|
||||
const QString EDIT = QStringLiteral("Edit");
|
||||
const QString VIEW = QStringLiteral("View");
|
||||
const QString SCRIPT = QStringLiteral("Script");
|
||||
const QString PLUGIN = QStringLiteral("Plugin");
|
||||
const QString SETTING = QStringLiteral("Setting");
|
||||
const QString ABOUT = QStringLiteral("About");
|
||||
};
|
||||
|
||||
QString catagory;
|
||||
QString displayName;
|
||||
|
||||
struct WINGPLUGIN_EXPORT Toolbox {
|
||||
QString name;
|
||||
QList<QToolButton *> tools;
|
||||
};
|
||||
QList<Toolbox> toolboxs;
|
||||
};
|
||||
|
||||
struct WINGPLUGIN_EXPORT ScriptCallError {
|
||||
int errorCode;
|
||||
QString errmsg;
|
||||
};
|
||||
|
||||
class SettingPage;
|
||||
|
||||
class WINGPLUGIN_EXPORT IWingPlugin : public IWingPluginBase,
|
||||
public IWingPluginCalls {
|
||||
Q_OBJECT
|
||||
public:
|
||||
IWingPlugin();
|
||||
|
||||
public:
|
||||
using ScriptFn = std::function<QVariant(const QVariantList &)>;
|
||||
|
||||
using UNSAFE_RET =
|
||||
std::variant<std::monostate, bool, quint8, quint16, quint32, quint64,
|
||||
float, double, void *, ScriptCallError>;
|
||||
using UNSAFE_SCFNPTR = std::function<UNSAFE_RET(const QList<void *> &)>;
|
||||
|
||||
enum MetaType : uint {
|
||||
Void,
|
||||
|
||||
Bool,
|
||||
Int,
|
||||
Int32 = Int,
|
||||
UInt,
|
||||
UInt32 = UInt,
|
||||
Int8,
|
||||
UInt8,
|
||||
Int16,
|
||||
UInt16,
|
||||
Int64,
|
||||
UInt64,
|
||||
|
||||
Float,
|
||||
Double,
|
||||
|
||||
String,
|
||||
Char,
|
||||
Byte,
|
||||
Color,
|
||||
|
||||
Map, // QVariantMap -> dictionary
|
||||
Hash, // QVariantHash -> dictionary
|
||||
|
||||
MetaMax, // reserved
|
||||
MetaTypeMask = 0xFFFFF,
|
||||
Array = 0x100000, // QVector<?> -> array<?>
|
||||
List = 0x200000, // QList<?> -> array<?>
|
||||
};
|
||||
|
||||
static_assert(MetaType::MetaMax < MetaType::Array);
|
||||
|
||||
struct ScriptFnInfo {
|
||||
MetaType ret;
|
||||
QVector<QPair<MetaType, QString>> params;
|
||||
ScriptFn fn;
|
||||
};
|
||||
|
||||
enum class RegisteredEvent : uint {
|
||||
None,
|
||||
AppReady = 1u,
|
||||
AppClosing = 1u << 1,
|
||||
SelectionChanged = 1u << 2,
|
||||
CursorPositionChanged = 1u << 3,
|
||||
FileOpened = 1u << 4,
|
||||
FileSaved = 1u << 5,
|
||||
FileSwitched = 1u << 6,
|
||||
FileClosed = 1u << 7,
|
||||
ScriptPragma = 1u << 8,
|
||||
PluginFileOpened = 1u << 9,
|
||||
PluginFileClosed = 1u << 10,
|
||||
ScriptUnSafeFnRegistering = 1u << 11,
|
||||
ScriptPragmaInit = 1u << 12
|
||||
};
|
||||
Q_DECLARE_FLAGS(RegisteredEvents, RegisteredEvent)
|
||||
|
||||
enum class PluginFileEvent {
|
||||
Opened,
|
||||
Saved,
|
||||
Exported,
|
||||
Switched,
|
||||
Closed,
|
||||
PluginOpened,
|
||||
PluginClosed
|
||||
};
|
||||
|
||||
enum class FileType { Invalid, File, Extension };
|
||||
Q_ENUM(FileType)
|
||||
|
||||
public:
|
||||
ScriptCallError generateScriptCallError(int errCode, const QString &msg);
|
||||
|
||||
QVariant getScriptCallError(int errCode, const QString &msg);
|
||||
|
||||
public:
|
||||
virtual ~IWingPlugin() = default;
|
||||
|
||||
virtual RegisteredEvents registeredEvents() const;
|
||||
|
||||
public:
|
||||
virtual QMenu *registeredHexContextMenu() const;
|
||||
virtual QList<WingRibbonToolBoxInfo> registeredRibbonTools() const;
|
||||
// QMap<page, whether is visible in setting tab>
|
||||
virtual QHash<SettingPage *, bool> registeredSettingPages() const;
|
||||
|
||||
virtual QList<QSharedPointer<WingEditorViewWidget::Creator>>
|
||||
registeredEditorViewWidgets() const;
|
||||
|
||||
public:
|
||||
// QHash< function-name, fn >
|
||||
virtual QHash<QString, ScriptFnInfo> registeredScriptFns() const;
|
||||
|
||||
// A hacking way to register script function (Generic_Call)
|
||||
// This registering way is not safe. There is no
|
||||
// other checking except function's signature.
|
||||
// You should handle your all the types and pay yourself.
|
||||
|
||||
// You should set RegisteredEvent::ScriptFnRegistering ON to enable it.
|
||||
|
||||
// QHash< function-name, fn >
|
||||
virtual QHash<QString, UNSAFE_SCFNPTR> registeredScriptUnsafeFns() const;
|
||||
|
||||
// QHash< enum , members >
|
||||
virtual QHash<QString, QList<QPair<QString, int>>>
|
||||
registeredScriptEnums() const;
|
||||
|
||||
// Note: must be valid identifier
|
||||
virtual QStringList registerScriptMarcos() const;
|
||||
|
||||
public:
|
||||
virtual void eventSelectionChanged(const QByteArrayList &selections,
|
||||
bool isPreview);
|
||||
|
||||
virtual void eventCursorPositionChanged(const WingHex::HexPosition &pos);
|
||||
|
||||
virtual void eventPluginFile(PluginFileEvent e, FileType type,
|
||||
const QString &newfileName, int handle,
|
||||
const QString &oldfileName);
|
||||
|
||||
virtual void eventReady();
|
||||
|
||||
virtual bool eventClosing();
|
||||
|
||||
public:
|
||||
virtual bool eventOnScriptPragma(const QString &script,
|
||||
const QStringList &comments);
|
||||
|
||||
virtual void eventOnScriptPragmaInit();
|
||||
};
|
||||
|
||||
} // namespace WingHex
|
||||
|
||||
Q_DECLARE_METATYPE(WingHex::SenderInfo)
|
||||
Q_DECLARE_METATYPE(WingHex::ScriptCallError)
|
||||
Q_DECLARE_INTERFACE(WingHex::IWingPlugin, "com.wingsummer.iwingplugin")
|
||||
|
||||
#endif // IWINGPLUGIN_H
|
|
@ -0,0 +1,47 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "iwingpluginbase.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDialog>
|
||||
#include <QMetaMethod>
|
||||
|
||||
using namespace WingHex;
|
||||
|
||||
IWingPluginBase::IWingPluginBase() : IWingPluginBaseCalls(this) {}
|
||||
|
||||
QIcon IWingPluginBase::pluginIcon() const { return {}; }
|
||||
|
||||
QString IWingPluginBase::retranslate(const QString &str) { return str; }
|
||||
|
||||
QList<WingDockWidgetInfo> IWingPluginBase::registeredDockWidgets() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
QList<PluginPage *> IWingPluginBase::registeredPages() const { return {}; }
|
||||
|
||||
QString WingHex::PLUGINDIR() {
|
||||
return QCoreApplication::applicationDirPath() + QStringLiteral("/plugin");
|
||||
}
|
||||
|
||||
QString WingHex::HOSTRESPIMG(const QString &name, const QString &suffix) {
|
||||
return QStringLiteral(":/com.wingsummer.winghex/images/") + name + suffix;
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef IWINGPLUGINBASE_H
|
||||
#define IWINGPLUGINBASE_H
|
||||
|
||||
#include "WingPlugin/iwingpluginbasecalls.h"
|
||||
#include "wingplugin_global.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
Q_DECL_UNUSED constexpr auto SDKVERSION = 16;
|
||||
|
||||
WINGPLUGIN_EXPORT QString PLUGINDIR();
|
||||
|
||||
WINGPLUGIN_EXPORT QString HOSTRESPIMG(
|
||||
const QString &name, const QString &suffix = QStringLiteral(".png"));
|
||||
|
||||
class PluginPage;
|
||||
|
||||
class WINGPLUGIN_EXPORT IWingPluginBase : public QObject,
|
||||
public IWingPluginBaseCalls {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IWingPluginBase();
|
||||
virtual ~IWingPluginBase() = default;
|
||||
|
||||
public:
|
||||
virtual int sdkVersion() const = 0;
|
||||
|
||||
virtual bool init(const std::unique_ptr<QSettings> &set) = 0;
|
||||
virtual void unload(std::unique_ptr<QSettings> &set) = 0;
|
||||
|
||||
virtual const QString pluginName() const = 0;
|
||||
virtual QIcon pluginIcon() const;
|
||||
virtual const QString pluginComment() const = 0;
|
||||
|
||||
virtual QString retranslate(const QString &str);
|
||||
|
||||
public:
|
||||
virtual QList<WingDockWidgetInfo> registeredDockWidgets() const;
|
||||
|
||||
virtual QList<PluginPage *> registeredPages() const;
|
||||
};
|
||||
|
||||
} // namespace WingHex
|
||||
|
||||
#endif // IWINGPLUGINBASE_H
|
|
@ -0,0 +1,302 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "iwingpluginbasecalls.h"
|
||||
|
||||
#include "WingPlugin/wingcore.h"
|
||||
#include "iwingpluginbase.h"
|
||||
|
||||
using namespace WingHex;
|
||||
|
||||
IWingPluginBaseCalls::IWingPluginBaseCalls(IWingPluginBase *const caller)
|
||||
: WingPluginCalls(caller) {}
|
||||
|
||||
void IWingPluginBaseCalls::toast(const QPixmap &icon, const QString &message) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::toast);
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, getSenderObj(),
|
||||
WINGAPI_ARG(icon), WINGAPI_ARG(message));
|
||||
}
|
||||
|
||||
void IWingPluginBaseCalls::logTrace(const QString &message) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::logTrace);
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, getSenderObj(),
|
||||
WINGAPI_ARG(message));
|
||||
}
|
||||
|
||||
void IWingPluginBaseCalls::logDebug(const QString &message) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::logDebug);
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, getSenderObj(),
|
||||
WINGAPI_ARG(message));
|
||||
}
|
||||
|
||||
void IWingPluginBaseCalls::logWarn(const QString &message) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::logWarn);
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, getSenderObj(),
|
||||
WINGAPI_ARG(message));
|
||||
}
|
||||
|
||||
void IWingPluginBaseCalls::logError(const QString &message) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::logError);
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, getSenderObj(),
|
||||
WINGAPI_ARG(message));
|
||||
}
|
||||
|
||||
void IWingPluginBaseCalls::logInfo(const QString &message) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::logInfo);
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, getSenderObj(),
|
||||
WINGAPI_ARG(message));
|
||||
}
|
||||
|
||||
bool IWingPluginBaseCalls::raiseDockWidget(QWidget *w) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::raiseDockWidget);
|
||||
bool ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(w));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QDialog *IWingPluginBaseCalls::createDialog(QWidget *content) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::createDialog);
|
||||
QDialog *ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(content));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void IWingPluginBaseCalls::msgAboutQt(QWidget *parent, const QString &title) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::msgAboutQt);
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, getSenderObj(),
|
||||
WINGAPI_ARG(parent), WINGAPI_ARG(title));
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton IWingPluginBaseCalls::msgInformation(
|
||||
QWidget *parent, const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::msgInformation);
|
||||
QMessageBox::StandardButton ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(title),
|
||||
WINGAPI_ARG(text), WINGAPI_ARG(buttons),
|
||||
WINGAPI_ARG(defaultButton));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton
|
||||
IWingPluginBaseCalls::msgQuestion(QWidget *parent, const QString &title,
|
||||
const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::msgQuestion);
|
||||
QMessageBox::StandardButton ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(title),
|
||||
WINGAPI_ARG(text), WINGAPI_ARG(buttons),
|
||||
WINGAPI_ARG(defaultButton));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton
|
||||
IWingPluginBaseCalls::msgWarning(QWidget *parent, const QString &title,
|
||||
const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::msgWarning);
|
||||
QMessageBox::StandardButton ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(title),
|
||||
WINGAPI_ARG(text), WINGAPI_ARG(buttons),
|
||||
WINGAPI_ARG(defaultButton));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton
|
||||
IWingPluginBaseCalls::critical(QWidget *parent, const QString &title,
|
||||
const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::critical);
|
||||
QMessageBox::StandardButton ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(title),
|
||||
WINGAPI_ARG(text), WINGAPI_ARG(buttons),
|
||||
WINGAPI_ARG(defaultButton));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void IWingPluginBaseCalls::msgAbout(QWidget *parent, const QString &title,
|
||||
const QString &text) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::msgAbout);
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, getSenderObj(),
|
||||
WINGAPI_ARG(parent), WINGAPI_ARG(title), WINGAPI_ARG(text));
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton
|
||||
IWingPluginBaseCalls::msgbox(QWidget *parent, QMessageBox::Icon icon,
|
||||
const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::msgbox);
|
||||
QMessageBox::StandardButton ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(icon),
|
||||
WINGAPI_ARG(title), WINGAPI_ARG(text), WINGAPI_ARG(buttons),
|
||||
WINGAPI_ARG(defaultButton));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString
|
||||
IWingPluginBaseCalls::dlgGetText(QWidget *parent, const QString &title,
|
||||
const QString &label, QLineEdit::EchoMode echo,
|
||||
const QString &text, bool *ok,
|
||||
Qt::InputMethodHints inputMethodHints) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::dlgGetText);
|
||||
QString ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(title),
|
||||
WINGAPI_ARG(label), WINGAPI_ARG(echo), WINGAPI_ARG(text),
|
||||
WINGAPI_ARG(ok), WINGAPI_ARG(inputMethodHints));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString IWingPluginBaseCalls::dlgGetMultiLineText(
|
||||
QWidget *parent, const QString &title, const QString &label,
|
||||
const QString &text, bool *ok, Qt::InputMethodHints inputMethodHints) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::dlgGetMultiLineText);
|
||||
QString ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(title),
|
||||
WINGAPI_ARG(label), WINGAPI_ARG(text), WINGAPI_ARG(ok),
|
||||
WINGAPI_ARG(inputMethodHints));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString
|
||||
IWingPluginBaseCalls::dlgGetItem(QWidget *parent, const QString &title,
|
||||
const QString &label, const QStringList &items,
|
||||
int current, bool editable, bool *ok,
|
||||
Qt::InputMethodHints inputMethodHints) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::dlgGetItem);
|
||||
QString ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(title),
|
||||
WINGAPI_ARG(label), WINGAPI_ARG(items), WINGAPI_ARG(current),
|
||||
WINGAPI_ARG(editable), WINGAPI_ARG(ok),
|
||||
WINGAPI_ARG(inputMethodHints));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int IWingPluginBaseCalls::dlgGetInt(QWidget *parent, const QString &title,
|
||||
const QString &label, int value,
|
||||
int minValue, int maxValue, int step,
|
||||
bool *ok) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::dlgGetInt);
|
||||
int ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(title),
|
||||
WINGAPI_ARG(label), WINGAPI_ARG(value), WINGAPI_ARG(minValue),
|
||||
WINGAPI_ARG(maxValue), WINGAPI_ARG(step), WINGAPI_ARG(ok));
|
||||
return ret;
|
||||
}
|
||||
|
||||
double IWingPluginBaseCalls::dlgGetDouble(QWidget *parent, const QString &title,
|
||||
const QString &label, double value,
|
||||
double minValue, double maxValue,
|
||||
int decimals, bool *ok, double step) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::dlgGetDouble);
|
||||
double ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(title),
|
||||
WINGAPI_ARG(label), WINGAPI_ARG(value), WINGAPI_ARG(minValue),
|
||||
WINGAPI_ARG(maxValue), WINGAPI_ARG(decimals), WINGAPI_ARG(ok),
|
||||
WINGAPI_ARG(step));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString IWingPluginBaseCalls::dlgGetExistingDirectory(
|
||||
QWidget *parent, const QString &caption, const QString &dir,
|
||||
QFileDialog::Options options) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::dlgGetExistingDirectory);
|
||||
QString ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(caption),
|
||||
WINGAPI_ARG(dir), WINGAPI_ARG(options));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString IWingPluginBaseCalls::dlgGetOpenFileName(QWidget *parent,
|
||||
const QString &caption,
|
||||
const QString &dir,
|
||||
const QString &filter,
|
||||
QString *selectedFilter,
|
||||
QFileDialog::Options options) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::dlgGetOpenFileName);
|
||||
QString ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(caption),
|
||||
WINGAPI_ARG(dir), WINGAPI_ARG(filter), WINGAPI_ARG(selectedFilter),
|
||||
WINGAPI_ARG(options));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QStringList IWingPluginBaseCalls::dlgGetOpenFileNames(
|
||||
QWidget *parent, const QString &caption, const QString &dir,
|
||||
const QString &filter, QString *selectedFilter,
|
||||
QFileDialog::Options options) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::dlgGetOpenFileNames);
|
||||
QStringList ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(caption),
|
||||
WINGAPI_ARG(dir), WINGAPI_ARG(filter), WINGAPI_ARG(selectedFilter),
|
||||
WINGAPI_ARG(options));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString IWingPluginBaseCalls::dlgGetSaveFileName(QWidget *parent,
|
||||
const QString &caption,
|
||||
const QString &dir,
|
||||
const QString &filter,
|
||||
QString *selectedFilter,
|
||||
QFileDialog::Options options) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::dlgGetSaveFileName);
|
||||
QString ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(parent), WINGAPI_ARG(caption),
|
||||
WINGAPI_ARG(dir), WINGAPI_ARG(filter), WINGAPI_ARG(selectedFilter),
|
||||
WINGAPI_ARG(options));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QColor IWingPluginBaseCalls::dlgGetColor(const QString &caption,
|
||||
QWidget *parent) {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::dlgGetColor);
|
||||
QColor ret;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(ret),
|
||||
getSenderObj(), WINGAPI_ARG(caption), WINGAPI_ARG(parent));
|
||||
return ret;
|
||||
}
|
||||
|
||||
AppTheme IWingPluginBaseCalls::currentAppTheme() {
|
||||
SETUP_CALL_CONTEXT(&IWingPluginBaseCalls::currentAppTheme);
|
||||
WingHex::AppTheme theme;
|
||||
m.invoke(callReceiver(), Qt::DirectConnection, WINGAPI_RETURN_ARG(theme),
|
||||
getSenderObj());
|
||||
return theme;
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef IWINGPLUGINBASECALLS_H
|
||||
#define IWINGPLUGINBASECALLS_H
|
||||
|
||||
#include "WingPlugin/wingplugincallconvertor.h"
|
||||
#include "wingplugincalls.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QIcon>
|
||||
#include <QLineEdit>
|
||||
#include <QList>
|
||||
#include <QMessageBox>
|
||||
#include <QObject>
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
class IWingPluginBase;
|
||||
|
||||
class WINGPLUGIN_EXPORT IWingPluginBaseCalls : public WingPluginCalls {
|
||||
public:
|
||||
explicit IWingPluginBaseCalls(IWingPluginBase *const caller);
|
||||
|
||||
public:
|
||||
void toast(const QPixmap &icon, const QString &message);
|
||||
void logTrace(const QString &message);
|
||||
void logDebug(const QString &message);
|
||||
void logWarn(const QString &message);
|
||||
void logError(const QString &message);
|
||||
void logInfo(const QString &message);
|
||||
|
||||
bool raiseDockWidget(QWidget *w);
|
||||
|
||||
// theme
|
||||
WingHex::AppTheme currentAppTheme();
|
||||
|
||||
// not available for AngelScript
|
||||
// only for plugin UI extenstion
|
||||
|
||||
QDialog *createDialog(QWidget *content);
|
||||
|
||||
public:
|
||||
void msgAboutQt(QWidget *parent = nullptr,
|
||||
const QString &title = QString());
|
||||
|
||||
QMessageBox::StandardButton msgInformation(
|
||||
QWidget *parent, const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||
|
||||
QMessageBox::StandardButton msgQuestion(
|
||||
QWidget *parent, const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons =
|
||||
QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No),
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||
|
||||
QMessageBox::StandardButton msgWarning(
|
||||
QWidget *parent, const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||
|
||||
QMessageBox::StandardButton
|
||||
critical(QWidget *parent, const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||
|
||||
void msgAbout(QWidget *parent, const QString &title, const QString &text);
|
||||
|
||||
QMessageBox::StandardButton
|
||||
msgbox(QWidget *parent, QMessageBox::Icon icon, const QString &title,
|
||||
const QString &text,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::NoButton,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||
|
||||
public:
|
||||
Q_REQUIRED_RESULT QString
|
||||
dlgGetText(QWidget *parent, const QString &title, const QString &label,
|
||||
QLineEdit::EchoMode echo = QLineEdit::Normal,
|
||||
const QString &text = QString(), bool *ok = nullptr,
|
||||
Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
|
||||
Q_REQUIRED_RESULT QString dlgGetMultiLineText(
|
||||
QWidget *parent, const QString &title, const QString &label,
|
||||
const QString &text = QString(), bool *ok = nullptr,
|
||||
Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
|
||||
|
||||
Q_REQUIRED_RESULT QString
|
||||
dlgGetItem(QWidget *parent, const QString &title, const QString &label,
|
||||
const QStringList &items, int current = 0, bool editable = true,
|
||||
bool *ok = nullptr,
|
||||
Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
|
||||
|
||||
Q_REQUIRED_RESULT int dlgGetInt(QWidget *parent, const QString &title,
|
||||
const QString &label, int value = 0,
|
||||
int minValue = -2147483647,
|
||||
int maxValue = 2147483647, int step = 1,
|
||||
bool *ok = nullptr);
|
||||
|
||||
Q_REQUIRED_RESULT double
|
||||
dlgGetDouble(QWidget *parent, const QString &title, const QString &label,
|
||||
double value = 0, double minValue = -2147483647,
|
||||
double maxValue = 2147483647, int decimals = 1,
|
||||
bool *ok = nullptr, double step = 1);
|
||||
|
||||
public:
|
||||
Q_REQUIRED_RESULT QString dlgGetExistingDirectory(
|
||||
QWidget *parent = nullptr, const QString &caption = QString(),
|
||||
const QString &dir = QString(),
|
||||
QFileDialog::Options options = QFileDialog::ShowDirsOnly);
|
||||
|
||||
Q_REQUIRED_RESULT QString dlgGetOpenFileName(
|
||||
QWidget *parent = nullptr, const QString &caption = QString(),
|
||||
const QString &dir = QString(), const QString &filter = QString(),
|
||||
QString *selectedFilter = nullptr,
|
||||
QFileDialog::Options options = QFileDialog::Options());
|
||||
|
||||
Q_REQUIRED_RESULT QStringList dlgGetOpenFileNames(
|
||||
QWidget *parent = nullptr, const QString &caption = QString(),
|
||||
const QString &dir = QString(), const QString &filter = QString(),
|
||||
QString *selectedFilter = nullptr,
|
||||
QFileDialog::Options options = QFileDialog::Options());
|
||||
|
||||
Q_REQUIRED_RESULT QString dlgGetSaveFileName(
|
||||
QWidget *parent = nullptr, const QString &caption = QString(),
|
||||
const QString &dir = QString(), const QString &filter = QString(),
|
||||
QString *selectedFilter = nullptr,
|
||||
QFileDialog::Options options = QFileDialog::Options());
|
||||
|
||||
public:
|
||||
Q_REQUIRED_RESULT QColor dlgGetColor(const QString &caption,
|
||||
QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
} // namespace WingHex
|
||||
|
||||
Q_DECLARE_METATYPE(QMessageBox::StandardButtons)
|
||||
Q_DECLARE_METATYPE(QMessageBox::StandardButton)
|
||||
Q_DECLARE_METATYPE(bool *)
|
||||
Q_DECLARE_METATYPE(QString *)
|
||||
|
||||
#endif // IWINGPLUGINBASECALLS_H
|
|
@ -0,0 +1,305 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef IWINGPLUGINCALLS_H
|
||||
#define IWINGPLUGINCALLS_H
|
||||
|
||||
#include "WingPlugin/iwingpluginbasecalls.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
struct WINGPLUGIN_EXPORT HexPosition {
|
||||
qsizetype line;
|
||||
int column;
|
||||
quint8 lineWidth;
|
||||
int nibbleindex;
|
||||
|
||||
HexPosition();
|
||||
Q_REQUIRED_RESULT qsizetype offset() const;
|
||||
qsizetype operator-(const HexPosition &rhs) const;
|
||||
bool operator==(const HexPosition &rhs) const;
|
||||
bool operator!=(const HexPosition &rhs) const;
|
||||
};
|
||||
|
||||
class IWingPlugin;
|
||||
|
||||
class WINGPLUGIN_EXPORT IWingPluginCalls : public WingPluginCalls {
|
||||
public:
|
||||
explicit IWingPluginCalls(IWingPlugin *const caller);
|
||||
|
||||
public:
|
||||
bool existsServiceHost(const QString &puid);
|
||||
|
||||
bool invokeService(const QString &puid, const char *method,
|
||||
Qt::ConnectionType type, QGenericReturnArgument ret,
|
||||
QGenericArgument val0 = QGenericArgument(nullptr),
|
||||
QGenericArgument val1 = QGenericArgument(),
|
||||
QGenericArgument val2 = QGenericArgument(),
|
||||
QGenericArgument val3 = QGenericArgument(),
|
||||
QGenericArgument val4 = QGenericArgument());
|
||||
|
||||
bool invokeService(const QString &puid, const char *member,
|
||||
QGenericReturnArgument ret,
|
||||
QGenericArgument val0 = QGenericArgument(nullptr),
|
||||
QGenericArgument val1 = QGenericArgument(),
|
||||
QGenericArgument val2 = QGenericArgument(),
|
||||
QGenericArgument val3 = QGenericArgument(),
|
||||
QGenericArgument val4 = QGenericArgument());
|
||||
|
||||
bool invokeService(const QString &puid, const char *member,
|
||||
Qt::ConnectionType type, QGenericArgument val0,
|
||||
QGenericArgument val1 = QGenericArgument(),
|
||||
QGenericArgument val2 = QGenericArgument(),
|
||||
QGenericArgument val3 = QGenericArgument(),
|
||||
QGenericArgument val4 = QGenericArgument());
|
||||
|
||||
bool invokeService(const QString &puid, const char *member,
|
||||
QGenericArgument val0,
|
||||
QGenericArgument val1 = QGenericArgument(),
|
||||
QGenericArgument val2 = QGenericArgument(),
|
||||
QGenericArgument val3 = QGenericArgument(),
|
||||
QGenericArgument val4 = QGenericArgument());
|
||||
|
||||
public:
|
||||
Q_REQUIRED_RESULT bool isCurrentDocEditing();
|
||||
Q_REQUIRED_RESULT QString currentDocFilename();
|
||||
|
||||
// document
|
||||
Q_REQUIRED_RESULT bool isReadOnly();
|
||||
Q_REQUIRED_RESULT bool isInsertionMode();
|
||||
Q_REQUIRED_RESULT bool isKeepSize();
|
||||
Q_REQUIRED_RESULT bool isLocked();
|
||||
Q_REQUIRED_RESULT qsizetype documentLines();
|
||||
Q_REQUIRED_RESULT qsizetype documentBytes();
|
||||
Q_REQUIRED_RESULT WingHex::HexPosition currentPos();
|
||||
Q_REQUIRED_RESULT qsizetype currentRow();
|
||||
Q_REQUIRED_RESULT qsizetype currentColumn();
|
||||
Q_REQUIRED_RESULT qsizetype currentOffset();
|
||||
Q_REQUIRED_RESULT qsizetype selectedLength();
|
||||
|
||||
Q_REQUIRED_RESULT QByteArray selectedBytes(qsizetype index);
|
||||
Q_REQUIRED_RESULT QByteArrayList selectionBytes();
|
||||
|
||||
Q_REQUIRED_RESULT WingHex::HexPosition selectionStart(qsizetype index);
|
||||
Q_REQUIRED_RESULT WingHex::HexPosition selectionEnd(qsizetype index);
|
||||
Q_REQUIRED_RESULT qsizetype selectionLength(qsizetype index);
|
||||
Q_REQUIRED_RESULT qsizetype selectionCount();
|
||||
|
||||
Q_REQUIRED_RESULT bool stringVisible();
|
||||
Q_REQUIRED_RESULT bool addressVisible();
|
||||
Q_REQUIRED_RESULT bool headerVisible();
|
||||
Q_REQUIRED_RESULT quintptr addressBase();
|
||||
Q_REQUIRED_RESULT bool isModified();
|
||||
|
||||
Q_REQUIRED_RESULT qint8 readInt8(qsizetype offset);
|
||||
Q_REQUIRED_RESULT qint16 readInt16(qsizetype offset);
|
||||
Q_REQUIRED_RESULT qint32 readInt32(qsizetype offset);
|
||||
Q_REQUIRED_RESULT qint64 readInt64(qsizetype offset);
|
||||
Q_REQUIRED_RESULT quint8 readUInt8(qsizetype offset);
|
||||
Q_REQUIRED_RESULT quint16 readUInt16(qsizetype offset);
|
||||
Q_REQUIRED_RESULT quint32 readUInt32(qsizetype offset);
|
||||
Q_REQUIRED_RESULT quint64 readUInt64(qsizetype offset);
|
||||
Q_REQUIRED_RESULT float readFloat(qsizetype offset);
|
||||
Q_REQUIRED_RESULT double readDouble(qsizetype offset);
|
||||
Q_REQUIRED_RESULT QString readString(qsizetype offset,
|
||||
const QString &encoding = {});
|
||||
Q_REQUIRED_RESULT QByteArray readBytes(qsizetype offset, qsizetype count);
|
||||
|
||||
Q_REQUIRED_RESULT qsizetype findNext(qsizetype begin, const QByteArray &ba);
|
||||
Q_REQUIRED_RESULT qsizetype findPrevious(qsizetype begin,
|
||||
const QByteArray &ba);
|
||||
|
||||
Q_REQUIRED_RESULT QString bookMarkComment(qsizetype pos);
|
||||
Q_REQUIRED_RESULT bool existBookMark(qsizetype pos);
|
||||
|
||||
public:
|
||||
// document
|
||||
Q_REQUIRED_RESULT bool switchDocument(int handle);
|
||||
Q_REQUIRED_RESULT bool raiseDocument(int handle);
|
||||
Q_REQUIRED_RESULT bool setLockedFile(bool b);
|
||||
Q_REQUIRED_RESULT bool setKeepSize(bool b);
|
||||
Q_REQUIRED_RESULT bool setStringVisible(bool b);
|
||||
Q_REQUIRED_RESULT bool setAddressVisible(bool b);
|
||||
Q_REQUIRED_RESULT bool setHeaderVisible(bool b);
|
||||
Q_REQUIRED_RESULT bool setAddressBase(quintptr base);
|
||||
|
||||
Q_REQUIRED_RESULT bool beginMarco(const QString &txt = {});
|
||||
bool endMarco();
|
||||
|
||||
Q_REQUIRED_RESULT bool writeInt8(qsizetype offset, qint8 value);
|
||||
Q_REQUIRED_RESULT bool writeInt16(qsizetype offset, qint16 value);
|
||||
Q_REQUIRED_RESULT bool writeInt32(qsizetype offset, qint32 value);
|
||||
Q_REQUIRED_RESULT bool writeInt64(qsizetype offset, qint64 value);
|
||||
Q_REQUIRED_RESULT bool writeUInt8(qsizetype offset, quint8 value);
|
||||
Q_REQUIRED_RESULT bool writeUInt16(qsizetype offset, quint16 value);
|
||||
Q_REQUIRED_RESULT bool writeUInt32(qsizetype offset, quint32 value);
|
||||
Q_REQUIRED_RESULT bool writeUInt64(qsizetype offset, quint64 value);
|
||||
Q_REQUIRED_RESULT bool writeFloat(qsizetype offset, float value);
|
||||
Q_REQUIRED_RESULT bool writeDouble(qsizetype offset, double value);
|
||||
Q_REQUIRED_RESULT bool writeString(qsizetype offset, const QString &value,
|
||||
const QString &encoding = QString());
|
||||
Q_REQUIRED_RESULT bool writeBytes(qsizetype offset, const QByteArray &data);
|
||||
|
||||
Q_REQUIRED_RESULT bool insertInt8(qsizetype offset, qint8 value);
|
||||
Q_REQUIRED_RESULT bool insertInt16(qsizetype offset, qint16 value);
|
||||
Q_REQUIRED_RESULT bool insertInt32(qsizetype offset, qint32 value);
|
||||
Q_REQUIRED_RESULT bool insertInt64(qsizetype offset, qint64 value);
|
||||
Q_REQUIRED_RESULT bool insertUInt8(qsizetype offset, quint8 value);
|
||||
Q_REQUIRED_RESULT bool insertUInt16(qsizetype offset, quint16 value);
|
||||
Q_REQUIRED_RESULT bool insertUInt32(qsizetype offset, quint32 value);
|
||||
Q_REQUIRED_RESULT bool insertUInt64(qsizetype offset, quint64 value);
|
||||
Q_REQUIRED_RESULT bool insertFloat(qsizetype offset, float value);
|
||||
Q_REQUIRED_RESULT bool insertDouble(qsizetype offset, double value);
|
||||
Q_REQUIRED_RESULT bool insertString(qsizetype offset, const QString &value,
|
||||
const QString &encoding = QString());
|
||||
Q_REQUIRED_RESULT bool insertBytes(qsizetype offset,
|
||||
const QByteArray &data);
|
||||
|
||||
Q_REQUIRED_RESULT bool appendInt8(qint8 value);
|
||||
Q_REQUIRED_RESULT bool appendInt16(qint16 value);
|
||||
Q_REQUIRED_RESULT bool appendInt32(qint32 value);
|
||||
Q_REQUIRED_RESULT bool appendInt64(qint64 value);
|
||||
Q_REQUIRED_RESULT bool appendUInt8(quint8 value);
|
||||
Q_REQUIRED_RESULT bool appendUInt16(quint16 value);
|
||||
Q_REQUIRED_RESULT bool appendUInt32(quint32 value);
|
||||
Q_REQUIRED_RESULT bool appendUInt64(quint64 value);
|
||||
Q_REQUIRED_RESULT bool appendFloat(float value);
|
||||
Q_REQUIRED_RESULT bool appendDouble(double value);
|
||||
Q_REQUIRED_RESULT bool appendString(const QString &value,
|
||||
const QString &encoding = QString());
|
||||
Q_REQUIRED_RESULT bool appendBytes(const QByteArray &data);
|
||||
|
||||
Q_REQUIRED_RESULT bool removeBytes(qsizetype offset, qsizetype len);
|
||||
|
||||
// cursor
|
||||
Q_REQUIRED_RESULT bool moveTo(qsizetype line, qsizetype column,
|
||||
int nibbleindex = 1,
|
||||
bool clearSelection = true);
|
||||
Q_REQUIRED_RESULT bool moveTo(qsizetype offset, bool clearSelection = true);
|
||||
Q_REQUIRED_RESULT bool select(qsizetype offset, qsizetype length,
|
||||
SelectionMode mode = SelectionMode::Add);
|
||||
Q_REQUIRED_RESULT bool setInsertionMode(bool isinsert);
|
||||
|
||||
// metadata
|
||||
Q_REQUIRED_RESULT bool foreground(qsizetype begin, qsizetype length,
|
||||
const QColor &fgcolor);
|
||||
Q_REQUIRED_RESULT bool background(qsizetype begin, qsizetype length,
|
||||
const QColor &bgcolor);
|
||||
Q_REQUIRED_RESULT bool comment(qsizetype begin, qsizetype length,
|
||||
const QString &comment);
|
||||
|
||||
Q_REQUIRED_RESULT bool metadata(qsizetype begin, qsizetype length,
|
||||
const QColor &fgcolor,
|
||||
const QColor &bgcolor,
|
||||
const QString &comment);
|
||||
|
||||
Q_REQUIRED_RESULT bool removeMetadata(qsizetype offset);
|
||||
Q_REQUIRED_RESULT bool clearMetadata();
|
||||
Q_REQUIRED_RESULT bool setMetaVisible(bool b);
|
||||
Q_REQUIRED_RESULT bool setMetafgVisible(bool b);
|
||||
Q_REQUIRED_RESULT bool setMetabgVisible(bool b);
|
||||
Q_REQUIRED_RESULT bool setMetaCommentVisible(bool b);
|
||||
|
||||
// mainwindow
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile newFile();
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile openFile(const QString &filename);
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile openExtFile(const QString &ext,
|
||||
const QString &file);
|
||||
|
||||
WingHex::ErrFile closeHandle(int handle);
|
||||
WingHex::ErrFile closeFile(int handle, bool force = false);
|
||||
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile saveFile(int handle);
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile exportFile(int handle,
|
||||
const QString &savename);
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile saveAsFile(int handle,
|
||||
const QString &savename);
|
||||
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile openCurrent();
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile closeCurrent(bool force = false);
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile saveCurrent();
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile exportCurrent(const QString &savename);
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile saveAsCurrent(const QString &savename);
|
||||
|
||||
// bookmark
|
||||
Q_REQUIRED_RESULT bool addBookMark(qsizetype pos, const QString &comment);
|
||||
Q_REQUIRED_RESULT bool modBookMark(qsizetype pos, const QString &comment);
|
||||
Q_REQUIRED_RESULT bool removeBookMark(qsizetype pos);
|
||||
Q_REQUIRED_RESULT bool clearBookMark();
|
||||
|
||||
// workspace
|
||||
Q_REQUIRED_RESULT WingHex::ErrFile openWorkSpace(const QString &filename);
|
||||
|
||||
// extension
|
||||
bool closeAllFiles();
|
||||
|
||||
public:
|
||||
bool dataVisualText(const QString &data, const QString &title = {});
|
||||
bool dataVisualTextList(const QStringList &data, const QString &title = {},
|
||||
WingHex::ClickedCallBack clicked = {},
|
||||
WingHex::ClickedCallBack dblClicked = {});
|
||||
|
||||
Q_REQUIRED_RESULT bool
|
||||
dataVisualTextTree(const QString &json, const QString &title = {},
|
||||
WingHex::ClickedCallBack clicked = {},
|
||||
WingHex::ClickedCallBack dblClicked = {});
|
||||
Q_REQUIRED_RESULT bool
|
||||
dataVisualTextTable(const QString &json, const QStringList &headers,
|
||||
const QStringList &headerNames = {},
|
||||
const QString &title = {},
|
||||
WingHex::ClickedCallBack clicked = {},
|
||||
WingHex::ClickedCallBack dblClicked = {});
|
||||
|
||||
// API for Qt Plugin Only
|
||||
Q_REQUIRED_RESULT bool
|
||||
dataVisualTextListByModel(QAbstractItemModel *model,
|
||||
const QString &title = {},
|
||||
WingHex::ClickedCallBack clicked = {},
|
||||
WingHex::ClickedCallBack dblClicked = {});
|
||||
Q_REQUIRED_RESULT bool
|
||||
dataVisualTextTableByModel(QAbstractItemModel *model,
|
||||
const QString &title = {},
|
||||
WingHex::ClickedCallBack clicked = {},
|
||||
WingHex::ClickedCallBack dblClicked = {});
|
||||
Q_REQUIRED_RESULT bool
|
||||
dataVisualTextTreeByModel(QAbstractItemModel *model,
|
||||
const QString &title = {},
|
||||
WingHex::ClickedCallBack clicked = {},
|
||||
WingHex::ClickedCallBack dblClicked = {});
|
||||
};
|
||||
|
||||
class WINGPLUGIN_EXPORT IWingPluginAPICalls : public IWingPluginCalls,
|
||||
public IWingPluginBaseCalls {
|
||||
public:
|
||||
explicit IWingPluginAPICalls(IWingPlugin *const caller);
|
||||
};
|
||||
|
||||
} // namespace WingHex
|
||||
|
||||
Q_DECLARE_METATYPE(const char *)
|
||||
Q_DECLARE_METATYPE(QGenericArgument)
|
||||
Q_DECLARE_METATYPE(QGenericReturnArgument)
|
||||
Q_DECLARE_METATYPE(QModelIndex)
|
||||
Q_DECLARE_METATYPE(WingHex::ClickedCallBack)
|
||||
Q_DECLARE_METATYPE(WingHex::HexPosition)
|
||||
|
||||
#endif // IWINGPLUGINCALLS_H
|
|
@ -0,0 +1,29 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "settingpage.h"
|
||||
|
||||
using namespace WingHex;
|
||||
|
||||
PageBase::PageBase(QWidget *parent) : QWidget(parent) {}
|
||||
|
||||
SettingPage::SettingPage(QWidget *parent) : PageBase(parent) {}
|
||||
|
||||
PluginPage::PluginPage(QWidget *parent) : PageBase(parent) {}
|
|
@ -0,0 +1,60 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef SETTINGPAGE_H
|
||||
#define SETTINGPAGE_H
|
||||
|
||||
#include "wingplugin_global.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
class WINGPLUGIN_EXPORT PageBase : public QWidget {
|
||||
public:
|
||||
explicit PageBase(QWidget *parent = nullptr);
|
||||
|
||||
public:
|
||||
virtual QIcon categoryIcon() const = 0;
|
||||
virtual QString name() const = 0;
|
||||
virtual QString id() const = 0;
|
||||
};
|
||||
|
||||
class WINGPLUGIN_EXPORT SettingPage : public PageBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SettingPage(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void optionNeedRestartChanged();
|
||||
|
||||
public:
|
||||
virtual void apply() = 0;
|
||||
virtual void reset() = 0;
|
||||
virtual void cancel() = 0;
|
||||
};
|
||||
|
||||
class WINGPLUGIN_EXPORT PluginPage : public PageBase {
|
||||
public:
|
||||
explicit PluginPage(QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
} // namespace WingHex
|
||||
|
||||
#endif // SETTINGPAGE_H
|
|
@ -0,0 +1,72 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef WINGCORE_H
|
||||
#define WINGCORE_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMetaType>
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
constexpr auto CALL_TABLE_PROPERTY = "__CALL_TABLE__";
|
||||
constexpr auto CALL_POINTER_PROPERTY = "__CALL_POINTER__";
|
||||
|
||||
template <class Func>
|
||||
inline QByteArray getFunctionSig(Func &&, const char *fn) {
|
||||
typedef QtPrivate::FunctionPointer<std::decay_t<Func>> FnPointerType;
|
||||
const int *types =
|
||||
QtPrivate::ConnectionTypes<typename FnPointerType::Arguments>::types();
|
||||
if constexpr (FnPointerType::ArgumentCount > 0) {
|
||||
QStringList args;
|
||||
Q_ASSERT(types);
|
||||
for (int i = 0; i < FnPointerType::ArgumentCount; ++i) {
|
||||
QMetaType type(types[i]);
|
||||
if (type.isValid()) {
|
||||
args.append(type.name());
|
||||
}
|
||||
}
|
||||
return QByteArray(fn) + '(' + args.join(',').toLatin1() + ')';
|
||||
} else {
|
||||
return QByteArray(fn) + QByteArray("()");
|
||||
}
|
||||
}
|
||||
|
||||
#define SETUP_CALL_CONTEXT(FN) \
|
||||
static QMutex __mutex__; \
|
||||
static QMetaMethod m; \
|
||||
do { \
|
||||
QMutexLocker locker(&__mutex__); \
|
||||
static auto CALLNAME = getFunctionSig(FN, __func__); \
|
||||
if (!m.isValid()) { \
|
||||
auto fnMap = callTable(); \
|
||||
if (fnMap.contains(CALLNAME)) { \
|
||||
m = fnMap.value(CALLNAME); \
|
||||
Q_ASSERT(m.isValid()); \
|
||||
} else { \
|
||||
qDebug("[InvokeCall] '%s' is not found in call table.", \
|
||||
CALLNAME.constData()); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif // WINGCORE_H
|
|
@ -0,0 +1,53 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "wingeditorviewwidget.h"
|
||||
|
||||
WingHex::WingEditorViewWidget::WingEditorViewWidget(IWingPlugin *plg,
|
||||
QWidget *parent)
|
||||
: WingPluginWidget(plg, parent) {}
|
||||
|
||||
void WingHex::WingEditorViewWidget::raiseView() {
|
||||
constexpr auto VIEW_PROPERTY = "__VIEW__";
|
||||
constexpr auto VIEW_ID_PROPERTY = "__ID__";
|
||||
|
||||
auto rawptr =
|
||||
reinterpret_cast<QObject *>(property(VIEW_PROPERTY).value<quintptr>());
|
||||
auto ptr = qobject_cast<QWidget *>(rawptr);
|
||||
auto id = property(VIEW_ID_PROPERTY).toString();
|
||||
if (ptr && !id.isEmpty()) {
|
||||
QMetaObject::invokeMethod(ptr, "raiseAndSwitchView",
|
||||
Qt::DirectConnection, WINGAPI_ARG(id));
|
||||
}
|
||||
}
|
||||
|
||||
void WingHex::WingEditorViewWidget::loadState(const QByteArray &state) {
|
||||
Q_UNUSED(state);
|
||||
}
|
||||
|
||||
bool WingHex::WingEditorViewWidget::hasUnsavedState() { return false; }
|
||||
|
||||
QByteArray WingHex::WingEditorViewWidget::saveState() { return {}; }
|
||||
|
||||
bool WingHex::WingEditorViewWidget::onClosing() { return true; }
|
||||
|
||||
void WingHex::WingEditorViewWidget::onWorkSpaceNotify(bool isWorkSpace) {
|
||||
Q_UNUSED(isWorkSpace);
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef WINGEDITORVIEWWIDGET_H
|
||||
#define WINGEDITORVIEWWIDGET_H
|
||||
|
||||
#include "WingPlugin/wingpluginwidget.h"
|
||||
#include "iwingplugincalls.h"
|
||||
#include "wingplugin_global.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
class IWingPlugin;
|
||||
|
||||
class WINGPLUGIN_EXPORT WingEditorViewWidget : public WingPluginWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
class Creator {
|
||||
public:
|
||||
Creator() = default;
|
||||
|
||||
public:
|
||||
virtual QIcon icon() const = 0;
|
||||
|
||||
virtual QString name() const = 0;
|
||||
|
||||
virtual QString id() const = 0;
|
||||
|
||||
public:
|
||||
virtual WingEditorViewWidget *create(WingHex::IWingPlugin *plg,
|
||||
QWidget *parent) const = 0;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit WingEditorViewWidget(WingHex::IWingPlugin *plg,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
virtual WingEditorViewWidget *clone() = 0;
|
||||
|
||||
signals:
|
||||
void savedStateChanged(bool b);
|
||||
|
||||
public slots:
|
||||
void raiseView();
|
||||
|
||||
virtual void toggled(bool isVisible) = 0;
|
||||
|
||||
virtual void loadState(const QByteArray &state);
|
||||
|
||||
virtual bool hasUnsavedState();
|
||||
|
||||
virtual QByteArray saveState();
|
||||
|
||||
// return false then stop closing and swith the view
|
||||
// but you cannot prevent closing the cloned view
|
||||
virtual bool onClosing();
|
||||
|
||||
// cloned view will never call it
|
||||
virtual void onWorkSpaceNotify(bool isWorkSpace);
|
||||
};
|
||||
|
||||
} // namespace WingHex
|
||||
|
||||
#endif // WINGEDITORVIEWWIDGET_H
|
|
@ -0,0 +1,130 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef WINGPLUGIN_GLOBAL_H
|
||||
#define WINGPLUGIN_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(WINGPLUGIN_LIBRARY)
|
||||
#define WINGPLUGIN_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define WINGPLUGIN_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaMethod>
|
||||
#include <QString>
|
||||
#include <QVersionNumber>
|
||||
#include <QWidget>
|
||||
|
||||
#ifdef WING_SERVICE
|
||||
#undef WING_SERVICE
|
||||
#endif
|
||||
|
||||
#define WING_SERVICE Q_INVOKABLE
|
||||
|
||||
#define WINGAPI_ARG_SPEC(Type) \
|
||||
inline QArgument<Type> WINGAPI_ARG(const Type &t) { \
|
||||
return QArgument<Type>(QT_STRINGIFY(Type), t); \
|
||||
} \
|
||||
inline QReturnArgument<Type> WINGAPI_RETURN_ARG(Type &t) { \
|
||||
return QReturnArgument<Type>(QT_STRINGIFY(Type), t); \
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline QArgument<T> WINGAPI_ARG(const T &t) {
|
||||
static QByteArray name;
|
||||
if (name.isEmpty()) {
|
||||
auto m = QMetaType::fromType<std::decay_t<T>>();
|
||||
name = m.name();
|
||||
}
|
||||
return QArgument<std::decay_t<T>>(name, t);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline QReturnArgument<T> WINGAPI_RETURN_ARG(T &t) {
|
||||
static QByteArray name;
|
||||
if (name.isEmpty()) {
|
||||
auto m = QMetaType::fromType<std::decay_t<T>>();
|
||||
name = m.name();
|
||||
}
|
||||
return QReturnArgument<std::decay_t<T>>(name, t);
|
||||
}
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
struct WingDockWidgetInfo {
|
||||
QString widgetName;
|
||||
QString displayName;
|
||||
QWidget *widget = nullptr;
|
||||
Qt::DockWidgetArea area = Qt::DockWidgetArea::NoDockWidgetArea;
|
||||
};
|
||||
|
||||
struct WingDependency {
|
||||
QString puid;
|
||||
QVersionNumber version;
|
||||
};
|
||||
|
||||
enum class AppTheme { Dark, Light };
|
||||
|
||||
using CallTable = QHash<QByteArray, QMetaMethod>;
|
||||
|
||||
using ClickedCallBack = std::function<void(const QModelIndex &)>;
|
||||
|
||||
Q_NAMESPACE_EXPORT(WINGPLUGIN_EXPORT)
|
||||
|
||||
enum ErrFile : int {
|
||||
Success = 0,
|
||||
Error = -1,
|
||||
UnSaved = -2,
|
||||
Permission = -3,
|
||||
NotExist = -4,
|
||||
AlreadyOpened = -5,
|
||||
IsNewFile = -6,
|
||||
WorkSpaceUnSaved = -7,
|
||||
ClonedFile = -8,
|
||||
InvalidFormat = -9,
|
||||
TooManyOpenedFile = -10,
|
||||
NotAllowedInNoneGUIThread = -11,
|
||||
DevNotFound = -12,
|
||||
};
|
||||
Q_ENUM_NS(ErrFile)
|
||||
|
||||
enum class SelectionMode : int { Add, Remove, Single };
|
||||
Q_ENUM_NS(SelectionMode)
|
||||
|
||||
} // namespace WingHex
|
||||
|
||||
Q_DECLARE_METATYPE(WingHex::AppTheme)
|
||||
Q_DECLARE_METATYPE(WingHex::CallTable)
|
||||
|
||||
// Template specialization for typedefs
|
||||
WINGAPI_ARG_SPEC(QMessageBox::StandardButtons);
|
||||
WINGAPI_ARG_SPEC(QInputDialog::InputDialogOptions);
|
||||
WINGAPI_ARG_SPEC(QFileDialog::Options);
|
||||
WINGAPI_ARG_SPEC(Qt::InputMethodHints);
|
||||
WINGAPI_ARG_SPEC(qsizetype);
|
||||
|
||||
WINGAPI_ARG_SPEC(WingHex::ClickedCallBack);
|
||||
|
||||
#endif // WINGPLUGIN_GLOBAL_H
|
|
@ -0,0 +1,34 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "wingplugincallconvertor.h"
|
||||
|
||||
#include "WingPlugin/wingplugin_global.h"
|
||||
#include "iwingpluginbase.h"
|
||||
|
||||
WingHex::WingPluginCallConvertor::WingPluginCallConvertor(QObject *caller) {
|
||||
_caller = reinterpret_cast<WingHex::IWingPluginBase *>(caller);
|
||||
Q_ASSERT(_caller);
|
||||
}
|
||||
|
||||
QArgument<WingHex::IWingPluginBase *>
|
||||
WingHex::WingPluginCallConvertor::getSenderObj() {
|
||||
return WINGAPI_ARG(_caller);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef WINGPLUGINCALLCONVERTOR_H
|
||||
#define WINGPLUGINCALLCONVERTOR_H
|
||||
|
||||
#include <QArgument>
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
class IWingPluginBase;
|
||||
|
||||
class WingPluginCallConvertor {
|
||||
public:
|
||||
WingPluginCallConvertor(QObject *caller);
|
||||
|
||||
protected:
|
||||
QArgument<IWingPluginBase *> getSenderObj();
|
||||
|
||||
private:
|
||||
IWingPluginBase *_caller;
|
||||
};
|
||||
} // namespace WingHex
|
||||
|
||||
#endif // WINGPLUGINCALLCONVERTOR_H
|
|
@ -0,0 +1,109 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "wingplugincalls.h"
|
||||
|
||||
#include "wingcore.h"
|
||||
#include "wingplugincalls_p.h"
|
||||
|
||||
#include <QDynamicPropertyChangeEvent>
|
||||
#include <QEvent>
|
||||
|
||||
using namespace WingHex;
|
||||
|
||||
Q_DECLARE_METATYPE(QMetaMethod)
|
||||
|
||||
WingPluginCalls::WingPluginCalls(QObject *coreobj)
|
||||
: WingPluginCallConvertor(coreobj), _core(new WingPluginCallsCore) {
|
||||
Q_ASSERT(coreobj);
|
||||
coreobj->installEventFilter(_core);
|
||||
|
||||
auto var = coreobj->property(CALL_POINTER_PROPERTY);
|
||||
if (var.canConvert<quintptr>()) {
|
||||
_core->d_ptr->_fnCaller =
|
||||
reinterpret_cast<QObject *>(var.value<quintptr>());
|
||||
}
|
||||
|
||||
var = coreobj->property(CALL_TABLE_PROPERTY);
|
||||
if (var.canConvert<QHash<QByteArray, QMetaMethod>>()) {
|
||||
_core->d_ptr->_fnTable = var.value<QHash<QByteArray, QMetaMethod>>();
|
||||
}
|
||||
}
|
||||
|
||||
WingPluginCalls::~WingPluginCalls() { delete _core; }
|
||||
|
||||
WingHex::CallTable WingPluginCalls::callTable() const {
|
||||
if (_core->d_ptr->_fnTable.isEmpty()) {
|
||||
std::abort();
|
||||
}
|
||||
return _core->d_ptr->_fnTable;
|
||||
}
|
||||
|
||||
QObject *WingPluginCalls::callReceiver() const {
|
||||
if (_core->d_ptr->_fnCaller == nullptr) {
|
||||
std::abort();
|
||||
}
|
||||
return _core->d_ptr->_fnCaller;
|
||||
}
|
||||
|
||||
WingPluginCallsCore *WingPluginCalls::core() const { return _core; }
|
||||
|
||||
WingPluginCallsCore::WingPluginCallsCore()
|
||||
: QObject(), d_ptr(new WingPluginCallsCorePrivate) {}
|
||||
|
||||
WingPluginCallsCore::~WingPluginCallsCore() { delete d_ptr; }
|
||||
|
||||
bool WingPluginCallsCore::eventFilter(QObject *watched, QEvent *event) {
|
||||
if (event->type() == QEvent::DynamicPropertyChange) {
|
||||
auto e = static_cast<QDynamicPropertyChangeEvent *>(event);
|
||||
if (e) {
|
||||
auto ppname = e->propertyName();
|
||||
if (ppname == CALL_POINTER_PROPERTY) {
|
||||
Q_D(WingPluginCallsCore);
|
||||
if (d->_fnCaller) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
auto var = watched->property(CALL_POINTER_PROPERTY);
|
||||
if (!var.canConvert<quintptr>()) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
d->_fnCaller =
|
||||
reinterpret_cast<QObject *>(var.value<quintptr>());
|
||||
}
|
||||
|
||||
if (ppname == CALL_TABLE_PROPERTY) {
|
||||
Q_D(WingPluginCallsCore);
|
||||
if (!d->_fnTable.isEmpty()) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
auto var = watched->property(CALL_TABLE_PROPERTY);
|
||||
if (!var.canConvert<QHash<QByteArray, QMetaMethod>>()) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
d->_fnTable = var.value<QHash<QByteArray, QMetaMethod>>();
|
||||
}
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef WINGPLUGINCALLS_H
|
||||
#define WINGPLUGINCALLS_H
|
||||
|
||||
#include <QMetaMethod>
|
||||
#include <QObject>
|
||||
|
||||
#include "wingplugin_global.h"
|
||||
#include "wingplugincallconvertor.h"
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
class WingPluginCallsCorePrivate;
|
||||
|
||||
class WingPluginCallsCore : public QObject {
|
||||
Q_OBJECT
|
||||
friend class WingPluginCalls;
|
||||
|
||||
public:
|
||||
WingPluginCallsCore();
|
||||
virtual ~WingPluginCallsCore();
|
||||
|
||||
// QObject interface
|
||||
public:
|
||||
virtual bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
private:
|
||||
WingPluginCallsCorePrivate *d_ptr;
|
||||
Q_DECLARE_PRIVATE(WingPluginCallsCore)
|
||||
Q_DISABLE_COPY_MOVE(WingPluginCallsCore)
|
||||
};
|
||||
|
||||
class WINGPLUGIN_EXPORT WingPluginCalls : public WingPluginCallConvertor {
|
||||
public:
|
||||
explicit WingPluginCalls(QObject *coreobj);
|
||||
virtual ~WingPluginCalls();
|
||||
|
||||
WingPluginCallsCore *core() const;
|
||||
|
||||
protected:
|
||||
WingHex::CallTable callTable() const;
|
||||
|
||||
QObject *callReceiver() const;
|
||||
|
||||
private:
|
||||
WingPluginCallsCore *_core;
|
||||
Q_DISABLE_COPY_MOVE(WingPluginCalls)
|
||||
};
|
||||
|
||||
} // namespace WingHex
|
||||
|
||||
#endif // WINGPLUGINCALLS_H
|
|
@ -0,0 +1,40 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef WINGPLUGINCALLS_P_H
|
||||
#define WINGPLUGINCALLS_P_H
|
||||
|
||||
#include <QHash>
|
||||
#include <QMetaMethod>
|
||||
#include <QObject>
|
||||
|
||||
#include "wingplugin_global.h"
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
class WingPluginCallsCorePrivate {
|
||||
public:
|
||||
WingHex::CallTable _fnTable;
|
||||
QObject *_fnCaller = nullptr;
|
||||
};
|
||||
|
||||
} // namespace WingHex
|
||||
|
||||
#endif // WINGPLUGINCALLS_P_H
|
|
@ -0,0 +1,46 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "wingpluginwidget.h"
|
||||
|
||||
using namespace WingHex;
|
||||
|
||||
WingPluginWidget::WingPluginWidget(IWingPlugin *plg, QWidget *parent)
|
||||
: QWidget(parent), WingHex::IWingPluginAPICalls(plg) {}
|
||||
|
||||
WingPluginWidget::~WingPluginWidget() {}
|
||||
|
||||
WingPluginDialog::WingPluginDialog(IWingPlugin *plg, QWidget *parent)
|
||||
: QDialog(parent), WingHex::IWingPluginAPICalls(plg) {}
|
||||
|
||||
WingPluginDialog::~WingPluginDialog() {}
|
||||
|
||||
WingPluginWindow::WingPluginWindow(IWingPlugin *plg, QWindow *parent)
|
||||
: QWindow(parent), WingHex::IWingPluginAPICalls(plg) {}
|
||||
|
||||
WingPluginWindow::WingPluginWindow(IWingPlugin *plg, QScreen *parent)
|
||||
: QWindow(parent), WingHex::IWingPluginAPICalls(plg) {}
|
||||
|
||||
WingPluginWindow::~WingPluginWindow() {}
|
||||
|
||||
WingPluginMainWindow::WingPluginMainWindow(IWingPlugin *plg, QWidget *parent)
|
||||
: QMainWindow(parent), WingHex::IWingPluginAPICalls(plg) {}
|
||||
|
||||
WingPluginMainWindow::~WingPluginMainWindow() {}
|
|
@ -0,0 +1,84 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** You can redistribute this file and/or modify it under the terms of the
|
||||
** BSD 3-Clause.
|
||||
**
|
||||
** THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
** POSSIBILITY OF SUCH DAMAGE.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef WINGPLUGINWIDGET_H
|
||||
#define WINGPLUGINWIDGET_H
|
||||
|
||||
#include "WingPlugin/iwingplugincalls.h"
|
||||
#include "wingplugin_global.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMainWindow>
|
||||
#include <QWidget>
|
||||
#include <QWindow>
|
||||
|
||||
namespace WingHex {
|
||||
|
||||
class IWingPlugin;
|
||||
|
||||
class WINGPLUGIN_EXPORT WingPluginWidget
|
||||
: public QWidget,
|
||||
protected WingHex::IWingPluginAPICalls {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WingPluginWidget(WingHex::IWingPlugin *plg,
|
||||
QWidget *parent = nullptr);
|
||||
virtual ~WingPluginWidget();
|
||||
};
|
||||
|
||||
class WINGPLUGIN_EXPORT WingPluginDialog
|
||||
: public QDialog,
|
||||
protected WingHex::IWingPluginAPICalls {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WingPluginDialog(WingHex::IWingPlugin *plg,
|
||||
QWidget *parent = nullptr);
|
||||
virtual ~WingPluginDialog();
|
||||
};
|
||||
|
||||
class WINGPLUGIN_EXPORT WingPluginWindow
|
||||
: public QWindow,
|
||||
protected WingHex::IWingPluginAPICalls {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WingPluginWindow(WingHex::IWingPlugin *plg,
|
||||
QWindow *parent = nullptr);
|
||||
explicit WingPluginWindow(WingHex::IWingPlugin *plg,
|
||||
QScreen *parent = nullptr);
|
||||
virtual ~WingPluginWindow();
|
||||
};
|
||||
|
||||
class WINGPLUGIN_EXPORT WingPluginMainWindow
|
||||
: public QMainWindow,
|
||||
protected WingHex::IWingPluginAPICalls {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WingPluginMainWindow(WingHex::IWingPlugin *plg,
|
||||
QWidget *parent = nullptr);
|
||||
virtual ~WingPluginMainWindow();
|
||||
};
|
||||
|
||||
} // namespace WingHex
|
||||
|
||||
#endif // WINGPLUGINWIDGET_H
|
After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 6.7 KiB |
|
@ -187,6 +187,8 @@ Homepage: https://www.cnblogs.com/wingsummer/
|
|||
os.mkdir(os.path.join(exeBasePath, "aslib"))
|
||||
|
||||
shutil.copy2(exemain_src, os.path.join(exeBasePath, package_name))
|
||||
shutil.copy2(os.path.join(projectdeb, "WingPlugin", "libWingPlugin.so"),
|
||||
os.path.join(exeBasePath, "libWingPlugin.so"))
|
||||
|
||||
desktopPath = os.path.join(exeDebPath, "usr", "share", "applications")
|
||||
os.makedirs(desktopPath)
|
||||
|
|
|
@ -13,6 +13,7 @@ import platform
|
|||
|
||||
from colorama import Fore, Style
|
||||
|
||||
|
||||
def run_command_interactive(command):
|
||||
"""
|
||||
Run a command interactively, printing its stdout in real-time.
|
||||
|
@ -21,8 +22,8 @@ def run_command_interactive(command):
|
|||
:return: The return code of the command
|
||||
"""
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT, # Capture both stdout and stderr
|
||||
text=True # Ensure the output is in text mode
|
||||
)
|
||||
|
@ -32,15 +33,16 @@ def run_command_interactive(command):
|
|||
if output == "" and process.poll() is not None:
|
||||
break
|
||||
if output:
|
||||
print(Fore.GREEN + output.strip() + Style.RESET_ALL)
|
||||
print(Fore.GREEN + output.strip() + Style.RESET_ALL)
|
||||
|
||||
return_code = process.wait()
|
||||
return return_code
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="mkdeb.py", description="A deb installer maker for WingHexExplorer2")
|
||||
|
||||
|
||||
parser.add_argument(
|
||||
"folder", help="A folder that has contained the binary build", type=str
|
||||
)
|
||||
|
@ -57,7 +59,7 @@ def main():
|
|||
"--no-build", dest="build", action="store_false", help="Skip building the installer"
|
||||
)
|
||||
parser.set_defaults(build=True)
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# checking build toolkits
|
||||
|
@ -81,15 +83,15 @@ def main():
|
|||
print(
|
||||
Fore.RED + "[Error] This is not a CMake build directory!" + Style.RESET_ALL)
|
||||
exit(-1)
|
||||
|
||||
|
||||
deploy_exec = ""
|
||||
|
||||
|
||||
with open(cmake_cache, 'r') as cmake_config:
|
||||
while(True):
|
||||
while (True):
|
||||
line = cmake_config.readline()
|
||||
if not line:
|
||||
break
|
||||
if(line.startswith("WINDEPLOYQT_EXECUTABLE:FILEPATH")):
|
||||
if (line.startswith("WINDEPLOYQT_EXECUTABLE:FILEPATH")):
|
||||
set = line.split('=', 1)
|
||||
deploy_exec = set[1].strip('\n')
|
||||
pass
|
||||
|
@ -124,20 +126,24 @@ def main():
|
|||
|
||||
# check
|
||||
exemain_src = ""
|
||||
exesym_src = ""
|
||||
|
||||
if(os.path.exists(os.path.join(projectdeb, "WingHexExplorer2.sln"))):
|
||||
exemain_src = os.path.join(projectdeb, "RelWithDebInfo", exe_name)
|
||||
exesym_src = ""
|
||||
exeplg_src = ""
|
||||
|
||||
if (os.path.exists(os.path.join(projectdeb, "WingHexExplorer2.sln"))):
|
||||
exemain_src = os.path.join(projectdeb, "RelWithDebInfo", exe_name)
|
||||
exesym_src = os.path.join(projectdeb, "RelWithDebInfo", sym_name)
|
||||
exeplg_src = os.path.join(
|
||||
projectdeb, "WingPlugin", "RelWithDebInfo", "WingPlugin.dll")
|
||||
else:
|
||||
exemain_src = os.path.join(projectdeb, exe_name)
|
||||
exesym_src = os.path.join(projectdeb, sym_name)
|
||||
|
||||
exeplg_src = os.path.join(projectdeb, "WingPlugin", "WingPlugin.dll")
|
||||
|
||||
if (os.path.exists(exemain_src) == False):
|
||||
print(
|
||||
Fore.RED + "[Error] WingHexExplorer2.exe is not found!" + Style.RESET_ALL)
|
||||
exit(-3)
|
||||
|
||||
|
||||
# calculate the md5 checksum
|
||||
with open(exemain_src, 'rb') as file_to_check:
|
||||
data = file_to_check.read()
|
||||
|
@ -155,6 +161,8 @@ def main():
|
|||
|
||||
shutil.copy2(exemain_src, os.path.join(exeDebPath, exe_name))
|
||||
shutil.copy2(exesym_src, os.path.join(exeDebPath, sym_name))
|
||||
shutil.copy2(exeplg_src,
|
||||
os.path.join(exeDebPath, "WingPlugin.dll"))
|
||||
|
||||
shutil.copytree(os.path.join(buildinstaller, "share"),
|
||||
os.path.join(exeDebPath, "share"))
|
||||
|
@ -173,23 +181,24 @@ def main():
|
|||
|
||||
shutil.copyfile(os.path.join(projectbase, "images", "author.jpg"),
|
||||
os.path.join(exeDebPath, "author.jpg"))
|
||||
|
||||
# deploy the software
|
||||
|
||||
# deploy the software
|
||||
|
||||
print(Fore.GREEN + ">> Copying finished, deploying the software..." + Style.RESET_ALL)
|
||||
|
||||
try:
|
||||
subprocess.run([deploy_exec, os.path.join(exeDebPath, exe_name) ], check=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
subprocess.run([deploy_exec, os.path.join(exeDebPath, exe_name)], check=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(Fore.RED + f"[Error] deploy package error: \n{e.stderr.decode('utf-8')}" + Style.RESET_ALL)
|
||||
print(
|
||||
Fore.RED + f"[Error] deploy package error: \n{e.stderr.decode('utf-8')}" + Style.RESET_ALL)
|
||||
exit(-4)
|
||||
except FileNotFoundError:
|
||||
exit(-4)
|
||||
exit(-4)
|
||||
|
||||
# generate iss file
|
||||
print(Fore.GREEN + ">> Copying finished, generate ISCC script..." + Style.RESET_ALL)
|
||||
|
||||
|
||||
iss_content = fr"""
|
||||
; Script generated by the mkinnopak.py by wingsummer.
|
||||
|
||||
|
@ -243,8 +252,10 @@ Source: {#MyAppExePath}; DestDir: "{app}"; Flags: ignoreversion
|
|||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
"""
|
||||
iss_content += fr'Source: "{exeDebPath}\*"; ' + r'DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: "*.iss,{#MyOutputBaseFilename}.exe,README.md"' + '\n'
|
||||
iss_content += fr'Source: "{exeDebPath}\README.md"; ' + r'DestDir: "{app}"; Flags: isreadme'
|
||||
iss_content += fr'Source: "{exeDebPath}\*"; ' + \
|
||||
r'DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: "*.iss,{#MyOutputBaseFilename}.exe,README.md"' + '\n'
|
||||
iss_content += fr'Source: "{exeDebPath}\README.md"; ' + \
|
||||
r'DestDir: "{app}"; Flags: isreadme'
|
||||
|
||||
iss_content += """
|
||||
[Registry]
|
||||
|
@ -271,21 +282,21 @@ Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChang
|
|||
"""
|
||||
|
||||
script_src = os.path.join(exeDebPath, "mkiss.iss")
|
||||
with codecs.open(script_src,'w', "utf-8-sig") as iss:
|
||||
with codecs.open(script_src, 'w', "utf-8-sig") as iss:
|
||||
iss.write(iss_content)
|
||||
|
||||
if args.build == False:
|
||||
exit(0)
|
||||
|
||||
|
||||
print(Fore.GREEN + ">> Copying finished, running ISCC building..." + Style.RESET_ALL)
|
||||
|
||||
|
||||
pak_out = ""
|
||||
if args.output is None:
|
||||
pak_out = os.path.join(exeDebPath,"..")
|
||||
pak_out = os.path.join(exeDebPath, "..")
|
||||
else:
|
||||
pak_out = args.output
|
||||
|
||||
ret = run_command_interactive([args.cc, f'/O{pak_out}', script_src])
|
||||
|
||||
ret = run_command_interactive([args.cc, f'/O{pak_out}', script_src])
|
||||
exit(ret)
|
||||
|
||||
|
||||
|
|
|
@ -161,6 +161,9 @@ def main():
|
|||
for item in deploy_files:
|
||||
shutil.copy2(os.path.join(installer_path, item),
|
||||
os.path.join(installer_path_exec, item))
|
||||
|
||||
shutil.copy2(os.path.join(build_path, "WingPlugin", "libWingPlugin.so"),
|
||||
os.path.join(installer_path_exec, "lib" , "libWingPlugin.so"))
|
||||
|
||||
# finally, copy other files
|
||||
print(Fore.GREEN + ">> Copying License and other materials..." + Style.RESET_ALL)
|
||||
|
|
|
@ -117,6 +117,8 @@ def update(build_path):
|
|||
print(Fore.GREEN + ">> Installing..." + Style.RESET_ALL)
|
||||
|
||||
shutil.copy2(exemain_src, os.path.join(INSTALL_PATH, PACKAGE_NAME))
|
||||
shutil.copy2(os.path.join(build_path, "WingPlugin", "libWingPlugin.so"),
|
||||
os.path.join(INSTALL_PATH, "libWingPlugin.so"))
|
||||
|
||||
create_dir(os.path.join(INSTALL_PATH, "plugin"))
|
||||
create_dir(os.path.join(INSTALL_PATH, "scripts"))
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
# Qt-Template
|
||||
|
||||
  该目录是模板目录,用于存放与插件开发的相关模板,极大的提高开发 WingHexExploer2 的插件便利性。
|
||||
|
||||
  目前该目录下只有一个`winghexplugin`,这个存放着 QT 认可的项目模板向导相关文件。而`qt-template-installer.py`是安装管理器,用于方便模板的卸载和安装,你可以使用以下方式进行安装/卸载:
|
||||
|
||||
```bash
|
||||
python3 qt-template-installer.py install # 安装模板
|
||||
python3 qt-template-installer.py uninstall # 卸载模板
|
||||
```
|
||||
|
||||
  当然,你可以手动进行安装,只需把`winghexplugin`拷贝到对应的模板存放目录,具体请看 [官方文档](https://docs.huihoo.com/qt/qtcreator/4.2/creator-project-wizards.html#locating-wizards) 。
|
||||
|
||||
  安装完毕之后,你在新建项目的 Library 分类下将会看到你已经安装好的模板:
|
||||
|
||||

|
||||
|
||||
  它和创建`Qt Creator Plugin`的逻辑比较相像,但有不同之处,就是需要指定插件版本和开发库目录以及主程序目录:
|
||||
|
||||

|
||||
|
||||
  `SDK Paths`填写开发头文件放置的位置,`WingHexExplorer2 Installation`填写安装该十六进制编辑器的安装目录,这里启动程序 **请不要填写安装器给你安装的目录位置,因为启动测试模式会把编译的测试 Dll 拷贝到插件目录,如果没有管理员权限会导致拷贝失败。** 这个软件可以认为是绿色软件的性质,只是建立了文件关联和在个人电脑保存了配置。完全可以把安装目录单独拷贝到一个不需要管理员权限的位置然后继续。
|
||||
|
||||

|
||||
|
||||
  在选择构建套件时候一定要注意你开发插件的套件的 QT 版本一定要和`WingHexExplorer2`保持一致,不然开发编译之后的插件会因为 Qt 版本检查不通过导致插件无法加载。详细的 QT 版本细节可以到 **软件设置** 的 **基本** 下查看,如下图所示:
|
||||
|
||||

|
||||
|
||||
  最后祝你开发插件愉快!
|
Before Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 78 KiB |
|
@ -1,61 +0,0 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
# @Time : 2024/12/27
|
||||
# @Author : 寂静的羽夏(wingsummer)
|
||||
# @FileName: qt-template-installer.py
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
import pathlib
|
||||
from colorama import Fore, Style
|
||||
|
||||
def install():
|
||||
installer_path = os.path.dirname(os.path.abspath(__file__))
|
||||
install_path = os.path.join(getQtTemplateDir(), "winghexplugin")
|
||||
shutil.rmtree(install_path, ignore_errors=True) # uninstall first
|
||||
shutil.copytree(os.path.join(installer_path, "winghexplugin"),
|
||||
install_path, dirs_exist_ok=True)
|
||||
print(Fore.GREEN + "WingHexExplorer2 plugin Template was installed under: " + install_path + Style.RESET_ALL)
|
||||
|
||||
def uninstall():
|
||||
install_path = os.path.join(getQtTemplateDir(), "winghexplugin")
|
||||
shutil.rmtree(install_path)
|
||||
print(Fore.RED + "WingHexExplorer2 plugin Template was removed: " + install_path + Style.RESET_ALL)
|
||||
|
||||
|
||||
def getQtTemplateDir() -> pathlib.Path:
|
||||
# https://docs.huihoo.com/qt/qtcreator/4.2/creator-project-wizards.html#locating-wizards
|
||||
home = pathlib.Path.home()
|
||||
if sys.platform == "win32":
|
||||
return home / "AppData/Roaming/QtProject/qtcreator/templates/wizards"
|
||||
else:
|
||||
return home / ".config/QtProject/qtcreator/templates/wizards"
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="qt-template-installer.py", description=f"A WingHexExplorer2 Plugin tempalte installer for QT.")
|
||||
parser.add_argument(
|
||||
"action",
|
||||
choices=["install", "uninstall"],
|
||||
nargs="?",
|
||||
help="Action to perform: install or uninstall."
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# checking build toolkits
|
||||
if args.action == "install":
|
||||
install()
|
||||
elif args.action == "uninstall":
|
||||
uninstall()
|
||||
|
||||
exit(0)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
else:
|
||||
print(
|
||||
Fore.RED + "[Error] Please run this script in main mode" + Style.RESET_ALL)
|
|
@ -1 +0,0 @@
|
|||
colorama==0.4.6
|
Before Width: | Height: | Size: 174 KiB |
|
@ -1,150 +0,0 @@
|
|||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: false
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveBitFields: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: Latest
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
...
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
# -----------------------------
|
||||
# Options effecting formatting.
|
||||
# -----------------------------
|
||||
with section("format"):
|
||||
|
||||
# How wide to allow formatted cmake files
|
||||
line_width = 80
|
||||
|
||||
# How many spaces to tab for indent
|
||||
tab_size = 4
|
||||
|
||||
# If true, separate flow control names from their parentheses with a space
|
||||
separate_ctrl_name_with_space = False
|
||||
|
||||
# If true, separate function names from parentheses with a space
|
||||
separate_fn_name_with_space = False
|
||||
|
||||
# If a statement is wrapped to more than one line, than dangle the closing
|
||||
# parenthesis on its own line.
|
||||
dangle_parens = False
|
|
@ -1,123 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(%{ProjectName} LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
||||
|
||||
if(MSVC)
|
||||
string(APPEND CMAKE_CXX_FLAGS " /utf-8")
|
||||
string(APPEND CMAKE_C_FLAGS " /utf-8")
|
||||
endif()
|
||||
|
||||
option(TEST_MODE TRUE)
|
||||
|
||||
if(NOT EXISTS "${WINGHEX_SDK}")
|
||||
message(FATAL_ERROR "Please config the SDK Path - WINGHEX_SDK")
|
||||
endif()
|
||||
|
||||
set(PLUGIN_INTERFACE_BASE_FOUND FALSE)
|
||||
set(PLUGIN_INTERFACE_FOUND FALSE)
|
||||
set(PLUGIN_SETPAGE_FOUND FALSE)
|
||||
if(EXISTS "${WINGHEX_SDK}/iwingpluginbase.h")
|
||||
set(PLUGIN_INTERFACE_BASE_FOUND TRUE)
|
||||
endif()
|
||||
if(EXISTS "${WINGHEX_SDK}/iwingplugin.h")
|
||||
set(PLUGIN_INTERFACE_FOUND TRUE)
|
||||
endif()
|
||||
if(EXISTS "${WINGHEX_SDK}/settingpage.h")
|
||||
set(PLUGIN_SETPAGE_FOUND TRUE)
|
||||
endif()
|
||||
if(PLUGIN_INTERFACE_FOUND
|
||||
AND PLUGIN_INTERFACE_BASE_FOUND
|
||||
AND PLUGIN_SETPAGE_FOUND)
|
||||
message(STATUS "${WINGHEX_SDK} is valid SDK path")
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid SDK path!")
|
||||
endif()
|
||||
|
||||
set(WINGHEX_SDK_HEADER
|
||||
"${WINGHEX_SDK}/iwingplugin.h" "${WINGHEX_SDK}/iwingpluginbase.h"
|
||||
"${WINGHEX_SDK}/settingpage.h")
|
||||
include_directories(${WINGHEX_SDK})
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)
|
||||
|
||||
@if %{HasTranslation}
|
||||
set(TS_FILES %{TsFileName})
|
||||
|
||||
set(TRANSLATION_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(${QT_VERSION_MAJOR} EQUAL 5)
|
||||
qt5_create_translation(QM_FILES ${TRANSLATION_PATH} ${TS_FILES})
|
||||
elseif(${QT_VERSION_MAJOR} EQUAL 6)
|
||||
qt6_create_translation(QM_FILES ${TRANSLATION_PATH} ${TS_FILES})
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported QT version")
|
||||
endif()
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/TranslationUtils.cmake)
|
||||
add_plugin_translations_resource(QM_RES %{ProjectName} ${QM_FILES})
|
||||
@else
|
||||
## Example for WingHexExplorer2 Plugin Localization
|
||||
|
||||
# set(TS_FILES )
|
||||
|
||||
# set(TRANSLATION_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# if(${QT_VERSION_MAJOR} EQUAL 5)
|
||||
# qt5_create_translation(QM_FILES ${TRANSLATION_PATH} ${TS_FILES})
|
||||
# elseif(${QT_VERSION_MAJOR} EQUAL 6)
|
||||
# qt6_create_translation(QM_FILES ${TRANSLATION_PATH} ${TS_FILES})
|
||||
# else()
|
||||
# message(FATAL_ERROR "Unsupported QT version")
|
||||
# endif()
|
||||
|
||||
# include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/TranslationUtils.cmake)
|
||||
# add_plugin_translations_resource(QM_RES %{ProjectName} ${QM_FILES})
|
||||
@endif
|
||||
|
||||
add_library(%{ProjectName} SHARED
|
||||
${WINGHEX_SDK_HEADER}
|
||||
@if %{HasTranslation}
|
||||
${QM_FILES}
|
||||
${QM_RES}
|
||||
@else
|
||||
# ${QM_FILES}
|
||||
# ${QM_RES}
|
||||
@endif
|
||||
%{SrcFileName}
|
||||
%{HdrFileName}
|
||||
%{PluginJsonFile}
|
||||
)
|
||||
|
||||
set_target_properties(%{ProjectName} PROPERTIES SUFFIX ".wingplg")
|
||||
|
||||
if(TEST_MODE)
|
||||
# If you want to be able to debug easily every time you compile, please set
|
||||
# this variable. Because this test plugin is a subproject of the main
|
||||
# project, use CMAKE_BINARY_DIR
|
||||
|
||||
if(NOT EXISTS "${WINGHEX_PATH}")
|
||||
message(
|
||||
FATAL_ERROR "Please config the WingHexExplorer2 Path - WINGHEX_PATH"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(WINGHEX_PLUGIN_PATH "${WINGHEX_PATH}/plugin")
|
||||
add_custom_command(
|
||||
TARGET %{ProjectName}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${WINGHEX_PLUGIN_PATH}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:%{ProjectName}>
|
||||
${WINGHEX_PLUGIN_PATH})
|
||||
endif()
|
||||
|
||||
target_link_libraries(%{ProjectName} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
\"Id\" : \"%{JS: value('PluginName').toLowerCase()}\",
|
||||
\"Name\" : \"%{PluginName}\",
|
||||
\"Version\" : \"0.0.1\",
|
||||
\"Vendor\" : \"%{VendorName}\",
|
||||
\"Dependencies\": [
|
||||
|
||||
],
|
||||
\"Author\" : \"%{Author}\",
|
||||
\"License\" : \"%{License}\",
|
||||
\"Url\" : \"%{Url}\"
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
# ==============================================================================
|
||||
# Copyright (C) 2024-2027 WingSummer
|
||||
#
|
||||
# You can redistribute this file and/or modify it under the terms of the BSD
|
||||
# 3-Clause.
|
||||
#
|
||||
# THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
# =============================================================================
|
||||
|
||||
if(NOT TARGET Qt${QT_VERSION_MAJOR}::lconvert)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"The package \\"Qt${QT_VERSION_MAJOR}LinguistTools\\" is required.")
|
||||
endif()
|
||||
|
||||
set(Qt_LCONVERT_EXECUTABLE Qt${QT_VERSION_MAJOR}::lconvert)
|
||||
|
||||
function(ADD_PLUGIN_TRANSLATIONS_RESOURCE res_file target)
|
||||
set(_qm_files ${ARGN})
|
||||
set(_res_file ${CMAKE_CURRENT_BINARY_DIR}/app_translations.qrc)
|
||||
|
||||
file(
|
||||
WRITE ${_res_file}
|
||||
"<!DOCTYPE RCC><RCC version=\\"1.0\\">\\n <qresource prefix=\\"/PLGLANG/${target}\\">\\n"
|
||||
)
|
||||
foreach(_lang ${_qm_files})
|
||||
get_filename_component(_filename ${_lang} NAME)
|
||||
file(APPEND ${_res_file} " <file>${_filename}</file>\\n")
|
||||
endforeach()
|
||||
file(APPEND ${_res_file} " </qresource>\\n</RCC>\\n")
|
||||
|
||||
set(${res_file}
|
||||
${_res_file}
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
add_custom_target(
|
||||
lupdate
|
||||
COMMAND ${Qt${QT_VERSION_MAJOR}_LUPDATE_EXECUTABLE} -recursive
|
||||
${PROJECT_SOURCE_DIR} -ts *.ts
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Updating translations")
|
|
@ -1,80 +0,0 @@
|
|||
# This file is used to ignore files which are generated
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
*~
|
||||
*.autosave
|
||||
*.a
|
||||
*.moc
|
||||
*.o
|
||||
*.obj
|
||||
*.orig
|
||||
*.rej
|
||||
*.so
|
||||
*.so.*
|
||||
*_pch.h.cpp
|
||||
*_resource.rc
|
||||
*.qm
|
||||
.#*
|
||||
*.*#
|
||||
tags
|
||||
.DS_Store
|
||||
.directory
|
||||
*.debug
|
||||
Makefile*
|
||||
*.prl
|
||||
*.app
|
||||
moc_*.cpp
|
||||
ui_*.h
|
||||
qrc_*.cpp
|
||||
Thumbs.db
|
||||
*.res
|
||||
*.rc
|
||||
*.deb
|
||||
*.rpm
|
||||
RC*
|
||||
!app.rc
|
||||
!favicon.rc
|
||||
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
|
||||
# qtcreator generated files
|
||||
build/
|
||||
*.pro.user*
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
|
||||
# Vim temporary files
|
||||
.*.swp
|
||||
|
||||
# Visual Studio generated files
|
||||
*.ib_pdb_index
|
||||
*.idb
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.sln
|
||||
*.suo
|
||||
*.vcproj
|
||||
*vcproj.*.*.user
|
||||
*.ncb
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.vcxproj
|
||||
*vcxproj.*
|
||||
|
||||
# MinGW generated files
|
||||
*.Debug
|
||||
*.Release
|
||||
|
||||
# Python byte code
|
||||
*.pyc
|
||||
|
||||
# Binaries
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
||||
|
||||
#VSCode
|
||||
.vscode/
|
|
@ -1,26 +0,0 @@
|
|||
%{Cpp:LicenseTemplate}\
|
||||
#include "%{JS: Util.relativeFilePath('%{Path}/%{HdrFileName}', '%{Path}' + '/' + Util.path('%{SrcFileName}'))}"
|
||||
|
||||
%{CN}::%{CN}() : WingHex::IWingPlugin(){
|
||||
}
|
||||
|
||||
%{CN}::~%{CN}() {}
|
||||
|
||||
int %{CN}::sdkVersion() const { return WingHex::SDKVERSION; }
|
||||
|
||||
const QString %{CN}::signature() const { return WingHex::WINGSUMMER; }
|
||||
|
||||
bool %{CN}::init(const std::unique_ptr<QSettings> &set) {
|
||||
// Your codes there
|
||||
return true;
|
||||
}
|
||||
|
||||
void %{CN}::unload(std::unique_ptr<QSettings> &set) {
|
||||
// Your unloading codes here
|
||||
}
|
||||
|
||||
const QString %{CN}::pluginName() const { return tr("%{CN}"); }
|
||||
|
||||
const QString %{CN}::pluginComment() const {
|
||||
return tr("%{Description}%");
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
%{Cpp:LicenseTemplate}\
|
||||
@if '%{Cpp:PragmaOnce}'
|
||||
#pragma once
|
||||
@else
|
||||
#ifndef %{GUARD}
|
||||
#define %{GUARD}
|
||||
@endif
|
||||
|
||||
#include "iwingplugin.h"
|
||||
|
||||
class %{CN} final : public WingHex::IWingPlugin {
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "com.wingsummer.iwingplugin" FILE "%{PluginJsonFile}")
|
||||
Q_INTERFACES(WingHex::IWingPlugin)
|
||||
|
||||
public:
|
||||
explicit %{CN}();
|
||||
virtual ~%{CN}();
|
||||
|
||||
// If you are writing codes with QtCreator,
|
||||
// you can press Alt+Enter in a empty line or line with spaces only to
|
||||
// trigger "Insert Virtual Functions of Base Classes" to select optional
|
||||
// virtual functions you want to implement.
|
||||
|
||||
public:
|
||||
virtual int sdkVersion() const override;
|
||||
virtual const QString signature() const override;
|
||||
virtual bool init(const std::unique_ptr<QSettings> &set) override;
|
||||
virtual void unload(std::unique_ptr<QSettings> &set) override;
|
||||
virtual const QString pluginName() const override;
|
||||
virtual const QString pluginComment() const override;
|
||||
|
||||
private:
|
||||
// Your private members
|
||||
};
|
||||
|
||||
@if ! '%{Cpp:PragmaOnce}'
|
||||
#endif // %{GUARD}
|
||||
@endif
|
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 6.8 KiB |
|
@ -1,171 +0,0 @@
|
|||
{
|
||||
"version": 1,
|
||||
"supportedProjectTypes": [ "CMakeProjectManager.CMakeProject" ],
|
||||
"id": "H.WingHex2Plugin",
|
||||
"category": "G.Library",
|
||||
"trDescription": "Creates a plugin for WingHexExplorer2.",
|
||||
"trDisplayName": "WingHexExplorer2 Plugin",
|
||||
"trDisplayCategory": "Library",
|
||||
"icon": "winghexplugin.png",
|
||||
"iconKind": "Themed",
|
||||
"enabled": "%{JS: value('Plugins').indexOf('CppEditor') >= 0 && value('Plugins').indexOf('CMakeProjectManager') >= 0 }",
|
||||
|
||||
"options":
|
||||
[
|
||||
{ "key": "ProjectFile", "value": "%{JS: value('CMakeFile') }" },
|
||||
{ "key": "PluginNameLower", "value": "%{JS: value('PluginName').toLowerCase()}"},
|
||||
{ "key": "PluginJsonFile", "value": "%{JS: Util.fileName(value('PluginName'), 'json.in')}" },
|
||||
{ "key": "CMakeFile", "value": "%{ProjectDirectory}/CMakeLists.txt" },
|
||||
{ "key": "PluginJsonFile", "value": "%{JS: Util.fileName(value('ProjectName'), 'json')}" },
|
||||
{ "key": "SrcFileName", "value": "%{JS: Util.fileName(value('PluginNameLower'), Util.preferredSuffix('text/x-c++src'))}" },
|
||||
{ "key": "HdrFileName", "value": "%{JS: Util.fileName(value('PluginNameLower'), Util.preferredSuffix('text/x-c++hdr'))}" },
|
||||
{ "key": "BaseClassName", "value": "%{JS: value('BaseClassInfo').BaseClassName }" },
|
||||
{ "key": "CN", "value": "%{JS: Cpp.className(value('PluginName'))}" },
|
||||
{ "key": "GUARD", "value": "%{JS: Cpp.headerGuard(value('HdrFileName'))}" },
|
||||
{ "key": "HasTranslation", "value": "%{JS: value('TsFileName') !== ''}" }
|
||||
],
|
||||
|
||||
"pages":
|
||||
[
|
||||
{
|
||||
"trDisplayName": "Project Location",
|
||||
"trShortTitle": "Location",
|
||||
"typeId": "Project",
|
||||
"data": { "trDescription": "This wizard creates a plugin for WingHexExplorer2." }
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Define Project Details",
|
||||
"trShortTitle": "Details",
|
||||
"typeId": "Fields",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"name": "ClassPageDescription",
|
||||
"type": "Label",
|
||||
"data":
|
||||
{
|
||||
"trText": "Specify details about your WingHexExplorer2 plugin.",
|
||||
"wordWrap": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "PluginName",
|
||||
"trDisplayName": "Plugin name:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"validator": "[a-zA-Z_][a-zA-Z_0-9]*",
|
||||
"text": "%{JS: value('ProjectName').charAt(0).toUpperCase() + value('ProjectName').slice(1)}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "VendorName",
|
||||
"persistenceKey": "VendorName",
|
||||
"trDisplayName": "Vendor name:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"trText": "MyCompany"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Author",
|
||||
"trDisplayName": "Author:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"trText": "MyName"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "License",
|
||||
"trDisplayName": "License:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"trText": "Put short license information here"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Url",
|
||||
"persistenceKey": "VendorUrl",
|
||||
"trDisplayName": "URL:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"text": "https://www.%{JS: encodeURIComponent(value('VendorName').toLowerCase())}.com"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Translation File",
|
||||
"trShortTitle": "Translation",
|
||||
"data": { "enabled": "yes" },
|
||||
"typeId": "QtTranslation"
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Kit Selection",
|
||||
"trShortTitle": "Kits",
|
||||
"typeId": "Kits",
|
||||
"data": { "projectFilePath": "%{ProjectFile}" }
|
||||
},
|
||||
|
||||
{
|
||||
"trDisplayName": "Project Management",
|
||||
"trShortTitle": "Summary",
|
||||
"typeId": "Summary"
|
||||
}
|
||||
],
|
||||
"generators":
|
||||
[
|
||||
{
|
||||
"typeId": "File",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"source": "CMakeLists.txt",
|
||||
"openAsProject": true
|
||||
},
|
||||
{
|
||||
"source": "lib.cpp",
|
||||
"target": "%{SrcFileName}",
|
||||
"openInEditor": true
|
||||
},
|
||||
{
|
||||
"source": "lib.h",
|
||||
"target": "%{HdrFileName}"
|
||||
},
|
||||
{
|
||||
"source": "cmake/TranslationUtils.cmake",
|
||||
"target": "cmake/TranslationUtils.cmake"
|
||||
},
|
||||
{
|
||||
"source": "cmake/LICENSE.txt",
|
||||
"target": "cmake/LICENSE.txt"
|
||||
},
|
||||
{
|
||||
"source": "MyPlugin.json.in",
|
||||
"target": "%{PluginJsonFile}"
|
||||
},
|
||||
{
|
||||
"source": "git.ignore",
|
||||
"target": ".gitignore"
|
||||
},
|
||||
{
|
||||
"source": ".clang-format",
|
||||
"target": ".clang-format"
|
||||
},
|
||||
{
|
||||
"source": ".cmake-format.py",
|
||||
"target": ".cmake-format.py"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -69,6 +69,7 @@
|
|||
<file>images/plugin.png</file>
|
||||
<file>images/pro.png</file>
|
||||
<file>images/qt.png</file>
|
||||
<file>images/qtloginspect.png</file>
|
||||
<file>images/readonly.png</file>
|
||||
<file>images/recent.png</file>
|
||||
<file>images/redo.png</file>
|
||||
|
@ -107,7 +108,6 @@
|
|||
<file>images/unover.png</file>
|
||||
<file>images/unsaved.png</file>
|
||||
<file>images/update.png</file>
|
||||
<file>images/viewtxt.png</file>
|
||||
<file>images/wiki.png</file>
|
||||
<file>images/win.png</file>
|
||||
<file>images/workspace.png</file>
|
||||
|
|
BIN
screenshot.png
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.5 MiB |
|
@ -27,13 +27,11 @@
|
|||
#define QPTR_WRAP(decl) "uint " decl
|
||||
#define QPTR "uint"
|
||||
#define QSIZETYPE "int"
|
||||
#define QUSIZETYPE "uint"
|
||||
#elif Q_PROCESSOR_WORDSIZE == 8
|
||||
#define QSIZETYPE_WRAP(decl) "int64 " decl
|
||||
#define QPTR_WRAP(decl) "uint64 " decl
|
||||
#define QPTR "uint64"
|
||||
#define QSIZETYPE "int64"
|
||||
#define QUSIZETYPE "uint64"
|
||||
#else
|
||||
#error "Processor with unexpected word size"
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "define.h"
|
||||
#include "dialog/mainwindow.h"
|
||||
#include "dialog/splashdialog.h"
|
||||
#include "inspectqtloghelper.h"
|
||||
#include "languagemanager.h"
|
||||
#include "logger.h"
|
||||
#include "settingmanager.h"
|
||||
|
@ -42,6 +43,8 @@ AppManager::AppManager(int &argc, char *argv[])
|
|||
: QtSingleApplication(argc, argv) {
|
||||
ASSERT_SINGLETON;
|
||||
|
||||
LanguageManager::instance();
|
||||
InspectQtLogHelper::instance().init();
|
||||
CrashHandler::instance().init();
|
||||
|
||||
auto args = arguments();
|
||||
|
@ -77,7 +80,6 @@ AppManager::AppManager(int &argc, char *argv[])
|
|||
setFont(font);
|
||||
|
||||
SkinManager::instance();
|
||||
LanguageManager::instance();
|
||||
|
||||
auto dontSplash = set.dontUseSplash();
|
||||
|
||||
|
@ -123,6 +125,8 @@ AppManager::AppManager(int &argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
connect(_w, &MainWindow::closed, this,
|
||||
[]() { AppManager::instance()->exit(); });
|
||||
_instance = this;
|
||||
|
||||
if (splash)
|
||||
|
@ -130,6 +134,7 @@ AppManager::AppManager(int &argc, char *argv[])
|
|||
}
|
||||
|
||||
AppManager::~AppManager() {
|
||||
InspectQtLogHelper::instance().destory();
|
||||
ClangFormatManager::instance().save();
|
||||
CommandHistoryManager::save(QConsoleWidget::history().strings_);
|
||||
|
||||
|
|
|
@ -18,15 +18,14 @@
|
|||
#ifndef CLICKCALLBACK_H
|
||||
#define CLICKCALLBACK_H
|
||||
|
||||
#include "WingPlugin/iwingplugin.h"
|
||||
#include "angelscript.h"
|
||||
#include "plugin/iwingplugin.h"
|
||||
|
||||
class ClickCallBack {
|
||||
public:
|
||||
ClickCallBack() {}
|
||||
|
||||
ClickCallBack(const WingHex::WingPlugin::DataVisual::ClickedCallBack &b)
|
||||
: _call(b) {}
|
||||
ClickCallBack(const WingHex::ClickedCallBack &b) : _call(b) {}
|
||||
|
||||
explicit ClickCallBack(asIScriptEngine *engine, asIScriptFunction *func)
|
||||
: _engine(engine), _func(func) {
|
||||
|
@ -42,14 +41,12 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
ClickCallBack &
|
||||
operator=(const WingHex::WingPlugin::DataVisual::ClickedCallBack &_Right) {
|
||||
ClickCallBack &operator=(const WingHex::ClickedCallBack &_Right) {
|
||||
*this = ClickCallBack(_Right);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ClickCallBack &
|
||||
operator=(WingHex::WingPlugin::DataVisual::ClickedCallBack &&_Right) {
|
||||
ClickCallBack &operator=(WingHex::ClickedCallBack &&_Right) {
|
||||
*this = ClickCallBack(_Right);
|
||||
return *this;
|
||||
}
|
||||
|
@ -79,7 +76,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
WingHex::WingPlugin::DataVisual::ClickedCallBack _call;
|
||||
WingHex::ClickedCallBack _call;
|
||||
asIScriptEngine *_engine = nullptr;
|
||||
asIScriptFunction *_func = nullptr;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "crashhandler.h"
|
||||
#include "angelscript.h"
|
||||
#include "class/pluginsystem.h"
|
||||
#include "dialog/crashreport.h"
|
||||
#include "plugin/pluginsystem.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLibraryInfo>
|
||||
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <cpptrace/cpptrace.hpp>
|
||||
|
||||
#include <cpptrace/formatting.hpp>
|
||||
#include <csignal>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -39,7 +40,6 @@ void CrashHandler::init() {
|
|||
std::signal(SIGABRT, signalHandler);
|
||||
std::signal(SIGSEGV, signalHandler);
|
||||
std::signal(SIGILL, signalHandler);
|
||||
std::signal(SIGABRT, signalHandler);
|
||||
std::signal(SIGFPE, signalHandler);
|
||||
#else
|
||||
::signal(SIGSEGV, signalHandler);
|
||||
|
@ -123,7 +123,9 @@ void CrashHandler::reportCrashAndExit() {
|
|||
ss << Qt::endl;
|
||||
}
|
||||
|
||||
auto str = cpptrace::generate_trace().to_string();
|
||||
auto formatter =
|
||||
cpptrace::formatter{}.paths(cpptrace::formatter::path_mode::basename);
|
||||
auto str = formatter.format(cpptrace::generate_trace());
|
||||
ss << QString::fromStdString(str) << Qt::endl;
|
||||
|
||||
CrashReport r;
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
#include "inspectqtloghelper.h"
|
||||
#include "utilities.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define INFOLOG(msg) "<font color=\"green\">" + msg + "</font>"
|
||||
#define ERRLOG(msg) "<font color=\"red\">" + msg + "</font>"
|
||||
#define WARNLOG(msg) "<font color=\"gold\">" + msg + "</font>"
|
||||
|
||||
InspectQtLogHelper &InspectQtLogHelper::instance() {
|
||||
static InspectQtLogHelper ins;
|
||||
return ins;
|
||||
}
|
||||
|
||||
void InspectQtLogHelper::init() {
|
||||
_logger = new FramelessDialogBase;
|
||||
_ctx = new QTextBrowser(_logger);
|
||||
_ctx->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
_ctx->setUndoRedoEnabled(false);
|
||||
_ctx->setOpenExternalLinks(true);
|
||||
|
||||
auto menu = _ctx->createStandardContextMenu();
|
||||
auto ma = menu->actions();
|
||||
|
||||
menu->addSeparator();
|
||||
auto a = new QAction(tr("Clear"), menu);
|
||||
connect(a, &QAction::triggered, this, [this]() { _ctx->clear(); });
|
||||
menu->addAction(a);
|
||||
|
||||
auto af = ma.at(0);
|
||||
af = menu->insertSeparator(af);
|
||||
a = new QAction(tr("TopMost"), menu);
|
||||
a->setCheckable(true);
|
||||
connect(a, &QAction::toggled, this, [this](bool b) {
|
||||
_logger->setWindowFlag(Qt::WindowStaysOnTopHint, b);
|
||||
if (!_logger->isVisible()) {
|
||||
_logger->setVisible(true);
|
||||
}
|
||||
});
|
||||
menu->insertAction(af, a);
|
||||
|
||||
connect(_ctx, &QTextBrowser::customContextMenuRequested, this,
|
||||
[menu, this](const QPoint &pos) {
|
||||
menu->popup(_ctx->mapToGlobal(pos));
|
||||
});
|
||||
|
||||
_logger->buildUpContent(_ctx);
|
||||
_logger->setWindowTitle(tr("Inspect"));
|
||||
_logger->setWindowIcon(ICONRES("qtloginspect"));
|
||||
|
||||
qSetMessagePattern(QStringLiteral("%{if-debug}[Debug]%{endif}"
|
||||
"%{if-warning}[Warn]%{endif}"
|
||||
"%{if-info}[Info]%{endif}"
|
||||
"%{if-critical}[Error]%{endif}"
|
||||
"%{if-fatal}[Fatal]%{endif}"
|
||||
" %{message}"));
|
||||
qInstallMessageHandler(messageHandler);
|
||||
}
|
||||
|
||||
void InspectQtLogHelper::destory() {
|
||||
qInstallMessageHandler(nullptr);
|
||||
delete _logger;
|
||||
}
|
||||
|
||||
void InspectQtLogHelper::showLogWidget() { _logger->show(); }
|
||||
|
||||
InspectQtLogHelper::InspectQtLogHelper() {}
|
||||
|
||||
InspectQtLogHelper::~InspectQtLogHelper() {}
|
||||
|
||||
void InspectQtLogHelper::messageHandler(QtMsgType type,
|
||||
const QMessageLogContext &context,
|
||||
const QString &message) {
|
||||
auto logger = InspectQtLogHelper::instance()._ctx;
|
||||
auto msg = qFormatLogMessage(type, context, message);
|
||||
Q_ASSERT(logger);
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
logger->append(msg);
|
||||
std::cout << qUtf8Printable(msg) << std::endl;
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
logger->append(INFOLOG(msg));
|
||||
std::cout << qUtf8Printable(msg) << std::endl;
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
case QtFatalMsg:
|
||||
logger->append(ERRLOG(msg));
|
||||
std::cerr << qUtf8Printable(msg) << std::endl;
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
logger->append(INFOLOG(msg));
|
||||
std::cout << qUtf8Printable(msg) << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef INSPECTQTLOGHELPER_H
|
||||
#define INSPECTQTLOGHELPER_H
|
||||
|
||||
#include "dialog/framelessdialogbase.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QTextBrowser>
|
||||
|
||||
class InspectQtLogHelper : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static InspectQtLogHelper &instance();
|
||||
|
||||
void init();
|
||||
void destory();
|
||||
|
||||
void showLogWidget();
|
||||
|
||||
private:
|
||||
InspectQtLogHelper();
|
||||
~InspectQtLogHelper();
|
||||
Q_DISABLE_COPY_MOVE(InspectQtLogHelper)
|
||||
|
||||
private:
|
||||
static void messageHandler(QtMsgType type,
|
||||
const QMessageLogContext &context,
|
||||
const QString &message);
|
||||
|
||||
private:
|
||||
FramelessDialogBase *_logger;
|
||||
QTextBrowser *_ctx;
|
||||
};
|
||||
|
||||
#endif // INSPECTQTLOGHELPER_H
|
|
@ -0,0 +1,917 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify it under
|
||||
** the terms of the GNU Affero General Public License as published by the Free
|
||||
** Software Foundation, version 3.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
** FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
** details.
|
||||
**
|
||||
** You should have received a copy of the GNU Affero General Public License
|
||||
** along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef PLUGINSYSTEM_H
|
||||
#define PLUGINSYSTEM_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QMenu>
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
#include <QQueue>
|
||||
#include <QReadWriteLock>
|
||||
#include <QTimer>
|
||||
#include <QTimerEvent>
|
||||
#include <QToolButton>
|
||||
#include <QVariant>
|
||||
|
||||
#include "WingPlugin/iwingdevice.h"
|
||||
#include "class/clickcallback.h"
|
||||
#include "class/wingangelapi.h"
|
||||
#include "control/editorview.h"
|
||||
|
||||
using namespace WingHex;
|
||||
|
||||
class MainWindow;
|
||||
class asCScriptEngine;
|
||||
|
||||
class PluginSystem : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
class UniqueIdGenerator {
|
||||
public:
|
||||
class UniqueId : public QSharedData {
|
||||
public:
|
||||
UniqueId() : _id(-1), _gen(nullptr) {}
|
||||
|
||||
UniqueId(UniqueIdGenerator *gen, int id) : _id(id), _gen(gen) {
|
||||
Q_ASSERT(gen);
|
||||
Q_ASSERT(id >= 0);
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "[UniqueId] alloced: " << id;
|
||||
#endif
|
||||
}
|
||||
|
||||
~UniqueId() {
|
||||
if (_gen) {
|
||||
_gen->release(_id);
|
||||
}
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "[UniqueId] freed: " << _id;
|
||||
#endif
|
||||
}
|
||||
|
||||
operator int() { return _id; }
|
||||
|
||||
private:
|
||||
int _id;
|
||||
UniqueIdGenerator *_gen;
|
||||
};
|
||||
|
||||
public:
|
||||
UniqueIdGenerator() : currentId(0) {}
|
||||
|
||||
QExplicitlySharedDataPointer<UniqueId> get() {
|
||||
if (!releasedIds.isEmpty()) {
|
||||
int id = releasedIds.dequeue();
|
||||
return QExplicitlySharedDataPointer<UniqueId>(
|
||||
new UniqueId(this, id));
|
||||
} else {
|
||||
return QExplicitlySharedDataPointer<UniqueId>(
|
||||
new UniqueId(this, currentId++));
|
||||
}
|
||||
}
|
||||
|
||||
void release(int id) {
|
||||
if (id < currentId && !releasedIds.contains(id)) {
|
||||
releasedIds.enqueue(id);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int currentId;
|
||||
QQueue<int> releasedIds;
|
||||
};
|
||||
|
||||
using SharedUniqueId =
|
||||
QExplicitlySharedDataPointer<UniqueIdGenerator::UniqueId>;
|
||||
|
||||
public:
|
||||
struct PluginInfo {
|
||||
QString id;
|
||||
QVersionNumber version;
|
||||
QString vendor;
|
||||
QList<WingDependency> dependencies;
|
||||
QString author;
|
||||
QString license;
|
||||
QString url;
|
||||
};
|
||||
|
||||
enum class PluginStatus {
|
||||
Valid,
|
||||
BrokenVersion,
|
||||
InvalidID,
|
||||
DupID,
|
||||
LackDependencies
|
||||
};
|
||||
Q_ENUM(PluginStatus)
|
||||
|
||||
private:
|
||||
struct PluginFileContext {
|
||||
SharedUniqueId fid;
|
||||
EditorView *view = nullptr;
|
||||
IWingPlugin *linkedplg = nullptr;
|
||||
QUndoCommand *cmd = nullptr;
|
||||
|
||||
~PluginFileContext() {
|
||||
if (cmd) {
|
||||
delete cmd;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
static PluginSystem &instance();
|
||||
|
||||
void setMainWindow(MainWindow *win);
|
||||
QWidget *mainWindow() const;
|
||||
|
||||
void loadAllPlugin();
|
||||
void unloadAllPlugin();
|
||||
|
||||
void destory();
|
||||
|
||||
const QList<IWingPlugin *> &plugins() const;
|
||||
IWingPlugin *plugin(qsizetype index) const;
|
||||
|
||||
const QList<IWingDevice *> &devices() const;
|
||||
IWingDevice *device(qsizetype index) const;
|
||||
|
||||
WingAngelAPI *angelApi() const;
|
||||
|
||||
void cleanUpEditorViewHandle(EditorView *view);
|
||||
|
||||
bool dispatchEvent(IWingPlugin::RegisteredEvent event,
|
||||
const QVariantList ¶ms);
|
||||
|
||||
IWingDevice *ext2Device(const QString &ext);
|
||||
|
||||
QStringList scriptMarcos() const;
|
||||
|
||||
public:
|
||||
void scriptPragmaBegin();
|
||||
|
||||
qsizetype pluginAPICount() const;
|
||||
|
||||
public:
|
||||
PluginInfo getPluginInfo(IWingPluginBase *plg) const;
|
||||
|
||||
QString getPluginID(IWingPluginBase *plg) const;
|
||||
|
||||
static QString getPUID(IWingPluginBase *p);
|
||||
|
||||
static QString type2AngelScriptString(IWingPlugin::MetaType type,
|
||||
bool isArg, bool noModifier = false);
|
||||
|
||||
private:
|
||||
void loadExtPlugin();
|
||||
|
||||
void loadDevicePlugin();
|
||||
|
||||
void checkDirRootSafe(const QDir &dir);
|
||||
|
||||
template <typename T>
|
||||
std::optional<PluginInfo> loadPlugin(const QFileInfo &filename,
|
||||
const QDir &setdir);
|
||||
|
||||
bool closeEditor(IWingPlugin *plg, int handle, bool force);
|
||||
|
||||
bool closeHandle(IWingPlugin *plg, int handle);
|
||||
|
||||
bool checkPluginCanOpenedFile(IWingPlugin *plg);
|
||||
|
||||
bool checkPluginHasAlreadyOpened(IWingPlugin *plg, EditorView *view);
|
||||
|
||||
EditorView *getCurrentPluginView(IWingPlugin *plg);
|
||||
|
||||
EditorView *handle2EditorView(IWingPlugin *plg, int handle);
|
||||
|
||||
SharedUniqueId assginHandleForPluginView(IWingPlugin *plg,
|
||||
EditorView *view);
|
||||
|
||||
static bool equalCompareHandle(const SharedUniqueId &id, int handle);
|
||||
|
||||
static int getUIDHandle(const SharedUniqueId &id);
|
||||
|
||||
private:
|
||||
PluginInfo parsePluginMetadata(const QJsonObject &meta);
|
||||
|
||||
PluginStatus checkPluginMetadata(const PluginInfo &meta, bool isPlg);
|
||||
|
||||
static bool isValidIdentifier(const QString &str);
|
||||
|
||||
void retranslateMetadata(IWingPluginBase *plg, PluginInfo &meta);
|
||||
|
||||
private:
|
||||
void registerFns(IWingPlugin *plg);
|
||||
void registerUnSafeFns(IWingPlugin *plg);
|
||||
void registerEnums(IWingPlugin *plg);
|
||||
void registerMarcos(IWingPlugin *plg);
|
||||
void registerEvents(IWingPlugin *plg);
|
||||
|
||||
void applyFunctionTables(IWingPluginBase *plg, const CallTable &fns);
|
||||
|
||||
static QString getScriptFnSig(const QString &fnName,
|
||||
const IWingPlugin::ScriptFnInfo &fninfo);
|
||||
|
||||
bool isPluginLoaded(const WingDependency &d);
|
||||
|
||||
bool isPluginLoaded(const QString &id);
|
||||
|
||||
bool checkThreadAff();
|
||||
|
||||
static QString packLogMessage(const char *header, const QString &msg);
|
||||
|
||||
EditorView *pluginCurrentEditor(IWingPlugin *plg) const;
|
||||
|
||||
QSharedPointer<PluginFileContext> pluginContextById(IWingPlugin *plg,
|
||||
int fid) const;
|
||||
|
||||
QUndoCommand *pluginCurrentUndoCmd(IWingPlugin *plg) const;
|
||||
|
||||
private:
|
||||
void loadPlugin(IWingPlugin *p, PluginInfo &meta,
|
||||
const std::optional<QDir> &setdir);
|
||||
void loadPlugin(IWingDevice *p, PluginInfo &meta,
|
||||
const std::optional<QDir> &setdir);
|
||||
|
||||
private:
|
||||
void registerMarcoDevice(IWingDevice *plg);
|
||||
|
||||
private:
|
||||
void registerPluginDockWidgets(IWingPluginBase *p);
|
||||
void registerPluginPages(IWingPluginBase *p);
|
||||
|
||||
public:
|
||||
bool updateTextList_API(const QStringList &data, const QString &title,
|
||||
const ClickCallBack &click,
|
||||
const ClickCallBack &dblclick);
|
||||
bool updateTextTree_API(const QString &json, const QString &title,
|
||||
const ClickCallBack &click,
|
||||
const ClickCallBack &dblclick);
|
||||
bool updateTextTable_API(const QString &json, const QStringList &headers,
|
||||
const QStringList &headerNames,
|
||||
const QString &title, const ClickCallBack &click,
|
||||
const ClickCallBack &dblclick);
|
||||
|
||||
public:
|
||||
// fpr crash checking
|
||||
QString currentLoadingPlugin() const;
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
T readBasicTypeContent(IWingPlugin *plg, qsizetype offset) {
|
||||
Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>);
|
||||
auto e = pluginCurrentEditor(plg);
|
||||
if (e) {
|
||||
_rwlock.lockForRead();
|
||||
auto buffer = e->hexEditor()->document()->read(offset, sizeof(T));
|
||||
if (buffer.size() == sizeof(T)) {
|
||||
auto pb = reinterpret_cast<const T *>(buffer.constData());
|
||||
_rwlock.unlock();
|
||||
return *pb;
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (std::is_floating_point_v<T>) {
|
||||
return qQNaN();
|
||||
} else {
|
||||
return T(0);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool insertBasicTypeContent(IWingPlugin *plg, qsizetype offset,
|
||||
const T &value) {
|
||||
Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>);
|
||||
auto e = getCurrentPluginView(plg);
|
||||
if (e) {
|
||||
auto editor = e->hexEditor();
|
||||
auto doc = editor->document();
|
||||
auto buffer = reinterpret_cast<const char *>(&value);
|
||||
auto uc = pluginCurrentUndoCmd(plg);
|
||||
auto cmd = doc->MakeInsert(uc, editor->cursor(), offset,
|
||||
QByteArray(buffer, sizeof(T)));
|
||||
if (uc == nullptr && cmd) {
|
||||
_rwlock.lockForWrite();
|
||||
doc->pushMakeUndo(cmd);
|
||||
_rwlock.unlock();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool writeBasicTypeContent(IWingPlugin *plg, qsizetype offset,
|
||||
const T &value) {
|
||||
Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>);
|
||||
auto e = getCurrentPluginView(plg);
|
||||
if (e) {
|
||||
auto editor = e->hexEditor();
|
||||
auto doc = editor->document();
|
||||
auto buffer = reinterpret_cast<const char *>(&value);
|
||||
auto uc = pluginCurrentUndoCmd(plg);
|
||||
auto cmd = doc->MakeReplace(uc, editor->cursor(), offset,
|
||||
QByteArray(buffer, sizeof(T)));
|
||||
if (uc == nullptr && cmd) {
|
||||
_rwlock.lockForWrite();
|
||||
doc->pushMakeUndo(cmd);
|
||||
_rwlock.unlock();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool appendBasicTypeContent(IWingPlugin *plg, const T &value) {
|
||||
Q_STATIC_ASSERT(std::is_integral_v<T> || std::is_floating_point_v<T>);
|
||||
auto e = getCurrentPluginView(plg);
|
||||
if (e) {
|
||||
auto editor = e->hexEditor();
|
||||
auto doc = editor->document();
|
||||
auto buffer = reinterpret_cast<const char *>(&value);
|
||||
auto uc = pluginCurrentUndoCmd(plg);
|
||||
auto cmd = doc->MakeAppend(uc, editor->cursor(),
|
||||
QByteArray(buffer, sizeof(T)));
|
||||
if (uc == nullptr && cmd) {
|
||||
_rwlock.lockForWrite();
|
||||
doc->pushMakeUndo(cmd);
|
||||
_rwlock.unlock();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
signals:
|
||||
void pluginLoading(const QString &plgName);
|
||||
|
||||
private:
|
||||
PluginSystem(QObject *parent = nullptr);
|
||||
~PluginSystem();
|
||||
|
||||
void initCheckingEngine();
|
||||
|
||||
void finalizeCheckingEngine();
|
||||
|
||||
// IWingPluginBase API
|
||||
public:
|
||||
WING_SERVICE void toast(WingHex::IWingPluginBase *sender,
|
||||
const QPixmap &icon, const QString &message);
|
||||
|
||||
// logging
|
||||
WING_SERVICE void logTrace(WingHex::IWingPluginBase *sender,
|
||||
const QString &message);
|
||||
WING_SERVICE void logDebug(WingHex::IWingPluginBase *sender,
|
||||
const QString &message);
|
||||
WING_SERVICE void logInfo(WingHex::IWingPluginBase *sender,
|
||||
const QString &message);
|
||||
WING_SERVICE void logWarn(WingHex::IWingPluginBase *sender,
|
||||
const QString &message);
|
||||
WING_SERVICE void logError(WingHex::IWingPluginBase *sender,
|
||||
const QString &message);
|
||||
WING_SERVICE bool raiseDockWidget(WingHex::IWingPluginBase *sender,
|
||||
QWidget *w);
|
||||
WING_SERVICE WingHex::AppTheme
|
||||
currentAppTheme(WingHex::IWingPluginBase *sender);
|
||||
WING_SERVICE QDialog *createDialog(WingHex::IWingPluginBase *sender,
|
||||
QWidget *content);
|
||||
|
||||
public:
|
||||
WING_SERVICE void msgAboutQt(WingHex::IWingPluginBase *sender,
|
||||
QWidget *parent, const QString &title);
|
||||
WING_SERVICE QMessageBox::StandardButton
|
||||
msgInformation(WingHex::IWingPluginBase *sender, QWidget *parent,
|
||||
const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton);
|
||||
WING_SERVICE QMessageBox::StandardButton
|
||||
msgQuestion(WingHex::IWingPluginBase *sender, QWidget *parent,
|
||||
const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton);
|
||||
WING_SERVICE QMessageBox::StandardButton
|
||||
msgWarning(WingHex::IWingPluginBase *sender, QWidget *parent,
|
||||
const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton);
|
||||
WING_SERVICE QMessageBox::StandardButton
|
||||
msgCritical(WingHex::IWingPluginBase *sender, QWidget *parent,
|
||||
const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton);
|
||||
WING_SERVICE void msgAbout(WingHex::IWingPluginBase *sender,
|
||||
QWidget *parent, const QString &title,
|
||||
const QString &text);
|
||||
WING_SERVICE QMessageBox::StandardButton
|
||||
msgbox(WingHex::IWingPluginBase *sender, QWidget *parent,
|
||||
QMessageBox::Icon icon, const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton);
|
||||
|
||||
public:
|
||||
WING_SERVICE QString dlgGetText(WingHex::IWingPluginBase *sender,
|
||||
QWidget *parent, const QString &title,
|
||||
const QString &label,
|
||||
QLineEdit::EchoMode echo,
|
||||
const QString &text, bool *ok,
|
||||
Qt::InputMethodHints inputMethodHints);
|
||||
WING_SERVICE QString dlgGetMultiLineText(
|
||||
WingHex::IWingPluginBase *sender, QWidget *parent, const QString &title,
|
||||
const QString &label, const QString &text, bool *ok,
|
||||
Qt::InputMethodHints inputMethodHints);
|
||||
WING_SERVICE QString dlgGetItem(WingHex::IWingPluginBase *sender,
|
||||
QWidget *parent, const QString &title,
|
||||
const QString &label,
|
||||
const QStringList &items, int current,
|
||||
bool editable, bool *ok,
|
||||
Qt::InputMethodHints inputMethodHints);
|
||||
WING_SERVICE int dlgGetInt(WingHex::IWingPluginBase *sender,
|
||||
QWidget *parent, const QString &title,
|
||||
const QString &label, int value, int minValue,
|
||||
int maxValue, int step, bool *ok);
|
||||
WING_SERVICE double dlgGetDouble(WingHex::IWingPluginBase *sender,
|
||||
QWidget *parent, const QString &title,
|
||||
const QString &label, double value,
|
||||
double minValue, double maxValue,
|
||||
int decimals, bool *ok, double step);
|
||||
|
||||
public:
|
||||
WING_SERVICE QString
|
||||
dlgGetExistingDirectory(WingHex::IWingPluginBase *sender, QWidget *parent,
|
||||
const QString &caption, const QString &dir,
|
||||
QFileDialog::Options options);
|
||||
WING_SERVICE QString dlgGetOpenFileName(
|
||||
WingHex::IWingPluginBase *sender, QWidget *parent,
|
||||
const QString &caption, const QString &dir, const QString &filter,
|
||||
QString *selectedFilter, QFileDialog::Options options);
|
||||
WING_SERVICE QStringList dlgGetOpenFileNames(
|
||||
WingHex::IWingPluginBase *sender, QWidget *parent,
|
||||
const QString &caption, const QString &dir, const QString &filter,
|
||||
QString *selectedFilter, QFileDialog::Options options);
|
||||
WING_SERVICE QString dlgGetSaveFileName(
|
||||
WingHex::IWingPluginBase *sender, QWidget *parent,
|
||||
const QString &caption, const QString &dir, const QString &filter,
|
||||
QString *selectedFilter, QFileDialog::Options options);
|
||||
|
||||
WING_SERVICE QColor dlgGetColor(WingHex::IWingPluginBase *sender,
|
||||
const QString &caption, QWidget *parent);
|
||||
|
||||
// IWingPlugin API
|
||||
public:
|
||||
WING_SERVICE bool existsServiceHost(WingHex::IWingPluginBase *sender,
|
||||
const QString &puid);
|
||||
|
||||
WING_SERVICE bool
|
||||
invokeService(WingHex::IWingPluginBase *sender, const QString &puid,
|
||||
const char *method, Qt::ConnectionType type,
|
||||
QGenericReturnArgument ret, QGenericArgument val0,
|
||||
QGenericArgument val1, QGenericArgument val2,
|
||||
QGenericArgument val3, QGenericArgument val4);
|
||||
|
||||
WING_SERVICE bool isCurrentDocEditing(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE QString currentDocFilename(WingHex::IWingPluginBase *sender);
|
||||
|
||||
// document
|
||||
WING_SERVICE bool isReadOnly(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE bool isInsertionMode(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE bool isKeepSize(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE bool isLocked(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE qsizetype documentLines(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE qsizetype documentBytes(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE WingHex::HexPosition
|
||||
currentPos(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE qsizetype currentRow(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE qsizetype currentColumn(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE qsizetype currentOffset(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE qsizetype selectedLength(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE QByteArray selectedBytes(WingHex::IWingPluginBase *sender,
|
||||
qsizetype index);
|
||||
|
||||
WING_SERVICE QByteArrayList
|
||||
selectionBytes(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE WingHex::HexPosition
|
||||
selectionStart(WingHex::IWingPluginBase *sender, qsizetype index);
|
||||
|
||||
WING_SERVICE WingHex::HexPosition
|
||||
selectionEnd(WingHex::IWingPluginBase *sender, qsizetype index);
|
||||
|
||||
WING_SERVICE qsizetype selectionLength(WingHex::IWingPluginBase *sender,
|
||||
qsizetype index);
|
||||
|
||||
WING_SERVICE qsizetype selectionCount(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE bool stringVisible(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE bool addressVisible(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE bool headerVisible(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE quintptr addressBase(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE bool isModified(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE qint8 readInt8(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset);
|
||||
|
||||
WING_SERVICE qint16 readInt16(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset);
|
||||
|
||||
WING_SERVICE qint32 readInt32(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset);
|
||||
|
||||
WING_SERVICE qint64 readInt64(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset);
|
||||
|
||||
WING_SERVICE quint8 readUInt8(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset);
|
||||
|
||||
WING_SERVICE quint16 readUInt16(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset);
|
||||
|
||||
WING_SERVICE quint32 readUInt32(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset);
|
||||
|
||||
WING_SERVICE quint64 readUInt64(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset);
|
||||
|
||||
WING_SERVICE float readFloat(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset);
|
||||
|
||||
WING_SERVICE double readDouble(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset);
|
||||
|
||||
WING_SERVICE QString readString(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, const QString &encoding);
|
||||
|
||||
WING_SERVICE QByteArray readBytes(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, qsizetype count);
|
||||
|
||||
WING_SERVICE qsizetype findNext(WingHex::IWingPluginBase *sender,
|
||||
qsizetype begin, const QByteArray &ba);
|
||||
|
||||
WING_SERVICE qsizetype findPrevious(WingHex::IWingPluginBase *sender,
|
||||
qsizetype begin, const QByteArray &ba);
|
||||
|
||||
WING_SERVICE QString bookMarkComment(WingHex::IWingPluginBase *sender,
|
||||
qsizetype pos);
|
||||
|
||||
WING_SERVICE bool existBookMark(WingHex::IWingPluginBase *sender,
|
||||
qsizetype pos);
|
||||
|
||||
// document
|
||||
WING_SERVICE bool switchDocument(WingHex::IWingPluginBase *sender,
|
||||
int handle);
|
||||
|
||||
WING_SERVICE bool raiseDocument(WingHex::IWingPluginBase *sender,
|
||||
int handle);
|
||||
|
||||
WING_SERVICE bool setLockedFile(WingHex::IWingPluginBase *sender, bool b);
|
||||
|
||||
WING_SERVICE bool setKeepSize(WingHex::IWingPluginBase *sender, bool b);
|
||||
|
||||
WING_SERVICE bool setStringVisible(WingHex::IWingPluginBase *sender,
|
||||
bool b);
|
||||
|
||||
WING_SERVICE bool setAddressVisible(WingHex::IWingPluginBase *sender,
|
||||
bool b);
|
||||
|
||||
WING_SERVICE bool setHeaderVisible(WingHex::IWingPluginBase *sender,
|
||||
bool b);
|
||||
|
||||
WING_SERVICE bool setAddressBase(WingHex::IWingPluginBase *sender,
|
||||
quintptr base);
|
||||
|
||||
WING_SERVICE bool beginMarco(WingHex::IWingPluginBase *sender,
|
||||
const QString &txt);
|
||||
|
||||
WING_SERVICE bool endMarco(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE bool writeInt8(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, qint8 value);
|
||||
|
||||
WING_SERVICE bool writeInt16(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, qint16 value);
|
||||
|
||||
WING_SERVICE bool writeInt32(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, qint32 value);
|
||||
|
||||
WING_SERVICE bool writeInt64(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, qint64 value);
|
||||
|
||||
WING_SERVICE bool writeUInt8(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, quint8 value);
|
||||
|
||||
WING_SERVICE bool writeUInt16(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, quint16 value);
|
||||
|
||||
WING_SERVICE bool writeUInt32(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, quint32 value);
|
||||
|
||||
WING_SERVICE bool writeUInt64(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, quint64 value);
|
||||
|
||||
WING_SERVICE bool writeFloat(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, float value);
|
||||
|
||||
WING_SERVICE bool writeDouble(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, double value);
|
||||
|
||||
WING_SERVICE bool writeString(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, const QString &value,
|
||||
const QString &encoding);
|
||||
|
||||
WING_SERVICE bool writeBytes(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, const QByteArray &data);
|
||||
|
||||
WING_SERVICE bool insertInt8(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, qint8 value);
|
||||
|
||||
WING_SERVICE bool insertInt16(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, qint16 value);
|
||||
|
||||
WING_SERVICE bool insertInt32(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, qint32 value);
|
||||
|
||||
WING_SERVICE bool insertInt64(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, qint64 value);
|
||||
|
||||
WING_SERVICE bool insertUInt8(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, quint8 value);
|
||||
|
||||
WING_SERVICE bool insertUInt16(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, quint16 value);
|
||||
|
||||
WING_SERVICE bool insertUInt32(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, quint32 value);
|
||||
|
||||
WING_SERVICE bool insertUInt64(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, quint64 value);
|
||||
|
||||
WING_SERVICE bool insertFloat(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, float value);
|
||||
|
||||
WING_SERVICE bool insertDouble(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, double value);
|
||||
|
||||
WING_SERVICE bool insertString(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, const QString &value,
|
||||
const QString &encoding);
|
||||
|
||||
WING_SERVICE bool insertBytes(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, const QByteArray &data);
|
||||
|
||||
WING_SERVICE bool appendInt8(WingHex::IWingPluginBase *sender, qint8 value);
|
||||
|
||||
WING_SERVICE bool appendInt16(WingHex::IWingPluginBase *sender,
|
||||
qint16 value);
|
||||
|
||||
WING_SERVICE bool appendInt32(WingHex::IWingPluginBase *sender,
|
||||
qint32 value);
|
||||
|
||||
WING_SERVICE bool appendInt64(WingHex::IWingPluginBase *sender,
|
||||
qint64 value);
|
||||
|
||||
WING_SERVICE bool appendUInt8(WingHex::IWingPluginBase *sender,
|
||||
quint8 value);
|
||||
|
||||
WING_SERVICE bool appendUInt16(WingHex::IWingPluginBase *sender,
|
||||
quint16 value);
|
||||
|
||||
WING_SERVICE bool appendUInt32(WingHex::IWingPluginBase *sender,
|
||||
quint32 value);
|
||||
|
||||
WING_SERVICE bool appendUInt64(WingHex::IWingPluginBase *sender,
|
||||
quint64 value);
|
||||
|
||||
WING_SERVICE bool appendFloat(WingHex::IWingPluginBase *sender,
|
||||
float value);
|
||||
|
||||
WING_SERVICE bool appendDouble(WingHex::IWingPluginBase *sender,
|
||||
double value);
|
||||
|
||||
WING_SERVICE bool appendString(WingHex::IWingPluginBase *sender,
|
||||
const QString &value,
|
||||
const QString &encoding);
|
||||
|
||||
WING_SERVICE bool appendBytes(WingHex::IWingPluginBase *sender,
|
||||
const QByteArray &data);
|
||||
|
||||
WING_SERVICE bool removeBytes(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset, qsizetype len);
|
||||
|
||||
// cursor
|
||||
WING_SERVICE bool moveTo(WingHex::IWingPluginBase *sender, qsizetype line,
|
||||
qsizetype column, int nibbleindex,
|
||||
bool clearSelection);
|
||||
|
||||
WING_SERVICE bool moveTo(WingHex::IWingPluginBase *sender, qsizetype offset,
|
||||
bool clearSelection);
|
||||
|
||||
WING_SERVICE bool select(WingHex::IWingPluginBase *sender, qsizetype offset,
|
||||
qsizetype length, SelectionMode mode);
|
||||
|
||||
WING_SERVICE bool setInsertionMode(WingHex::IWingPluginBase *sender,
|
||||
bool isinsert);
|
||||
|
||||
WING_SERVICE bool metadata(WingHex::IWingPluginBase *sender,
|
||||
qsizetype begin, qsizetype length,
|
||||
const QColor &fgcolor, const QColor &bgcolor,
|
||||
const QString &comment);
|
||||
|
||||
WING_SERVICE bool removeMetadata(WingHex::IWingPluginBase *sender,
|
||||
qsizetype offset);
|
||||
|
||||
WING_SERVICE bool clearMetadata(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE bool setMetaVisible(WingHex::IWingPluginBase *sender, bool b);
|
||||
|
||||
WING_SERVICE bool setMetafgVisible(WingHex::IWingPluginBase *sender,
|
||||
bool b);
|
||||
|
||||
WING_SERVICE bool setMetabgVisible(WingHex::IWingPluginBase *sender,
|
||||
bool b);
|
||||
|
||||
WING_SERVICE bool setMetaCommentVisible(WingHex::IWingPluginBase *sender,
|
||||
bool b);
|
||||
|
||||
// mainwindow
|
||||
WING_SERVICE WingHex::ErrFile newFile(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile openFile(WingHex::IWingPluginBase *sender,
|
||||
const QString &filename);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile openExtFile(WingHex::IWingPluginBase *sender,
|
||||
const QString &ext,
|
||||
const QString &file);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile
|
||||
openWorkSpace(WingHex::IWingPluginBase *sender, const QString &filename);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile closeHandle(WingHex::IWingPluginBase *sender,
|
||||
int handle);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile closeFile(WingHex::IWingPluginBase *sender,
|
||||
int handle, bool force);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile saveFile(WingHex::IWingPluginBase *sender,
|
||||
int handle);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile exportFile(WingHex::IWingPluginBase *sender,
|
||||
int handle,
|
||||
const QString &savename);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile saveAsFile(WingHex::IWingPluginBase *sender,
|
||||
int handle,
|
||||
const QString &savename);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile openCurrent(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile closeCurrent(WingHex::IWingPluginBase *sender,
|
||||
bool force);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile saveCurrent(WingHex::IWingPluginBase *sender);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile
|
||||
exportCurrent(WingHex::IWingPluginBase *sender, const QString &savename);
|
||||
|
||||
WING_SERVICE WingHex::ErrFile
|
||||
saveAsCurrent(WingHex::IWingPluginBase *sender, const QString &savename);
|
||||
|
||||
// bookmark
|
||||
WING_SERVICE bool addBookMark(WingHex::IWingPluginBase *sender,
|
||||
qsizetype pos, const QString &comment);
|
||||
|
||||
WING_SERVICE bool modBookMark(WingHex::IWingPluginBase *sender,
|
||||
qsizetype pos, const QString &comment);
|
||||
|
||||
WING_SERVICE bool removeBookMark(WingHex::IWingPluginBase *sender,
|
||||
qsizetype pos);
|
||||
|
||||
WING_SERVICE bool clearBookMark(WingHex::IWingPluginBase *sender);
|
||||
|
||||
// extension
|
||||
WING_SERVICE bool closeAllFiles(WingHex::IWingPluginBase *sender);
|
||||
|
||||
public:
|
||||
WING_SERVICE bool dataVisualText(WingHex::IWingPluginBase *sender,
|
||||
const QString &data, const QString &title);
|
||||
|
||||
WING_SERVICE bool dataVisualTextList(WingHex::IWingPluginBase *sender,
|
||||
const QStringList &data,
|
||||
const QString &title,
|
||||
WingHex::ClickedCallBack clicked,
|
||||
WingHex::ClickedCallBack dblClicked);
|
||||
|
||||
WING_SERVICE bool dataVisualTextTree(WingHex::IWingPluginBase *sender,
|
||||
const QString &json,
|
||||
const QString &title,
|
||||
WingHex::ClickedCallBack clicked,
|
||||
WingHex::ClickedCallBack dblClicked);
|
||||
|
||||
WING_SERVICE bool dataVisualTextTable(WingHex::IWingPluginBase *sender,
|
||||
const QString &json,
|
||||
const QStringList &headers,
|
||||
const QStringList &headerNames,
|
||||
const QString &title,
|
||||
WingHex::ClickedCallBack clicked,
|
||||
WingHex::ClickedCallBack dblClicked);
|
||||
|
||||
// API for Qt Plugin Only
|
||||
WING_SERVICE bool
|
||||
dataVisualTextListByModel(WingHex::IWingPluginBase *sender,
|
||||
QAbstractItemModel *model, const QString &title,
|
||||
WingHex::ClickedCallBack clicked,
|
||||
WingHex::ClickedCallBack dblClicked);
|
||||
|
||||
WING_SERVICE bool
|
||||
dataVisualTextTableByModel(WingHex::IWingPluginBase *sender,
|
||||
QAbstractItemModel *model, const QString &title,
|
||||
WingHex::ClickedCallBack clicked,
|
||||
WingHex::ClickedCallBack dblClicked);
|
||||
|
||||
WING_SERVICE bool
|
||||
dataVisualTextTreeByModel(WingHex::IWingPluginBase *sender,
|
||||
QAbstractItemModel *model, const QString &title,
|
||||
WingHex::ClickedCallBack clicked,
|
||||
WingHex::ClickedCallBack dblClicked);
|
||||
|
||||
private:
|
||||
WingHex::IWingPlugin *checkPluginAndReport(WingHex::IWingPluginBase *sender,
|
||||
const char *func);
|
||||
|
||||
WingHex::IWingDevice *checkBaseAndReport(WingHex::IWingPluginBase *sender,
|
||||
const char *func);
|
||||
|
||||
bool checkErrAllAllowAndReport(WingHex::IWingPluginBase *sender,
|
||||
const char *func);
|
||||
|
||||
private:
|
||||
CallTable _plgFns;
|
||||
|
||||
private:
|
||||
MainWindow *_win = nullptr;
|
||||
QHash<IWingPluginBase *, PluginInfo> _pinfos;
|
||||
QList<IWingPlugin *> _loadedplgs;
|
||||
QHash<QWidget *, ads::CDockWidget *> _raisedw;
|
||||
QStringList _lazyplgs;
|
||||
|
||||
QList<IWingDevice *> _loadeddevs;
|
||||
|
||||
QMap<IWingPlugin::RegisteredEvent, QList<IWingPlugin *>> _evplgs;
|
||||
|
||||
QHash<IWingPlugin *, QVector<QSharedPointer<PluginFileContext>>>
|
||||
m_plgviewMap;
|
||||
QHash<IWingPlugin *, int> m_plgCurrentfid; // fid
|
||||
QHash<EditorView *, QList<IWingPlugin *>> m_viewBindings;
|
||||
|
||||
UniqueIdGenerator m_idGen;
|
||||
|
||||
QHash<QString, QHash<QString, WingAngelAPI::ScriptFnInfo>> _scfns;
|
||||
|
||||
WingAngelAPI *_angelplg = nullptr;
|
||||
asCScriptEngine *_engine = nullptr;
|
||||
|
||||
QStringList _scriptMarcos;
|
||||
QList<IWingPlugin *> _pragmaedPlg;
|
||||
|
||||
QReadWriteLock _rwlock;
|
||||
|
||||
private:
|
||||
QString _curLoadingPlg;
|
||||
|
||||
Q_DISABLE_COPY_MOVE(PluginSystem)
|
||||
};
|
||||
|
||||
#endif // PLUGINSYSTEM_H
|
|
@ -30,9 +30,9 @@
|
|||
|
||||
#include "angelobjstring.h"
|
||||
#include "class/asbuilder.h"
|
||||
#include "class/pluginsystem.h"
|
||||
#include "class/qascodeparser.h"
|
||||
#include "define.h"
|
||||
#include "plugin/pluginsystem.h"
|
||||
#include "scriptaddon/scriptcolor.h"
|
||||
#include "scriptaddon/scriptfile.h"
|
||||
#include "scriptaddon/scriptjson.h"
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
#define WINGANGELAPI_H
|
||||
|
||||
#include "AngelScript/sdk/add_on/scriptarray/scriptarray.h"
|
||||
#include "plugin/iwingplugin.h"
|
||||
#include "WingPlugin/iwingplugin.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <any>
|
||||
#include <functional>
|
||||
|
@ -31,6 +33,7 @@ class ScriptingConsole;
|
|||
|
||||
class WingAngelAPI : public WingHex::IWingPlugin {
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(WingHex::IWingPlugin)
|
||||
|
||||
public:
|
||||
WingAngelAPI();
|
||||
|
@ -39,7 +42,6 @@ public:
|
|||
// IWingPlugin interface
|
||||
public:
|
||||
virtual int sdkVersion() const override;
|
||||
virtual const QString signature() const override;
|
||||
virtual bool init(const std::unique_ptr<QSettings> &set) override;
|
||||
virtual void unload(std::unique_ptr<QSettings> &set) override;
|
||||
virtual const QString pluginName() const override;
|
||||
|
@ -223,19 +225,9 @@ private:
|
|||
|
||||
CScriptArray *_HexReader_readBytes(qsizetype offset, qsizetype len);
|
||||
|
||||
qsizetype _HexReader_searchForward(qsizetype begin, const CScriptArray &ba);
|
||||
qsizetype _HexReader_findNext(qsizetype begin, const CScriptArray &ba);
|
||||
|
||||
qsizetype _HexReader_searchBackward(qsizetype begin,
|
||||
const CScriptArray &ba);
|
||||
|
||||
CScriptArray *_HexReader_findAllBytes(qsizetype begin, qsizetype end,
|
||||
const CScriptArray &ba);
|
||||
|
||||
CScriptArray *_HexReader_getsBookmarkPos(qsizetype line);
|
||||
|
||||
CScriptArray *_HexReader_getSupportedEncodings();
|
||||
|
||||
CScriptArray *_HexReader_getStorageDrivers();
|
||||
qsizetype _HexReader_findPrevious(qsizetype begin, const CScriptArray &ba);
|
||||
|
||||
bool _HexController_writeBytes(qsizetype offset, const CScriptArray &ba);
|
||||
|
||||
|
|