From af15ffc8aa3b1d64fa2f79106db7fd41b61f40f2 Mon Sep 17 00:00:00 2001 From: wingsummer <1326224942@qq.com> Date: Sun, 20 Jul 2025 21:51:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=BC=BA=E5=8D=81=E5=85=AD?= =?UTF-8?q?=E8=BF=9B=E5=88=B6=E7=BC=96=E8=BE=91=E5=8C=BA=E6=8B=93=E5=B1=95?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdparty/QHexView/document/qhexrenderer.cpp | 13 + 3rdparty/QHexView/document/qhexrenderer.h | 1 + 3rdparty/QHexView/qhexview.cpp | 35 ++- 3rdparty/QHexView/qhexview.h | 4 + TestHexExt/testhexext.cpp | 8 +- WingPlugin | 2 +- lang/zh_CN/winghex_zh_CN.ts | 166 +++++------ lang/zh_TW/winghex_zh_TW.ts | 166 +++++------ src/class/aspreprocesser.cpp | 2 +- src/class/pluginsystem.cpp | 108 ++++++- src/class/wingangel.cpp | 33 ++- src/control/editorview.cpp | 301 +++++++++++--------- src/control/editorview.h | 290 ++++++++++--------- src/dialog/settingdialog.cpp | 4 +- 14 files changed, 643 insertions(+), 490 deletions(-) diff --git a/3rdparty/QHexView/document/qhexrenderer.cpp b/3rdparty/QHexView/document/qhexrenderer.cpp index 85681fe..d044bd9 100644 --- a/3rdparty/QHexView/document/qhexrenderer.cpp +++ b/3rdparty/QHexView/document/qhexrenderer.cpp @@ -111,6 +111,19 @@ void QHexRenderer::renderFrame(QPainter *painter) { painter->drawLine(endx, rect.top(), endx, rect.bottom()); } +void QHexRenderer::renderAdditonalFrame(QPainter *painter, bool top, + bool left) { + QRect rect = painter->window(); + int endx = this->getEndColumnX(); + painter->setPen(m_borderColor); + if (top) { + painter->drawLine(0, 0, endx, 0); + } + if (left) { + painter->drawLine(0, 0, 0, rect.bottom()); + } +} + // modified by wingsummer void QHexRenderer::render(QPainter *painter, qsizetype begin, qsizetype end, qsizetype firstline) { diff --git a/3rdparty/QHexView/document/qhexrenderer.h b/3rdparty/QHexView/document/qhexrenderer.h index e477a29..25b1aec 100644 --- a/3rdparty/QHexView/document/qhexrenderer.h +++ b/3rdparty/QHexView/document/qhexrenderer.h @@ -43,6 +43,7 @@ public: const QFontMetricsF &fontmetrics, QObject *parent = nullptr); void renderFrame(QPainter *painter); + void renderAdditonalFrame(QPainter *painter, bool top, bool left); void render(QPainter *painter, qsizetype start, qsizetype end, qsizetype firstline); // begin included, end excluded void updateMetrics(const QFontMetricsF &fm); diff --git a/3rdparty/QHexView/qhexview.cpp b/3rdparty/QHexView/qhexview.cpp index c3bf64f..3a91d8d 100644 --- a/3rdparty/QHexView/qhexview.cpp +++ b/3rdparty/QHexView/qhexview.cpp @@ -325,10 +325,17 @@ void QHexView::keyPressEvent(QKeyEvent *e) { QPoint QHexView::absolutePosition(const QPoint &pos) const { auto margins = viewport()->contentsMargins(); QPoint shift(horizontalScrollBar()->value() - margins.left(), - -margins.top() * m_renderer->lineHeight()); + -margins.top()); return pos + shift; } +bool QHexView::disableInternalPaint() const { return m_disableInternalPaint; } + +void QHexView::setDisableInternalPaint(bool newDisableInternalPaint) { + m_disableInternalPaint = newDisableInternalPaint; + update(); +} + QHexCursor *QHexView::cursor() const { return m_cursor; } qsizetype QHexView::copyLimit() const { return m_copylimit; } @@ -786,9 +793,9 @@ void QHexView::paintEvent(QPaintEvent *e) { // these are lines from the point of view of the visible rect // where the first "headerCount" are taken by the header - const int first = (r.top() / lineHeight); // included + const int first = (r.top() - m.top()) / lineHeight; // included const int lastPlusOne = - (r.bottom() / lineHeight) + 1 - m.top() - m.bottom(); // excluded + ((r.bottom() - m.top() - m.bottom()) / lineHeight) + 1; // excluded // compute document lines, adding firstVisible and removing the header // the max is necessary if the rect covers the header @@ -796,12 +803,15 @@ void QHexView::paintEvent(QPaintEvent *e) { const qsizetype end = firstVisible + std::max(lastPlusOne - headerCount, 0); Q_EMIT onPaintCustomEventBegin(); - painter.save(); auto xOff = this->horizontalScrollBar()->value(); - painter.translate(-xOff + m.left(), m.top() * m_renderer->lineHeight()); - m_renderer->render(&painter, begin, end, firstVisible); - m_renderer->renderFrame(&painter); - painter.restore(); + if (Q_LIKELY(!m_disableInternalPaint)) { + painter.save(); + painter.translate(-xOff + m.left(), m.top()); + m_renderer->render(&painter, begin, end, firstVisible); + m_renderer->renderFrame(&painter); + m_renderer->renderAdditonalFrame(&painter, m.top() > 0, m.left() > 0); + painter.restore(); + } Q_EMIT onPaintCustomEvent(xOff, firstVisible, begin, end); } @@ -1184,7 +1194,6 @@ void QHexView::adjustScrollBars() { auto docLines = m_renderer->documentLines(); auto visLines = this->visibleLines(); - auto margins = viewport()->contentsMargins(); // modified by wingsummer,fix the scrollbar bug if (docLines > visLines && !m_document->isEmpty()) { @@ -1200,6 +1209,7 @@ void QHexView::adjustScrollBars() { QScrollBar *hscrollbar = this->horizontalScrollBar(); int documentWidth = m_renderer->documentWidth(); int viewportWidth = viewport()->width(); + auto margins = viewport()->contentsMargins(); if (documentWidth > viewportWidth) { this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); @@ -1231,9 +1241,10 @@ qsizetype QHexView::lastVisibleLine() const { qsizetype QHexView::visibleLines() const { auto margins = viewport()->contentsMargins(); - auto visLines = qsizetype(std::ceil( - this->height() / m_renderer->lineHeight() - - m_renderer->headerLineCount() - margins.top() - margins.bottom())); + auto visLines = qsizetype( + std::ceil((this->height() - margins.top() - margins.bottom()) / + m_renderer->lineHeight() - + m_renderer->headerLineCount())); return std::min(visLines, m_renderer->documentLines()); } diff --git a/3rdparty/QHexView/qhexview.h b/3rdparty/QHexView/qhexview.h index 651fefe..14310a3 100644 --- a/3rdparty/QHexView/qhexview.h +++ b/3rdparty/QHexView/qhexview.h @@ -106,6 +106,9 @@ public: qsizetype copyLimit() const; QHexCursor *cursor() const; + bool disableInternalPaint() const; + void setDisableInternalPaint(bool newDisableInternalPaint); + public slots: void setDocument(const QSharedPointer &document, QHexCursor *cursor = nullptr); @@ -228,6 +231,7 @@ private: qreal m_fontSize; qreal m_scaleRate = 1.0; + bool m_disableInternalPaint = false; qsizetype m_copylimit = 1; // MB }; diff --git a/TestHexExt/testhexext.cpp b/TestHexExt/testhexext.cpp index 656bd20..bf17633 100644 --- a/TestHexExt/testhexext.cpp +++ b/TestHexExt/testhexext.cpp @@ -48,7 +48,6 @@ QMenu *TestHexExt::registeredHexContextMenu() const { return m_context; } QList TestHexExt::registeredRibbonTools() const { - // TODO return {}; } @@ -60,8 +59,10 @@ QMargins TestHexExt::contentMargins(WingHex::HexEditorContext *context) const { auto str = QString::number(lines); auto fm = context->fontMetrics(); constexpr auto padding = 4; - auto len = fm.horizontalAdvance(str) + padding; - return {int(len), 0, 0, 1}; + auto header = QStringLiteral("Line"); + auto minLen = fm.horizontalAdvance(header) + padding; + auto colLen = qMax(fm.horizontalAdvance(str) + padding, minLen); + return {int(colLen) + 1, 0, 0, 0}; } void TestHexExt::onPaintEvent(QPainter *painter, const QWidget *w, @@ -90,7 +91,6 @@ void TestHexExt::onPaintEvent(QPainter *painter, const QWidget *w, painter->restore(); context->renderHexBackground(painter, {0, 0}, colLen); } - painter->drawLine(colLen, 0, colLen, w->height()); // draw Line Numbers painter->setPen(context->addressColor()); diff --git a/WingPlugin b/WingPlugin index 19604df..fad7748 160000 --- a/WingPlugin +++ b/WingPlugin @@ -1 +1 @@ -Subproject commit 19604dfffe05008c22f3ec77b7d09f6525836ed9 +Subproject commit fad774858664d6a137c21b0c2af73ca209cc2f47 diff --git a/lang/zh_CN/winghex_zh_CN.ts b/lang/zh_CN/winghex_zh_CN.ts index 6998b63..f4eb9bd 100644 --- a/lang/zh_CN/winghex_zh_CN.ts +++ b/lang/zh_CN/winghex_zh_CN.ts @@ -450,72 +450,72 @@ EditorView - + Cut 剪切 - + CutHex 剪切(十六进制) - + Copy 复制 - + CopyHex 复制(十六进制) - + Paste 粘贴 - + PasteHex 粘贴(十六进制) - + Delete 删除 - + Find 查找 - + Goto 跳转 - + Fill 填充 - + MetaData 标注 - + BookMark 书签 - + Untitled 未命名 - + Not allowed operation in non-UI thread 该操作在非 UI 线程非法 @@ -2298,7 +2298,7 @@ - + PluginInfo 插件信息 @@ -2315,7 +2315,7 @@ - + DevExtInfo 设备插件信息 @@ -2341,88 +2341,88 @@ - + Plugin 插件 - + ID ID - + Name 名称 - + License 协议 - + Author 作者 - + Vendor 厂家 - - + + Version 版本 - + SelectAll 全选 - + SelectEnable - + SelectDisable - + SelectClear - + DiscardChanges - + Dependencies - + PUID - + Comment 说明 - + NoPluginLoaded - + URL 网址 @@ -2430,187 +2430,186 @@ PluginSystem - + LoadingPlugin 加载插件中: - - - + + + InvalidPluginBrokenInfo 加载插件失败:损坏的插件数据 - - + PluginBlockByManager - + AppClosingCanceled: 程序关闭被取消: - + - PluginID: - 插件 ID: - + FoundDrvPluginCount 总计发现设备拓展插件数目: - + PluginManagerNeedSingleton - - - + + + ErrLoadPluginSDKVersion 插件加载失败:非法插件 SDK 版本! - + ErrLoadPluginNoName 插件加载失败:非法插件名称! - - - + + + ErrLoadInitPlugin 插件加载失败:初始化插件失败! - + HexExtNeedSingleton - + PluginName : 插件名: - + PluginAuthor : 插件作者: - + PluginWidgetRegister 注册插件对象中…… - + ExtPluginAuthor : 设备拓展插件作者: - + ExtPluginWidgetRegister 设备拓展注册插件对象中…… - + ErrLoadInitExtPlugin 设备拓展插件加载失败:初始化插件失败! - + ChooseFile 选择文件 - - + + Error 错误 - + FileNotExist 文件不存在! - + FilePermission 因文件权限无法继续! - + EmptyNameDockWidget: 空的贴边组件名: - + InvalidNameDockWidget: 无效贴边组件名: - + InvalidNullDockWidget: 无效空贴边组件: - + Not allowed operation in non-UI thread 该操作在非 UI 线程非法 - + UnexpectedUndoCmdPushDetected - + UnsafePluginDir 不安全的插件目录,请将插件目录设置为仅管理员账户可写 - - - + + + InvalidPluginID 加载插件失败:非法插件标识符 - + InvalidDupPlugin 加载插件失败:重复的插件标识符 - + FoundPluginCount 总计发现插件数目: - + PluginLoadingFailedSummary 有依赖插件加载失败总结 - + - Dependencies: - 依赖: - + PUID: 插件唯一标志符: - + Version: 版本: - + PluginLoadingFinished 加载插件完毕! @@ -5452,15 +5451,6 @@ 纯文本 - - WingAngel - - - - RegisterScriptFnUnSupportedTypes: - 因脚本函数含有未支持的类型而注册失败: - - WingAngelAPI diff --git a/lang/zh_TW/winghex_zh_TW.ts b/lang/zh_TW/winghex_zh_TW.ts index dd094ac..c7d4fb4 100644 --- a/lang/zh_TW/winghex_zh_TW.ts +++ b/lang/zh_TW/winghex_zh_TW.ts @@ -450,72 +450,72 @@ EditorView - + Cut 剪切 - + CutHex 剪切(十六進制) - + Copy 複製 - + CopyHex 複製(十六進制) - + Paste 粘貼 - + PasteHex 粘貼(十六進制) - + Delete 刪除 - + Find 查找 - + Goto 跳轉 - + Fill 填充 - + MetaData 標注 - + BookMark 書簽 - + Untitled 未命名 - + Not allowed operation in non-UI thread 該操作在非 UI 線程非法 @@ -2298,7 +2298,7 @@ - + PluginInfo 插件資訊 @@ -2315,7 +2315,7 @@ - + DevExtInfo 設備插件資訊 @@ -2341,88 +2341,88 @@ - + Plugin 插件 - + ID ID - + Name 名稱 - + License 協議 - + Author 作者 - + Vendor 廠家 - - + + Version 版本 - + SelectAll 全選 - + SelectEnable - + SelectDisable - + SelectClear - + DiscardChanges - + Dependencies - + PUID - + Comment 說明 - + NoPluginLoaded - + URL 網址 @@ -2430,187 +2430,186 @@ PluginSystem - + LoadingPlugin 加載插件中: - - - + + + InvalidPluginBrokenInfo 加載插件失敗:損壞的插件數據 - - + PluginBlockByManager - + AppClosingCanceled: 程式關閉被取消: - + - PluginID: - 插件 ID: - + FoundDrvPluginCount 總計發現設備拓展插件數目: - + PluginManagerNeedSingleton - - - + + + ErrLoadPluginSDKVersion 插件加載失敗:非法插件 SDK 版本! - + ErrLoadPluginNoName 插件加載失敗:非法插件名稱! - - - + + + ErrLoadInitPlugin 插件加載失敗:初始化插件失敗! - + HexExtNeedSingleton - + PluginName : 插件名: - + PluginAuthor : 插件作者: - + PluginWidgetRegister 註冊插件對象中…… - + ExtPluginAuthor : 設備拓展插件作者: - + ExtPluginWidgetRegister 設備拓展註冊插件對象中…… - + ErrLoadInitExtPlugin 設備拓展插件加載失敗:初始化插件失敗! - + ChooseFile 選擇檔 - - + + Error 錯誤 - + FileNotExist 檔不存在! - + FilePermission 因檔許可權無法繼續! - + EmptyNameDockWidget: 空的貼邊組件名: - + InvalidNameDockWidget: 無效貼邊組件名: - + InvalidNullDockWidget: 無效空貼邊組件: - + Not allowed operation in non-UI thread 該操作在非 UI 線程非法 - + UnexpectedUndoCmdPushDetected - + UnsafePluginDir 不安全的插件目錄,請將插件目錄設置為僅管理員帳戶可寫 - - - + + + InvalidPluginID 加載插件失敗:非法插件識別字 - + InvalidDupPlugin 加載插件失敗:重複的插件識別字 - + FoundPluginCount 總計發現插件數目: - + PluginLoadingFailedSummary 有依賴插件加載失敗總結 - + - Dependencies: - 依賴: - + PUID: 插件唯一標誌符: - + Version: 版本: - + PluginLoadingFinished 加載插件完畢! @@ -5452,15 +5451,6 @@ 純文字 - - WingAngel - - - - RegisterScriptFnUnSupportedTypes: - 因腳本函數含有未支持的類型而註冊失敗: - - WingAngelAPI diff --git a/src/class/aspreprocesser.cpp b/src/class/aspreprocesser.cpp index 283b069..a0f6822 100644 --- a/src/class/aspreprocesser.cpp +++ b/src/class/aspreprocesser.cpp @@ -953,7 +953,7 @@ void AsPreprocesser::overwriteCode(QByteArray &modifiedScript, int start, int AsPreprocesser::getLineCount(const QByteArray &modifiedScript, int pos) const { - pos = qBound(0, pos, int(modifiedScript.size())); + pos = qBound(0, pos, qsizetype(modifiedScript.size())); return std::count_if(modifiedScript.begin(), std::next(modifiedScript.begin(), pos), [](char ch) -> bool { return ch == '\n'; }) + diff --git a/src/class/pluginsystem.cpp b/src/class/pluginsystem.cpp index 380ba62..abb4417 100644 --- a/src/class/pluginsystem.cpp +++ b/src/class/pluginsystem.cpp @@ -513,14 +513,66 @@ bool PluginSystem::invokeServiceImpl(const QObject *sender, const QString &puid, return false; } - auto r = - std::find_if(_loadedplgs.begin(), _loadedplgs.end(), - [=](IWingPlugin *plg) { return getPUID(plg) == puid; }); - if (r == _loadedplgs.end()) { + QObject *obj = nullptr; + if (puid.compare(QStringLiteral("[MAN]"), Qt::CaseInsensitive) == 0) { + obj = _manager; + } else if (puid.compare(QStringLiteral("[HEXE]"), Qt::CaseInsensitive) == + 0) { + obj = _hexExt; + } else { + QString rpuid; + auto question = puid.indexOf('?'); + enum { None, MustPlugin, MustExt } State = None; + + if (question >= 0) { + rpuid = puid.sliced(0, question); + auto equest = puid.sliced(question + 1); + if (equest.compare(QStringLiteral("[PLG]"))) { + State = MustPlugin; + } else if (equest.compare(QStringLiteral("[EXT]"))) { + State = MustExt; + } else { + // warn and ignored + Logger::warning( + QStringLiteral("[PluginSystem::invokeServiceImpl] Cannot " + "parsing filter: '%1'") + .arg(equest)); + } + } else { + rpuid = puid; + State = None; + } + auto r = std::find_if( + _loadedplgs.begin(), _loadedplgs.end(), + [=](IWingPlugin *plg) { return getPUID(plg) == rpuid; }); + + if (r == _loadedplgs.end()) { + return false; + } + + auto rc = *r; + switch (State) { + case None: + obj = rc; + break; + case MustPlugin: + if (qobject_cast(rc)) { + obj = rc; + } + break; + case MustExt: + if (qobject_cast(rc)) { + obj = rc; + } + break; + } + } + + if (obj == nullptr) { + qCritical("[PluginSystem::invokeServiceImpl] Null caller"); return false; } - auto obj = *r; auto meta = obj->metaObject(); Qt::ConnectionType c; @@ -532,6 +584,7 @@ bool PluginSystem::invokeServiceImpl(const QObject *sender, const QString &puid, std::tie(method, c, paramCount, parameters, typeNames, metaTypes) = infos; if (parameters == nullptr || typeNames == nullptr || metaTypes == nullptr) { + qCritical("[PluginSystem::invokeServiceImpl] Invalid calling info"); return false; } @@ -561,6 +614,7 @@ bool PluginSystem::invokeServiceImpl(const QObject *sender, const QString &puid, } if (!m.isValid()) { + qCritical("[PluginSystem::invokeServiceImpl] Invalid MetaMethod"); return false; } @@ -610,7 +664,37 @@ bool PluginSystem::invokeServiceImpl(const QObject *sender, const QString &puid, m, obj, c, nparamCount, nparameters.data(), ntypeNames.data(), nmetaTypes.data()); - // errror report + auto cstr = [](QMetaMethodInvoker::InvokeFailReason r) -> const char * { + switch (r) { + case QMetaMethodInvoker::InvokeFailReason::ReturnTypeMismatch: + return "ReturnTypeMismatch"; + case QMetaMethodInvoker::InvokeFailReason::DeadLockDetected: + return "DeadLockDetected"; + case QMetaMethodInvoker::InvokeFailReason::CallViaVirtualFailed: + return "CallViaVirtualFailed"; + case QMetaMethodInvoker::InvokeFailReason::ConstructorCallOnObject: + return "ConstructorCallOnObject"; + case QMetaMethodInvoker::InvokeFailReason::ConstructorCallWithoutResult: + return "ConstructorCallWithoutResult"; + case QMetaMethodInvoker::InvokeFailReason::ConstructorCallFailed: + return "ConstructorCallFailed"; + case QMetaMethodInvoker::InvokeFailReason::CouldNotQueueParameter: + return "CouldNotQueueParameter"; + case QMetaMethodInvoker::InvokeFailReason::None: + return "None"; + case QMetaMethodInvoker::InvokeFailReason::TooFewArguments: + return "TooFewArguments"; + case QMetaMethodInvoker::InvokeFailReason::FormalParameterMismatch: + return "FormalParameterMismatch"; + break; + } + return ""; + }; + + if (ret != QMetaMethodInvoker::InvokeFailReason::None) { + qCritical("[PluginSystem::invokeServiceImpl] MetaCall failed: %s (%d)", + cstr(ret), ret); + } return ret == QMetaMethodInvoker::InvokeFailReason::None; } @@ -2612,7 +2696,11 @@ IWingGeneric *PluginSystem::__createParamContext(const QObject *sender, bool PluginSystem::passByFailedGuard(const QObject *sender, const char *func, const QVariantList ¶ms) { if (_manager && sender != _manager) { - return !_manager->enterGuard(sender->metaObject(), func, params); + auto ret = !_manager->enterGuard(sender->metaObject(), func, params); + if (ret) { + qCritical("[GuardBlock] '%s' was blocked", func); + } + return ret; } return false; } @@ -3280,9 +3368,9 @@ std::optional PluginSystem::loadPlugin(const QFileInfo &fileinfo, } else if constexpr (std::is_same_v) { _blkdevs[BlockReason::BlockedByManager].append(m); } - Logger::critical(QStringLiteral("{ ") + m.id + - QStringLiteral(" } ") + - tr("PluginBlockByManager")); + qCritical( + "[PluginSystem::loadPlugin] '%s' was blocked by manager", + qUtf8Printable(m.id)); return std::nullopt; } } diff --git a/src/class/wingangel.cpp b/src/class/wingangel.cpp index bef5c87..6fdc9e0 100644 --- a/src/class/wingangel.cpp +++ b/src/class/wingangel.cpp @@ -239,8 +239,10 @@ WingAngel::registerGlobalFunction(uint retMetaType, const ScriptFn &fn, const QVector> ¶ms) { auto sig = getScriptFnSig(retMetaType, fn, fnName, params); if (sig.isEmpty()) { - Logger::critical(tr("RegisterScriptFnUnSupportedTypes:") + _plgsess + - QStringLiteral("::") + fnName); + Logger::critical(QStringLiteral("[WingAngel::registerGlobalFunction] " + "getScriptFnSig failed (") + + _plgsess + QStringLiteral("::") + fnName + + QStringLiteral(")")); return WingHex::asRetCodes::asINVALID_ARG; } @@ -250,8 +252,13 @@ WingAngel::registerGlobalFunction(uint retMetaType, const ScriptFn &fn, sig.toUtf8(), asFUNCTION(WingAngelAPI::script_call), asECallConvTypes::asCALL_GENERIC); + auto minfo = QMetaEnum::fromType(); + if (ret < 0) { - // TODO + Logger::critical( + QStringLiteral("[WingAngel::registerGlobalFunction] " + "RegisterGlobalFunction '%1' failed (%2)") + .arg(sig, minfo.valueToKey(ret))); return returnValue(ret); } @@ -264,6 +271,9 @@ WingAngel::registerGlobalFunction(uint retMetaType, const ScriptFn &fn, f->SetUserData(reinterpret_cast(id), AsUserDataType::UserData_PluginFn); } else { + Logger::critical(QStringLiteral("[WingAngel::registerGlobalFunction] " + "'%1' GetFunctionById failed") + .arg(sig)); return WingHex::asRetCodes::asINVALID_ARG; } @@ -281,8 +291,8 @@ WingHex::asRetCodes WingAngel::registerGlobalFunction(const QString &decl, const WingHex::UNSAFE_SCFNPTR &fn) { if (decl.isEmpty()) { - Logger::critical(tr("RegisterScriptFnUnSupportedTypes:") + _plgsess + - QStringLiteral("::") + decl); + Logger::critical(QStringLiteral( + "[WingAngel::registerGlobalFunction] Empty declaration")); return WingHex::asRetCodes::asINVALID_ARG; } @@ -292,8 +302,12 @@ WingAngel::registerGlobalFunction(const QString &decl, decl.toUtf8(), asFUNCTION(WingAngelAPI::script_unsafe_call), asECallConvTypes::asCALL_GENERIC); + auto minfo = QMetaEnum::fromType(); if (ret < 0) { - // TODO + Logger::critical( + QStringLiteral("[WingAngel::registerGlobalFunction] " + "RegisterGlobalFunction '%1' failed (%2)") + .arg(decl, minfo.valueToKey(ret))); return returnValue(ret); } @@ -306,6 +320,9 @@ WingAngel::registerGlobalFunction(const QString &decl, f->SetUserData(reinterpret_cast(id), AsUserDataType::UserData_PluginFn); } else { + Logger::critical(QStringLiteral("[WingAngel::registerGlobalFunction] " + "'%1' GetFunctionById failed") + .arg(decl)); return WingHex::asRetCodes::asINVALID_ARG; } @@ -319,8 +336,8 @@ void WingAngel::registerScriptMarco(const QString &marco) { static auto sep = QStringLiteral("_"); _scriptMarcos.append(sep + _plgsess + sep + marco + sep); } else { - - // TODO + Logger::critical(QStringLiteral( + "[WingAngel::registerScriptMarco] isValidIdentifier failed")); } } diff --git a/src/control/editorview.cpp b/src/control/editorview.cpp index 95c38f9..b5cfe5d 100644 --- a/src/control/editorview.cpp +++ b/src/control/editorview.cpp @@ -63,7 +63,9 @@ EditorView::EditorView(QWidget *parent) hexLayout->setContentsMargins(0, 0, 0, 0); m_hex = new QHexView(this); _context = new EditorViewContext(m_hex); - if (PluginSystem::instance().hexEditorExtension()) { + auto &plgsys = PluginSystem::instance(); + auto hexExt = plgsys.hexEditorExtension(); + if (hexExt) { connect(m_hex, &QHexView::onPaintCustomEventBegin, this, [this]() { auto m = PluginSystem::instance().hexEditorExtension()->contentMargins( @@ -74,6 +76,7 @@ EditorView::EditorView(QWidget *parent) m.setBottom(qMax(0, m.bottom())); m_hex->viewport()->setContentsMargins(m); }); + m_hex->setDisableInternalPaint(hexExt->disableOriginPainting()); } connect(m_hex, &QHexView::onPaintCustomEvent, this, [this](int XOffset, qsizetype firstVisible, qsizetype begin, @@ -920,7 +923,7 @@ bool EditorView::checkThreadAff() { return true; } -bool EditorView::existsServiceHost(QObject *caller, const QString &puid) { +bool EditorView::existsServiceHost(const QObject *caller, const QString &puid) { return PluginSystem::instance().existsServiceHost(caller, puid); } @@ -933,21 +936,21 @@ bool EditorView::invokeServiceImpl(const QObject *sender, const QString &puid, return PluginSystem::instance().invokeServiceImpl(this, puid, infos); } -QString EditorView::currentDocFilename(QObject *caller) { +QString EditorView::currentDocFilename(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return {}; } return fileName(); } -bool EditorView::isReadOnly(QObject *caller) { +bool EditorView::isReadOnly(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return false; } return m_hex->isReadOnly(); } -bool EditorView::isInsertionMode(QObject *caller) { +bool EditorView::isInsertionMode(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -955,77 +958,77 @@ bool EditorView::isInsertionMode(QObject *caller) { QHexCursor::InsertionMode::InsertMode; } -bool EditorView::isKeepSize(QObject *caller) { +bool EditorView::isKeepSize(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return false; } return m_hex->isKeepSize(); } -bool EditorView::isLocked(QObject *caller) { +bool EditorView::isLocked(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return false; } return m_hex->isLocked(); } -qsizetype EditorView::documentLines(QObject *caller) { +qsizetype EditorView::documentLines(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return 0; } return m_hex->documentLines(); } -qsizetype EditorView::documentBytes(QObject *caller) { +qsizetype EditorView::documentBytes(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return 0; } return m_hex->documentBytes(); } -qsizetype EditorView::currentRow(QObject *caller) { +qsizetype EditorView::currentRow(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return 0; } return m_hex->currentRow(); } -qsizetype EditorView::currentColumn(QObject *caller) { +qsizetype EditorView::currentColumn(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return 0; } return m_hex->currentColumn(); } -qsizetype EditorView::currentOffset(QObject *caller) { +qsizetype EditorView::currentOffset(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return 0; } return m_hex->currentOffset(); } -qsizetype EditorView::selectedLength(QObject *caller) { +qsizetype EditorView::selectedLength(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return 0; } return m_hex->cursor()->currentSelectionLength(); } -QByteArray EditorView::selectedBytes(QObject *caller, qsizetype index) { +QByteArray EditorView::selectedBytes(const QObject *caller, qsizetype index) { if (checkErrAndReport(caller, __func__)) { return {}; } return m_hex->selectedBytes(index); } -QByteArrayList EditorView::selectionBytes(QObject *caller) { +QByteArrayList EditorView::selectionBytes(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return {}; } return m_hex->selectedBytes(); } -qsizetype EditorView::selectionLength(QObject *caller, qsizetype index) { +qsizetype EditorView::selectionLength(const QObject *caller, qsizetype index) { if (checkErrAndReport(caller, __func__)) { return 0; } @@ -1038,119 +1041,119 @@ qsizetype EditorView::selectionLength(QObject *caller, qsizetype index) { return 0; } -qsizetype EditorView::selectionCount(QObject *caller) { +qsizetype EditorView::selectionCount(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return 0; } return m_hex->selectionCount(); } -bool EditorView::stringVisible(QObject *caller) { +bool EditorView::stringVisible(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return false; } return m_hex->asciiVisible(); } -bool EditorView::addressVisible(QObject *caller) { +bool EditorView::addressVisible(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return false; } return m_hex->addressVisible(); } -bool EditorView::headerVisible(QObject *caller) { +bool EditorView::headerVisible(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return false; } return m_hex->headerVisible(); } -quintptr EditorView::addressBase(QObject *caller) { +quintptr EditorView::addressBase(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return 0; } return m_hex->addressBase(); } -bool EditorView::isModified(QObject *caller) { +bool EditorView::isModified(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return false; } return !m_hex->isSaved(); } -qint8 EditorView::readInt8(QObject *caller, qsizetype offset) { +qint8 EditorView::readInt8(const QObject *caller, qsizetype offset) { if (checkErrAndReport(caller, __func__)) { return 0; } return readBasicTypeContent(this, offset, _rwlock); } -qint16 EditorView::readInt16(QObject *caller, qsizetype offset) { +qint16 EditorView::readInt16(const QObject *caller, qsizetype offset) { if (checkErrAndReport(caller, __func__)) { return 0; } return readBasicTypeContent(this, offset, _rwlock); } -qint32 EditorView::readInt32(QObject *caller, qsizetype offset) { +qint32 EditorView::readInt32(const QObject *caller, qsizetype offset) { if (checkErrAndReport(caller, __func__)) { return 0; } return readBasicTypeContent(this, offset, _rwlock); } -qint64 EditorView::readInt64(QObject *caller, qsizetype offset) { +qint64 EditorView::readInt64(const QObject *caller, qsizetype offset) { if (checkErrAndReport(caller, __func__)) { return 0; } return readBasicTypeContent(this, offset, _rwlock); } -quint8 EditorView::readUInt8(QObject *caller, qsizetype offset) { +quint8 EditorView::readUInt8(const QObject *caller, qsizetype offset) { if (checkErrAndReport(caller, __func__)) { return 0; } return readBasicTypeContent(this, offset, _rwlock); } -quint16 EditorView::readUInt16(QObject *caller, qsizetype offset) { +quint16 EditorView::readUInt16(const QObject *caller, qsizetype offset) { if (checkErrAndReport(caller, __func__)) { return 0; } return readBasicTypeContent(this, offset, _rwlock); } -quint32 EditorView::readUInt32(QObject *caller, qsizetype offset) { +quint32 EditorView::readUInt32(const QObject *caller, qsizetype offset) { if (checkErrAndReport(caller, __func__)) { return 0; } return readBasicTypeContent(this, offset, _rwlock); } -quint64 EditorView::readUInt64(QObject *caller, qsizetype offset) { +quint64 EditorView::readUInt64(const QObject *caller, qsizetype offset) { if (checkErrAndReport(caller, __func__)) { return 0; } return readBasicTypeContent(this, offset, _rwlock); } -float EditorView::readFloat(QObject *caller, qsizetype offset) { +float EditorView::readFloat(const QObject *caller, qsizetype offset) { if (checkErrAndReport(caller, __func__)) { return 0; } return readBasicTypeContent(this, offset, _rwlock); } -double EditorView::readDouble(QObject *caller, qsizetype offset) { +double EditorView::readDouble(const QObject *caller, qsizetype offset) { if (checkErrAndReport(caller, __func__)) { return 0; } return readBasicTypeContent(this, offset, _rwlock); } -QString EditorView::readString(QObject *caller, qsizetype offset, +QString EditorView::readString(const QObject *caller, qsizetype offset, const QString &encoding) { if (checkErrAndReport(caller, __func__)) { return {}; @@ -1169,7 +1172,7 @@ QString EditorView::readString(QObject *caller, qsizetype offset, return Utilities::decodingString(buffer, encoding); } -QByteArray EditorView::readBytes(QObject *caller, qsizetype offset, +QByteArray EditorView::readBytes(const QObject *caller, qsizetype offset, qsizetype count) { if (checkErrAndReport(caller, __func__)) { return {}; @@ -1180,7 +1183,7 @@ QByteArray EditorView::readBytes(QObject *caller, qsizetype offset, return ret; } -qsizetype EditorView::findNext(QObject *caller, qsizetype begin, +qsizetype EditorView::findNext(const QObject *caller, qsizetype begin, const QByteArray &ba) { if (checkErrAndReport(caller, __func__)) { return -1; @@ -1188,7 +1191,7 @@ qsizetype EditorView::findNext(QObject *caller, qsizetype begin, return m_hex->document()->findNext(begin, ba); } -qsizetype EditorView::findPrevious(QObject *caller, qsizetype begin, +qsizetype EditorView::findPrevious(const QObject *caller, qsizetype begin, const QByteArray &ba) { if (checkErrAndReport(caller, __func__)) { return -1; @@ -1196,21 +1199,21 @@ qsizetype EditorView::findPrevious(QObject *caller, qsizetype begin, return m_hex->document()->findPrevious(begin, ba); } -QString EditorView::bookMarkComment(QObject *caller, qsizetype pos) { +QString EditorView::bookMarkComment(const QObject *caller, qsizetype pos) { if (checkErrAndReport(caller, __func__)) { return {}; } return m_hex->document()->bookMark(pos); } -bool EditorView::existBookMark(QObject *caller, qsizetype pos) { +bool EditorView::existBookMark(const QObject *caller, qsizetype pos) { if (checkErrAndReport(caller, __func__)) { return false; } return m_hex->document()->existBookMark(pos); } -bool EditorView::setLockedFile(QObject *caller, bool b) { +bool EditorView::setLockedFile(const QObject *caller, bool b) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1221,7 +1224,7 @@ bool EditorView::setLockedFile(QObject *caller, bool b) { return m_hex->setLockedFile(b); } -bool EditorView::setKeepSize(QObject *caller, bool b) { +bool EditorView::setKeepSize(const QObject *caller, bool b) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1231,7 +1234,7 @@ bool EditorView::setKeepSize(QObject *caller, bool b) { return m_hex->setKeepSize(b); } -bool EditorView::setStringVisible(QObject *caller, bool b) { +bool EditorView::setStringVisible(const QObject *caller, bool b) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1242,7 +1245,7 @@ bool EditorView::setStringVisible(QObject *caller, bool b) { return true; } -bool EditorView::setAddressVisible(QObject *caller, bool b) { +bool EditorView::setAddressVisible(const QObject *caller, bool b) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1253,7 +1256,7 @@ bool EditorView::setAddressVisible(QObject *caller, bool b) { return true; } -bool EditorView::setHeaderVisible(QObject *caller, bool b) { +bool EditorView::setHeaderVisible(const QObject *caller, bool b) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1264,7 +1267,7 @@ bool EditorView::setHeaderVisible(QObject *caller, bool b) { return true; } -bool EditorView::setAddressBase(QObject *caller, quintptr base) { +bool EditorView::setAddressBase(const QObject *caller, quintptr base) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1275,7 +1278,7 @@ bool EditorView::setAddressBase(QObject *caller, quintptr base) { return true; } -bool EditorView::beginMarco(QObject *caller, const QString &txt) { +bool EditorView::beginMarco(const QObject *caller, const QString &txt) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1283,7 +1286,7 @@ bool EditorView::beginMarco(QObject *caller, const QString &txt) { return true; } -bool EditorView::endMarco(QObject *caller) { +bool EditorView::endMarco(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1291,77 +1294,87 @@ bool EditorView::endMarco(QObject *caller) { return true; } -bool EditorView::writeInt8(QObject *caller, qsizetype offset, qint8 value) { +bool EditorView::writeInt8(const QObject *caller, qsizetype offset, + qint8 value) { if (checkErrAndReport(caller, __func__)) { return false; } return writeBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::writeInt16(QObject *caller, qsizetype offset, qint16 value) { +bool EditorView::writeInt16(const QObject *caller, qsizetype offset, + qint16 value) { if (checkErrAndReport(caller, __func__)) { return false; } return writeBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::writeInt32(QObject *caller, qsizetype offset, qint32 value) { +bool EditorView::writeInt32(const QObject *caller, qsizetype offset, + qint32 value) { if (checkErrAndReport(caller, __func__)) { return false; } return writeBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::writeInt64(QObject *caller, qsizetype offset, qint64 value) { +bool EditorView::writeInt64(const QObject *caller, qsizetype offset, + qint64 value) { if (checkErrAndReport(caller, __func__)) { return false; } return writeBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::writeUInt8(QObject *caller, qsizetype offset, quint8 value) { +bool EditorView::writeUInt8(const QObject *caller, qsizetype offset, + quint8 value) { if (checkErrAndReport(caller, __func__)) { return false; } return writeBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::writeUInt16(QObject *caller, qsizetype offset, quint16 value) { +bool EditorView::writeUInt16(const QObject *caller, qsizetype offset, + quint16 value) { if (checkErrAndReport(caller, __func__)) { return false; } return writeBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::writeUInt32(QObject *caller, qsizetype offset, quint32 value) { +bool EditorView::writeUInt32(const QObject *caller, qsizetype offset, + quint32 value) { if (checkErrAndReport(caller, __func__)) { return false; } return writeBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::writeUInt64(QObject *caller, qsizetype offset, quint64 value) { +bool EditorView::writeUInt64(const QObject *caller, qsizetype offset, + quint64 value) { if (checkErrAndReport(caller, __func__)) { return false; } return writeBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::writeFloat(QObject *caller, qsizetype offset, float value) { +bool EditorView::writeFloat(const QObject *caller, qsizetype offset, + float value) { if (checkErrAndReport(caller, __func__)) { return false; } return writeBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::writeDouble(QObject *caller, qsizetype offset, double value) { +bool EditorView::writeDouble(const QObject *caller, qsizetype offset, + double value) { if (checkErrAndReport(caller, __func__)) { return false; } return writeBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::writeString(QObject *caller, qsizetype offset, +bool EditorView::writeString(const QObject *caller, qsizetype offset, const QString &value, const QString &encoding) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1379,7 +1392,7 @@ bool EditorView::writeString(QObject *caller, qsizetype offset, return false; } -bool EditorView::writeBytes(QObject *caller, qsizetype offset, +bool EditorView::writeBytes(const QObject *caller, qsizetype offset, const QByteArray &data) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1395,42 +1408,47 @@ bool EditorView::writeBytes(QObject *caller, qsizetype offset, return false; } -bool EditorView::insertInt8(QObject *caller, qsizetype offset, qint8 value) { +bool EditorView::insertInt8(const QObject *caller, qsizetype offset, + qint8 value) { if (checkErrAndReport(caller, __func__)) { return false; } return insertBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::insertInt16(QObject *caller, qsizetype offset, qint16 value) { +bool EditorView::insertInt16(const QObject *caller, qsizetype offset, + qint16 value) { if (checkErrAndReport(caller, __func__)) { return false; } return insertBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::insertInt32(QObject *caller, qsizetype offset, qint32 value) { +bool EditorView::insertInt32(const QObject *caller, qsizetype offset, + qint32 value) { if (checkErrAndReport(caller, __func__)) { return false; } return insertBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::insertInt64(QObject *caller, qsizetype offset, qint64 value) { +bool EditorView::insertInt64(const QObject *caller, qsizetype offset, + qint64 value) { if (checkErrAndReport(caller, __func__)) { return false; } return insertBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::insertUInt8(QObject *caller, qsizetype offset, quint8 value) { +bool EditorView::insertUInt8(const QObject *caller, qsizetype offset, + quint8 value) { if (checkErrAndReport(caller, __func__)) { return false; } return insertBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::insertUInt16(QObject *caller, qsizetype offset, +bool EditorView::insertUInt16(const QObject *caller, qsizetype offset, quint16 value) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1438,7 +1456,7 @@ bool EditorView::insertUInt16(QObject *caller, qsizetype offset, return insertBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::insertUInt32(QObject *caller, qsizetype offset, +bool EditorView::insertUInt32(const QObject *caller, qsizetype offset, quint32 value) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1446,7 +1464,7 @@ bool EditorView::insertUInt32(QObject *caller, qsizetype offset, return insertBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::insertUInt64(QObject *caller, qsizetype offset, +bool EditorView::insertUInt64(const QObject *caller, qsizetype offset, quint64 value) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1454,21 +1472,23 @@ bool EditorView::insertUInt64(QObject *caller, qsizetype offset, return insertBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::insertFloat(QObject *caller, qsizetype offset, float value) { +bool EditorView::insertFloat(const QObject *caller, qsizetype offset, + float value) { if (checkErrAndReport(caller, __func__)) { return false; } return insertBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::insertDouble(QObject *caller, qsizetype offset, double value) { +bool EditorView::insertDouble(const QObject *caller, qsizetype offset, + double value) { if (checkErrAndReport(caller, __func__)) { return false; } return insertBasicTypeContent(this, offset, value, nullptr, _rwlock); } -bool EditorView::insertString(QObject *caller, qsizetype offset, +bool EditorView::insertString(const QObject *caller, qsizetype offset, const QString &value, const QString &encoding) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1487,7 +1507,7 @@ bool EditorView::insertString(QObject *caller, qsizetype offset, return false; } -bool EditorView::insertBytes(QObject *caller, qsizetype offset, +bool EditorView::insertBytes(const QObject *caller, qsizetype offset, const QByteArray &data) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1504,77 +1524,77 @@ bool EditorView::insertBytes(QObject *caller, qsizetype offset, return false; } -bool EditorView::appendInt8(QObject *caller, qint8 value) { +bool EditorView::appendInt8(const QObject *caller, qint8 value) { if (checkErrAndReport(caller, __func__)) { return false; } return appendBasicTypeContent(this, value, nullptr, _rwlock); } -bool EditorView::appendInt16(QObject *caller, qint16 value) { +bool EditorView::appendInt16(const QObject *caller, qint16 value) { if (checkErrAndReport(caller, __func__)) { return false; } return appendBasicTypeContent(this, value, nullptr, _rwlock); } -bool EditorView::appendInt32(QObject *caller, qint32 value) { +bool EditorView::appendInt32(const QObject *caller, qint32 value) { if (checkErrAndReport(caller, __func__)) { return false; } return appendBasicTypeContent(this, value, nullptr, _rwlock); } -bool EditorView::appendInt64(QObject *caller, qint64 value) { +bool EditorView::appendInt64(const QObject *caller, qint64 value) { if (checkErrAndReport(caller, __func__)) { return false; } return appendBasicTypeContent(this, value, nullptr, _rwlock); } -bool EditorView::appendUInt8(QObject *caller, quint8 value) { +bool EditorView::appendUInt8(const QObject *caller, quint8 value) { if (checkErrAndReport(caller, __func__)) { return false; } return appendBasicTypeContent(this, value, nullptr, _rwlock); } -bool EditorView::appendUInt16(QObject *caller, quint16 value) { +bool EditorView::appendUInt16(const QObject *caller, quint16 value) { if (checkErrAndReport(caller, __func__)) { return false; } return appendBasicTypeContent(this, value, nullptr, _rwlock); } -bool EditorView::appendUInt32(QObject *caller, quint32 value) { +bool EditorView::appendUInt32(const QObject *caller, quint32 value) { if (checkErrAndReport(caller, __func__)) { return false; } return appendBasicTypeContent(this, value, nullptr, _rwlock); } -bool EditorView::appendUInt64(QObject *caller, quint64 value) { +bool EditorView::appendUInt64(const QObject *caller, quint64 value) { if (checkErrAndReport(caller, __func__)) { return false; } return appendBasicTypeContent(this, value, nullptr, _rwlock); } -bool EditorView::appendFloat(QObject *caller, float value) { +bool EditorView::appendFloat(const QObject *caller, float value) { if (checkErrAndReport(caller, __func__)) { return false; } return appendBasicTypeContent(this, value, nullptr, _rwlock); } -bool EditorView::appendDouble(QObject *caller, double value) { +bool EditorView::appendDouble(const QObject *caller, double value) { if (checkErrAndReport(caller, __func__)) { return false; } return appendBasicTypeContent(this, value, nullptr, _rwlock); } -bool EditorView::appendString(QObject *caller, const QString &value, +bool EditorView::appendString(const QObject *caller, const QString &value, const QString &encoding) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1593,7 +1613,7 @@ bool EditorView::appendString(QObject *caller, const QString &value, return false; } -bool EditorView::appendBytes(QObject *caller, const QByteArray &data) { +bool EditorView::appendBytes(const QObject *caller, const QByteArray &data) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1609,7 +1629,8 @@ bool EditorView::appendBytes(QObject *caller, const QByteArray &data) { return false; } -bool EditorView::removeBytes(QObject *caller, qsizetype offset, qsizetype len) { +bool EditorView::removeBytes(const QObject *caller, qsizetype offset, + qsizetype len) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1625,7 +1646,7 @@ bool EditorView::removeBytes(QObject *caller, qsizetype offset, qsizetype len) { return false; } -bool EditorView::moveTo(QObject *caller, qsizetype line, qsizetype column, +bool EditorView::moveTo(const QObject *caller, qsizetype line, qsizetype column, int nibbleindex, bool clearSelection) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1637,7 +1658,7 @@ bool EditorView::moveTo(QObject *caller, qsizetype line, qsizetype column, return true; } -bool EditorView::moveTo(QObject *caller, qsizetype offset, +bool EditorView::moveTo(const QObject *caller, qsizetype offset, bool clearSelection) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1649,8 +1670,8 @@ bool EditorView::moveTo(QObject *caller, qsizetype offset, return true; } -bool EditorView::select(QObject *caller, qsizetype offset, qsizetype length, - SelectionMode mode) { +bool EditorView::select(const QObject *caller, qsizetype offset, + qsizetype length, SelectionMode mode) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1675,7 +1696,7 @@ bool EditorView::select(QObject *caller, qsizetype offset, qsizetype length, return true; } -bool EditorView::setInsertionMode(QObject *caller, bool isinsert) { +bool EditorView::setInsertionMode(const QObject *caller, bool isinsert) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1687,9 +1708,9 @@ bool EditorView::setInsertionMode(QObject *caller, bool isinsert) { return true; } -bool EditorView::metadata(QObject *caller, qsizetype begin, qsizetype length, - const QColor &fgcolor, const QColor &bgcolor, - const QString &comment) { +bool EditorView::metadata(const QObject *caller, qsizetype begin, + qsizetype length, const QColor &fgcolor, + const QColor &bgcolor, const QString &comment) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1708,7 +1729,7 @@ bool EditorView::metadata(QObject *caller, qsizetype begin, qsizetype length, return false; } -bool EditorView::removeMetadata(QObject *caller, qsizetype offset) { +bool EditorView::removeMetadata(const QObject *caller, qsizetype offset) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1725,7 +1746,7 @@ bool EditorView::removeMetadata(QObject *caller, qsizetype offset) { return false; } -bool EditorView::clearMetadata(QObject *caller) { +bool EditorView::clearMetadata(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1742,7 +1763,7 @@ bool EditorView::clearMetadata(QObject *caller) { return false; } -bool EditorView::setMetaVisible(QObject *caller, bool b) { +bool EditorView::setMetaVisible(const QObject *caller, bool b) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1756,7 +1777,7 @@ bool EditorView::setMetaVisible(QObject *caller, bool b) { return true; } -bool EditorView::setMetafgVisible(QObject *caller, bool b) { +bool EditorView::setMetafgVisible(const QObject *caller, bool b) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1768,7 +1789,7 @@ bool EditorView::setMetafgVisible(QObject *caller, bool b) { return true; } -bool EditorView::setMetabgVisible(QObject *caller, bool b) { +bool EditorView::setMetabgVisible(const QObject *caller, bool b) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1780,7 +1801,7 @@ bool EditorView::setMetabgVisible(QObject *caller, bool b) { return true; } -bool EditorView::setMetaCommentVisible(QObject *caller, bool b) { +bool EditorView::setMetaCommentVisible(const QObject *caller, bool b) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1792,7 +1813,7 @@ bool EditorView::setMetaCommentVisible(QObject *caller, bool b) { return true; } -bool EditorView::addBookMark(QObject *caller, qsizetype pos, +bool EditorView::addBookMark(const QObject *caller, qsizetype pos, const QString &comment) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1809,7 +1830,7 @@ bool EditorView::addBookMark(QObject *caller, qsizetype pos, return false; } -bool EditorView::modBookMark(QObject *caller, qsizetype pos, +bool EditorView::modBookMark(const QObject *caller, qsizetype pos, const QString &comment) { if (checkErrAndReport(caller, __func__)) { return false; @@ -1826,7 +1847,7 @@ bool EditorView::modBookMark(QObject *caller, qsizetype pos, return false; } -bool EditorView::removeBookMark(QObject *caller, qsizetype pos) { +bool EditorView::removeBookMark(const QObject *caller, qsizetype pos) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1842,7 +1863,7 @@ bool EditorView::removeBookMark(QObject *caller, qsizetype pos) { return false; } -bool EditorView::clearBookMark(QObject *caller) { +bool EditorView::clearBookMark(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return false; } @@ -1858,20 +1879,20 @@ bool EditorView::clearBookMark(QObject *caller) { return false; } -void EditorView::toast(QObject *caller, const QPixmap &icon, +void EditorView::toast(const QObject *caller, const QPixmap &icon, const QString &message) { PluginSystem::instance().toast(caller, icon, message); } -void EditorView::logTrace(QObject *caller, const QString &message) { +void EditorView::logTrace(const QObject *caller, const QString &message) { PluginSystem::instance().logTrace(caller, message); } -void EditorView::logDebug(QObject *caller, const QString &message) { +void EditorView::logDebug(const QObject *caller, const QString &message) { PluginSystem::instance().logDebug(caller, message); } -HexPosition EditorView::selectionEnd(QObject *caller, qsizetype index) { +HexPosition EditorView::selectionEnd(const QObject *caller, qsizetype index) { if (checkErrAndReport(caller, __func__)) { return {}; } @@ -1890,7 +1911,7 @@ HexPosition EditorView::selectionEnd(QObject *caller, qsizetype index) { return pos; } -HexPosition EditorView::selectionStart(QObject *caller, qsizetype index) { +HexPosition EditorView::selectionStart(const QObject *caller, qsizetype index) { if (checkErrAndReport(caller, __func__)) { return {}; } @@ -1909,7 +1930,7 @@ HexPosition EditorView::selectionStart(QObject *caller, qsizetype index) { return pos; } -HexPosition EditorView::currentPos(QObject *caller) { +HexPosition EditorView::currentPos(const QObject *caller) { if (checkErrAndReport(caller, __func__)) { return {}; } @@ -1924,33 +1945,33 @@ HexPosition EditorView::currentPos(QObject *caller) { return pos; } -void EditorView::logWarn(QObject *caller, const QString &message) { +void EditorView::logWarn(const QObject *caller, const QString &message) { PluginSystem::instance().logWarn(caller, message); } -void EditorView::logError(QObject *caller, const QString &message) { +void EditorView::logError(const QObject *caller, const QString &message) { PluginSystem::instance().logError(caller, message); } -void EditorView::logInfo(QObject *caller, const QString &message) { +void EditorView::logInfo(const QObject *caller, const QString &message) { PluginSystem::instance().logInfo(caller, message); } -bool EditorView::raiseDockWidget(QObject *caller, QWidget *w) { +bool EditorView::raiseDockWidget(const QObject *caller, QWidget *w) { return PluginSystem::instance().raiseDockWidget(caller, w); } -QDialog *EditorView::createDialog(QObject *caller, QWidget *content) { +QDialog *EditorView::createDialog(const QObject *caller, QWidget *content) { return PluginSystem::instance().createDialog(caller, content); } -void EditorView::msgAboutQt(QObject *caller, QWidget *parent, +void EditorView::msgAboutQt(const QObject *caller, QWidget *parent, const QString &title) { return PluginSystem::instance().msgAboutQt(caller, parent, title); } QMessageBox::StandardButton -EditorView::msgInformation(QObject *caller, QWidget *parent, +EditorView::msgInformation(const QObject *caller, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { @@ -1959,8 +1980,8 @@ EditorView::msgInformation(QObject *caller, QWidget *parent, } QMessageBox::StandardButton -EditorView::msgQuestion(QObject *caller, QWidget *parent, const QString &title, - const QString &text, +EditorView::msgQuestion(const QObject *caller, QWidget *parent, + const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { return PluginSystem::instance().msgQuestion(caller, parent, title, text, @@ -1968,8 +1989,8 @@ EditorView::msgQuestion(QObject *caller, QWidget *parent, const QString &title, } QMessageBox::StandardButton -EditorView::msgWarning(QObject *caller, QWidget *parent, const QString &title, - const QString &text, +EditorView::msgWarning(const QObject *caller, QWidget *parent, + const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { return PluginSystem::instance().msgWarning(caller, parent, title, text, @@ -1977,29 +1998,29 @@ EditorView::msgWarning(QObject *caller, QWidget *parent, const QString &title, } QMessageBox::StandardButton -EditorView::msgCritical(QObject *caller, QWidget *parent, const QString &title, - const QString &text, +EditorView::msgCritical(const QObject *caller, QWidget *parent, + const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { return PluginSystem::instance().msgCritical(caller, parent, title, text, buttons, defaultButton); } -void EditorView::msgAbout(QObject *caller, QWidget *parent, +void EditorView::msgAbout(const QObject *caller, QWidget *parent, const QString &title, const QString &text) { return PluginSystem::instance().msgAbout(caller, parent, title, text); } QMessageBox::StandardButton -EditorView::msgbox(QObject *caller, QWidget *parent, QMessageBox::Icon icon, - const QString &title, const QString &text, - QMessageBox::StandardButtons buttons, +EditorView::msgbox(const QObject *caller, QWidget *parent, + QMessageBox::Icon icon, const QString &title, + const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { return PluginSystem::instance().msgbox(caller, parent, icon, title, text, buttons, defaultButton); } -QString EditorView::dlgGetText(QObject *caller, QWidget *parent, +QString EditorView::dlgGetText(const QObject *caller, QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode echo, const QString &text, bool *ok, @@ -2008,7 +2029,7 @@ QString EditorView::dlgGetText(QObject *caller, QWidget *parent, caller, parent, title, label, echo, text, ok, inputMethodHints); } -QString EditorView::dlgGetMultiLineText(QObject *caller, QWidget *parent, +QString EditorView::dlgGetMultiLineText(const QObject *caller, QWidget *parent, const QString &title, const QString &label, const QString &text, bool *ok, @@ -2017,7 +2038,7 @@ QString EditorView::dlgGetMultiLineText(QObject *caller, QWidget *parent, caller, parent, title, label, text, ok, inputMethodHints); } -QString EditorView::dlgGetItem(QObject *caller, QWidget *parent, +QString EditorView::dlgGetItem(const QObject *caller, QWidget *parent, const QString &title, const QString &label, const QStringList &items, int current, bool editable, bool *ok, @@ -2027,14 +2048,14 @@ QString EditorView::dlgGetItem(QObject *caller, QWidget *parent, inputMethodHints); } -int EditorView::dlgGetInt(QObject *caller, QWidget *parent, +int EditorView::dlgGetInt(const QObject *caller, QWidget *parent, const QString &title, const QString &label, int value, int minValue, int maxValue, int step, bool *ok) { return PluginSystem::instance().dlgGetInt( caller, parent, title, label, value, minValue, maxValue, step, ok); } -double EditorView::dlgGetDouble(QObject *caller, QWidget *parent, +double EditorView::dlgGetDouble(const QObject *caller, QWidget *parent, const QString &title, const QString &label, double value, double minValue, double maxValue, int decimals, bool *ok, double step) { @@ -2043,7 +2064,8 @@ double EditorView::dlgGetDouble(QObject *caller, QWidget *parent, decimals, ok, step); } -QString EditorView::dlgGetExistingDirectory(QObject *caller, QWidget *parent, +QString EditorView::dlgGetExistingDirectory(const QObject *caller, + QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options) { @@ -2051,7 +2073,7 @@ QString EditorView::dlgGetExistingDirectory(QObject *caller, QWidget *parent, caller, parent, caption, dir, options); } -QString EditorView::dlgGetOpenFileName(QObject *caller, QWidget *parent, +QString EditorView::dlgGetOpenFileName(const QObject *caller, QWidget *parent, const QString &caption, const QString &dir, const QString &filter, @@ -2061,17 +2083,16 @@ QString EditorView::dlgGetOpenFileName(QObject *caller, QWidget *parent, caller, parent, caption, dir, filter, selectedFilter, options); } -QStringList EditorView::dlgGetOpenFileNames(QObject *caller, QWidget *parent, - const QString &caption, - const QString &dir, - const QString &filter, - QString *selectedFilter, - QFileDialog::Options options) { +QStringList +EditorView::dlgGetOpenFileNames(const QObject *caller, QWidget *parent, + const QString &caption, const QString &dir, + const QString &filter, QString *selectedFilter, + QFileDialog::Options options) { return PluginSystem::instance().dlgGetOpenFileNames( caller, parent, caption, dir, filter, selectedFilter, options); } -QString EditorView::dlgGetSaveFileName(QObject *caller, QWidget *parent, +QString EditorView::dlgGetSaveFileName(const QObject *caller, QWidget *parent, const QString &caption, const QString &dir, const QString &filter, @@ -2081,12 +2102,12 @@ QString EditorView::dlgGetSaveFileName(QObject *caller, QWidget *parent, caller, parent, caption, dir, filter, selectedFilter, options); } -QColor EditorView::dlgGetColor(QObject *caller, const QString &caption, +QColor EditorView::dlgGetColor(const QObject *caller, const QString &caption, QWidget *parent) { return PluginSystem::instance().dlgGetColor(caller, caption, parent); } -AppTheme EditorView::currentAppTheme(QObject *caller) { +AppTheme EditorView::currentAppTheme(const QObject *caller) { return PluginSystem::instance().currentAppTheme(caller); } diff --git a/src/control/editorview.h b/src/control/editorview.h index f09e067..94fe59f 100644 --- a/src/control/editorview.h +++ b/src/control/editorview.h @@ -236,260 +236,278 @@ private: bool checkThreadAff(); private slots: - WING_API bool existsServiceHost(QObject *caller, const QString &puid); + WING_API bool existsServiceHost(const QObject *caller, const QString &puid); WING_API bool invokeServiceImpl(const QObject *sender, const QString &puid, const WingHex::MetaCallInfo &infos); private slots: - WING_API QString currentDocFilename(QObject *caller); + WING_API QString currentDocFilename(const QObject *caller); // document - WING_API bool isReadOnly(QObject *caller); - WING_API bool isInsertionMode(QObject *caller); - WING_API bool isKeepSize(QObject *caller); - WING_API bool isLocked(QObject *caller); - WING_API qsizetype documentLines(QObject *caller); - WING_API qsizetype documentBytes(QObject *caller); - WING_API WingHex::HexPosition currentPos(QObject *caller); - WING_API qsizetype currentRow(QObject *caller); - WING_API qsizetype currentColumn(QObject *caller); - WING_API qsizetype currentOffset(QObject *caller); - WING_API qsizetype selectedLength(QObject *caller); + WING_API bool isReadOnly(const QObject *caller); + WING_API bool isInsertionMode(const QObject *caller); + WING_API bool isKeepSize(const QObject *caller); + WING_API bool isLocked(const QObject *caller); + WING_API qsizetype documentLines(const QObject *caller); + WING_API qsizetype documentBytes(const QObject *caller); + WING_API WingHex::HexPosition currentPos(const QObject *caller); + WING_API qsizetype currentRow(const QObject *caller); + WING_API qsizetype currentColumn(const QObject *caller); + WING_API qsizetype currentOffset(const QObject *caller); + WING_API qsizetype selectedLength(const QObject *caller); - WING_API QByteArray selectedBytes(QObject *caller, qsizetype index); - WING_API QByteArrayList selectionBytes(QObject *caller); + WING_API QByteArray selectedBytes(const QObject *caller, qsizetype index); + WING_API QByteArrayList selectionBytes(const QObject *caller); - WING_API WingHex::HexPosition selectionStart(QObject *caller, + WING_API WingHex::HexPosition selectionStart(const QObject *caller, qsizetype index); - WING_API WingHex::HexPosition selectionEnd(QObject *caller, + WING_API WingHex::HexPosition selectionEnd(const QObject *caller, qsizetype index); - WING_API qsizetype selectionLength(QObject *caller, qsizetype index); - WING_API qsizetype selectionCount(QObject *caller); + WING_API qsizetype selectionLength(const QObject *caller, qsizetype index); + WING_API qsizetype selectionCount(const QObject *caller); - WING_API bool stringVisible(QObject *caller); - WING_API bool addressVisible(QObject *caller); - WING_API bool headerVisible(QObject *caller); - WING_API quintptr addressBase(QObject *caller); - WING_API bool isModified(QObject *caller); + WING_API bool stringVisible(const QObject *caller); + WING_API bool addressVisible(const QObject *caller); + WING_API bool headerVisible(const QObject *caller); + WING_API quintptr addressBase(const QObject *caller); + WING_API bool isModified(const QObject *caller); - WING_API qint8 readInt8(QObject *caller, qsizetype offset); - WING_API qint16 readInt16(QObject *caller, qsizetype offset); - WING_API qint32 readInt32(QObject *caller, qsizetype offset); - WING_API qint64 readInt64(QObject *caller, qsizetype offset); - WING_API quint8 readUInt8(QObject *caller, qsizetype offset); - WING_API quint16 readUInt16(QObject *caller, qsizetype offset); - WING_API quint32 readUInt32(QObject *caller, qsizetype offset); - WING_API quint64 readUInt64(QObject *caller, qsizetype offset); - WING_API float readFloat(QObject *caller, qsizetype offset); - WING_API double readDouble(QObject *caller, qsizetype offset); - WING_API QString readString(QObject *caller, qsizetype offset, + WING_API qint8 readInt8(const QObject *caller, qsizetype offset); + WING_API qint16 readInt16(const QObject *caller, qsizetype offset); + WING_API qint32 readInt32(const QObject *caller, qsizetype offset); + WING_API qint64 readInt64(const QObject *caller, qsizetype offset); + WING_API quint8 readUInt8(const QObject *caller, qsizetype offset); + WING_API quint16 readUInt16(const QObject *caller, qsizetype offset); + WING_API quint32 readUInt32(const QObject *caller, qsizetype offset); + WING_API quint64 readUInt64(const QObject *caller, qsizetype offset); + WING_API float readFloat(const QObject *caller, qsizetype offset); + WING_API double readDouble(const QObject *caller, qsizetype offset); + WING_API QString readString(const QObject *caller, qsizetype offset, const QString &encoding); - WING_API QByteArray readBytes(QObject *caller, qsizetype offset, + WING_API QByteArray readBytes(const QObject *caller, qsizetype offset, qsizetype count); - WING_API qsizetype findNext(QObject *caller, qsizetype begin, + WING_API qsizetype findNext(const QObject *caller, qsizetype begin, const QByteArray &ba); - WING_API qsizetype findPrevious(QObject *caller, qsizetype begin, + WING_API qsizetype findPrevious(const QObject *caller, qsizetype begin, const QByteArray &ba); - WING_API QString bookMarkComment(QObject *caller, qsizetype pos); - WING_API bool existBookMark(QObject *caller, qsizetype pos); + WING_API QString bookMarkComment(const QObject *caller, qsizetype pos); + WING_API bool existBookMark(const QObject *caller, qsizetype pos); - WING_API bool setLockedFile(QObject *caller, bool b); - WING_API bool setKeepSize(QObject *caller, bool b); - WING_API bool setStringVisible(QObject *caller, bool b); - WING_API bool setAddressVisible(QObject *caller, bool b); - WING_API bool setHeaderVisible(QObject *caller, bool b); - WING_API bool setAddressBase(QObject *caller, quintptr base); + WING_API bool setLockedFile(const QObject *caller, bool b); + WING_API bool setKeepSize(const QObject *caller, bool b); + WING_API bool setStringVisible(const QObject *caller, bool b); + WING_API bool setAddressVisible(const QObject *caller, bool b); + WING_API bool setHeaderVisible(const QObject *caller, bool b); + WING_API bool setAddressBase(const QObject *caller, quintptr base); - WING_API bool beginMarco(QObject *caller, const QString &txt); - bool endMarco(QObject *caller); + WING_API bool beginMarco(const QObject *caller, const QString &txt); + bool endMarco(const QObject *caller); - WING_API bool writeInt8(QObject *caller, qsizetype offset, qint8 value); - WING_API bool writeInt16(QObject *caller, qsizetype offset, qint16 value); - WING_API bool writeInt32(QObject *caller, qsizetype offset, qint32 value); - WING_API bool writeInt64(QObject *caller, qsizetype offset, qint64 value); - WING_API bool writeUInt8(QObject *caller, qsizetype offset, quint8 value); - WING_API bool writeUInt16(QObject *caller, qsizetype offset, quint16 value); - WING_API bool writeUInt32(QObject *caller, qsizetype offset, quint32 value); - WING_API bool writeUInt64(QObject *caller, qsizetype offset, quint64 value); - WING_API bool writeFloat(QObject *caller, qsizetype offset, float value); - WING_API bool writeDouble(QObject *caller, qsizetype offset, double value); + WING_API bool writeInt8(const QObject *caller, qsizetype offset, + qint8 value); + WING_API bool writeInt16(const QObject *caller, qsizetype offset, + qint16 value); + WING_API bool writeInt32(const QObject *caller, qsizetype offset, + qint32 value); + WING_API bool writeInt64(const QObject *caller, qsizetype offset, + qint64 value); + WING_API bool writeUInt8(const QObject *caller, qsizetype offset, + quint8 value); + WING_API bool writeUInt16(const QObject *caller, qsizetype offset, + quint16 value); + WING_API bool writeUInt32(const QObject *caller, qsizetype offset, + quint32 value); + WING_API bool writeUInt64(const QObject *caller, qsizetype offset, + quint64 value); + WING_API bool writeFloat(const QObject *caller, qsizetype offset, + float value); + WING_API bool writeDouble(const QObject *caller, qsizetype offset, + double value); WING_API - bool writeString(QObject *caller, qsizetype offset, const QString &value, - const QString &encoding); - WING_API bool writeBytes(QObject *caller, qsizetype offset, + bool writeString(const QObject *caller, qsizetype offset, + const QString &value, const QString &encoding); + WING_API bool writeBytes(const QObject *caller, qsizetype offset, const QByteArray &data); - WING_API bool insertInt8(QObject *caller, qsizetype offset, qint8 value); - WING_API bool insertInt16(QObject *caller, qsizetype offset, qint16 value); - WING_API bool insertInt32(QObject *caller, qsizetype offset, qint32 value); - WING_API bool insertInt64(QObject *caller, qsizetype offset, qint64 value); - WING_API bool insertUInt8(QObject *caller, qsizetype offset, quint8 value); + WING_API bool insertInt8(const QObject *caller, qsizetype offset, + qint8 value); + WING_API bool insertInt16(const QObject *caller, qsizetype offset, + qint16 value); + WING_API bool insertInt32(const QObject *caller, qsizetype offset, + qint32 value); + WING_API bool insertInt64(const QObject *caller, qsizetype offset, + qint64 value); + WING_API bool insertUInt8(const QObject *caller, qsizetype offset, + quint8 value); WING_API - bool insertUInt16(QObject *caller, qsizetype offset, quint16 value); + bool insertUInt16(const QObject *caller, qsizetype offset, quint16 value); WING_API - bool insertUInt32(QObject *caller, qsizetype offset, quint32 value); - WING_API bool insertUInt64(QObject *caller, qsizetype offset, + bool insertUInt32(const QObject *caller, qsizetype offset, quint32 value); + WING_API bool insertUInt64(const QObject *caller, qsizetype offset, quint64 value); - WING_API bool insertFloat(QObject *caller, qsizetype offset, float value); - WING_API bool insertDouble(QObject *caller, qsizetype offset, double value); - WING_API bool insertString(QObject *caller, qsizetype offset, + WING_API bool insertFloat(const QObject *caller, qsizetype offset, + float value); + WING_API bool insertDouble(const QObject *caller, qsizetype offset, + double value); + WING_API bool insertString(const QObject *caller, qsizetype offset, const QString &value, const QString &encoding); - WING_API bool insertBytes(QObject *caller, qsizetype offset, + WING_API bool insertBytes(const QObject *caller, qsizetype offset, const QByteArray &data); - WING_API bool appendInt8(QObject *caller, qint8 value); - WING_API bool appendInt16(QObject *caller, qint16 value); - WING_API bool appendInt32(QObject *caller, qint32 value); - WING_API bool appendInt64(QObject *caller, qint64 value); - WING_API bool appendUInt8(QObject *caller, quint8 value); - WING_API bool appendUInt16(QObject *caller, quint16 value); - WING_API bool appendUInt32(QObject *caller, quint32 value); - WING_API bool appendUInt64(QObject *caller, quint64 value); - WING_API bool appendFloat(QObject *caller, float value); - WING_API bool appendDouble(QObject *caller, double value); - WING_API bool appendString(QObject *caller, const QString &value, + WING_API bool appendInt8(const QObject *caller, qint8 value); + WING_API bool appendInt16(const QObject *caller, qint16 value); + WING_API bool appendInt32(const QObject *caller, qint32 value); + WING_API bool appendInt64(const QObject *caller, qint64 value); + WING_API bool appendUInt8(const QObject *caller, quint8 value); + WING_API bool appendUInt16(const QObject *caller, quint16 value); + WING_API bool appendUInt32(const QObject *caller, quint32 value); + WING_API bool appendUInt64(const QObject *caller, quint64 value); + WING_API bool appendFloat(const QObject *caller, float value); + WING_API bool appendDouble(const QObject *caller, double value); + WING_API bool appendString(const QObject *caller, const QString &value, const QString &encoding); - WING_API bool appendBytes(QObject *caller, const QByteArray &data); + WING_API bool appendBytes(const QObject *caller, const QByteArray &data); - WING_API bool removeBytes(QObject *caller, qsizetype offset, qsizetype len); + WING_API bool removeBytes(const QObject *caller, qsizetype offset, + qsizetype len); // cursor - WING_API bool moveTo(QObject *caller, qsizetype line, qsizetype column, - int nibbleindex, bool clearSelection); - WING_API bool moveTo(QObject *caller, qsizetype offset, + WING_API bool moveTo(const QObject *caller, qsizetype line, + qsizetype column, int nibbleindex, bool clearSelection); - WING_API bool select(QObject *caller, qsizetype offset, qsizetype length, - WingHex::SelectionMode mode); - WING_API bool setInsertionMode(QObject *caller, bool isinsert); + WING_API bool moveTo(const QObject *caller, qsizetype offset, + bool clearSelection); + WING_API bool select(const QObject *caller, qsizetype offset, + qsizetype length, WingHex::SelectionMode mode); + WING_API bool setInsertionMode(const QObject *caller, bool isinsert); // metadata - WING_API bool metadata(QObject *caller, qsizetype begin, qsizetype length, - const QColor &fgcolor, const QColor &bgcolor, - const QString &comment); + WING_API bool metadata(const QObject *caller, qsizetype begin, + qsizetype length, const QColor &fgcolor, + const QColor &bgcolor, const QString &comment); - WING_API bool removeMetadata(QObject *caller, qsizetype offset); - WING_API bool clearMetadata(QObject *caller); - WING_API bool setMetaVisible(QObject *caller, bool b); - WING_API bool setMetafgVisible(QObject *caller, bool b); - WING_API bool setMetabgVisible(QObject *caller, bool b); - WING_API bool setMetaCommentVisible(QObject *caller, bool b); + WING_API bool removeMetadata(const QObject *caller, qsizetype offset); + WING_API bool clearMetadata(const QObject *caller); + WING_API bool setMetaVisible(const QObject *caller, bool b); + WING_API bool setMetafgVisible(const QObject *caller, bool b); + WING_API bool setMetabgVisible(const QObject *caller, bool b); + WING_API bool setMetaCommentVisible(const QObject *caller, bool b); // bookmark - WING_API bool addBookMark(QObject *caller, qsizetype pos, + WING_API bool addBookMark(const QObject *caller, qsizetype pos, const QString &comment); - WING_API bool modBookMark(QObject *caller, qsizetype pos, + WING_API bool modBookMark(const QObject *caller, qsizetype pos, const QString &comment); - WING_API bool removeBookMark(QObject *caller, qsizetype pos); - WING_API bool clearBookMark(QObject *caller); + WING_API bool removeBookMark(const QObject *caller, qsizetype pos); + WING_API bool clearBookMark(const QObject *caller); private slots: - WING_API void toast(QObject *caller, const QPixmap &icon, + WING_API void toast(const QObject *caller, const QPixmap &icon, const QString &message); - WING_API void logTrace(QObject *caller, const QString &message); - WING_API void logDebug(QObject *caller, const QString &message); - WING_API void logWarn(QObject *caller, const QString &message); - WING_API void logError(QObject *caller, const QString &message); - WING_API void logInfo(QObject *caller, const QString &message); + WING_API void logTrace(const QObject *caller, const QString &message); + WING_API void logDebug(const QObject *caller, const QString &message); + WING_API void logWarn(const QObject *caller, const QString &message); + WING_API void logError(const QObject *caller, const QString &message); + WING_API void logInfo(const QObject *caller, const QString &message); - WING_API bool raiseDockWidget(QObject *caller, QWidget *w); + WING_API bool raiseDockWidget(const QObject *caller, QWidget *w); // theme - WING_API WingHex::AppTheme currentAppTheme(QObject *caller); + WING_API WingHex::AppTheme currentAppTheme(const QObject *caller); // not available for AngelScript // only for plugin UI extenstion - WING_API QDialog *createDialog(QObject *caller, QWidget *content); + WING_API QDialog *createDialog(const QObject *caller, QWidget *content); private slots: - WING_API void msgAboutQt(QObject *caller, QWidget *parent = nullptr, + WING_API void msgAboutQt(const QObject *caller, QWidget *parent = nullptr, const QString &title = QString()); WING_API QMessageBox::StandardButton msgInformation( - QObject *caller, QWidget *parent, const QString &title, + const QObject *caller, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); WING_API QMessageBox::StandardButton msgQuestion( - QObject *caller, QWidget *parent, const QString &title, + const QObject *caller, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No), QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); WING_API QMessageBox::StandardButton msgWarning( - QObject *caller, QWidget *parent, const QString &title, + const QObject *caller, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); WING_API QMessageBox::StandardButton msgCritical( - QObject *caller, QWidget *parent, const QString &title, + const QObject *caller, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); - WING_API void msgAbout(QObject *caller, QWidget *parent, + WING_API void msgAbout(const QObject *caller, QWidget *parent, const QString &title, const QString &text); WING_API QMessageBox::StandardButton - msgbox(QObject *caller, QWidget *parent, QMessageBox::Icon icon, + msgbox(const QObject *caller, QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::NoButton, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); private slots: - WING_API QString dlgGetText(QObject *caller, QWidget *parent, + WING_API QString dlgGetText(const QObject *caller, QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode echo, const QString &text, bool *ok, Qt::InputMethodHints inputMethodHints); - WING_API QString dlgGetMultiLineText(QObject *caller, QWidget *parent, + WING_API QString dlgGetMultiLineText(const QObject *caller, QWidget *parent, const QString &title, const QString &label, const QString &text, bool *ok, Qt::InputMethodHints inputMethodHints); - WING_API QString dlgGetItem(QObject *caller, QWidget *parent, + WING_API QString dlgGetItem(const QObject *caller, QWidget *parent, const QString &title, const QString &label, const QStringList &items, int current, bool editable, bool *ok, Qt::InputMethodHints inputMethodHints); - WING_API int dlgGetInt(QObject *caller, QWidget *parent, + WING_API int dlgGetInt(const QObject *caller, QWidget *parent, const QString &title, const QString &label, int value, int minValue, int maxValue, int step, bool *ok); - WING_API double dlgGetDouble(QObject *caller, QWidget *parent, + WING_API double dlgGetDouble(const QObject *caller, QWidget *parent, const QString &title, const QString &label, double value, double minValue, double maxValue, int decimals, bool *ok, double step); private slots: - WING_API QString dlgGetExistingDirectory(QObject *caller, QWidget *parent, + WING_API QString dlgGetExistingDirectory(const QObject *caller, + QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options); - WING_API QString dlgGetOpenFileName(QObject *caller, QWidget *parent, + WING_API QString dlgGetOpenFileName(const QObject *caller, QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options); - WING_API QStringList dlgGetOpenFileNames(QObject *caller, QWidget *parent, - const QString &caption, - const QString &dir, - const QString &filter, - QString *selectedFilter, - QFileDialog::Options options); + WING_API QStringList dlgGetOpenFileNames( + const QObject *caller, QWidget *parent, const QString &caption, + const QString &dir, const QString &filter, QString *selectedFilter, + QFileDialog::Options options); - WING_API QString dlgGetSaveFileName(QObject *caller, QWidget *parent, + WING_API QString dlgGetSaveFileName(const QObject *caller, QWidget *parent, const QString &caption, const QString &dir, const QString &filter, @@ -497,7 +515,7 @@ private slots: QFileDialog::Options options); private slots: - WING_API QColor dlgGetColor(QObject *caller, const QString &caption, + WING_API QColor dlgGetColor(const QObject *caller, const QString &caption, QWidget *parent); private: diff --git a/src/dialog/settingdialog.cpp b/src/dialog/settingdialog.cpp index 350a431..94f793c 100644 --- a/src/dialog/settingdialog.cpp +++ b/src/dialog/settingdialog.cpp @@ -72,9 +72,9 @@ SettingDialog::SettingDialog(QWidget *parent) _dialog->setWindowTitle(this->windowTitle()); ui->btnRestore->setStyleSheet( - QStringLiteral("QToolButton::down-arrow { width:10px; height:10px; " + QStringLiteral("QToolButton::down-arrow {width:10px; height:10px; " "subcontrol-position:right center; " - "subcontrol-origin:content; left: -2px;")); + "subcontrol-origin:content; left: -2px;}")); auto menu = new QMenu(ui->btnRestore); auto a = menu->addAction(tr("Restore current")); connect(a, &QAction::triggered, this, [this]() {