fix(shot): add event log for OCR and scroll screenshot in toolbar#830
Merged
deepin-bot[bot] merged 1 commit intoApr 22, 2026
Merged
Conversation
- Add B4 event log when clicking OCR button or pressing Alt+O - Add B5 event log when clicking scroll screenshot button or pressing Alt+I bug: https://pms.uniontech.com/bug-view-358389.html https://pms.uniontech.com/bug-view-358387.html
deepin pr auto review这份代码 diff 主要是在 1. 代码逻辑与语法审查
2. 代码质量与可维护性
3. 代码性能
4. 代码安全
改进建议与重构代码建议将日志记录的逻辑提取为一个私有辅助函数,以消除重复代码并提高可维护性。 修改后的代码示例:// 在 main_window.h 的 MainWindow 类中声明私有辅助函数
private:
void logToolStartup(const QString &mode);
// 在 main_window.cpp 中实现
void MainWindow::logToolStartup(const QString &startupMode) {
// 使用常量或枚举代替魔法字符串 "1"
const int kDefaultMode = 1;
QJsonObject obj;
obj["tid"] = EventLogUtils::Start;
obj["version"] = QCoreApplication::applicationVersion();
obj["mode"] = kDefaultMode;
obj["startup_mode"] = startupMode;
EventLogUtils::get().writeLogs(obj);
}
// 修改后的 changeShotToolEvent 片段
void MainWindow::changeShotToolEvent(const QString &func)
{
qCDebug(dsrApp) << "MainWindow::changeShotToolEvent >> func: " << func;
if (func == "ocr") {
// 提取重复代码,传入具体的模式标识
logToolStartup("B4");
// 调起OCR识别界面, 传入截图路径
m_ocrInterface = new OcrInterface("com.deepin.Ocr", "/com/deepin/Ocr", QDBusConnection::sessionBus(), this);
int delayTime = 0;
// ... (其余代码保持不变) ...
} else if (func == "scrollShot") { // 点击滚动截图
logToolStartup("B5");
// 捕捉区域的固件不显示
drawDragPoint = false;
m_toolBar->hide();
// ... (其余代码保持不变) ...
}
// ...
}改进点总结:
|
lzwind
approved these changes
Apr 22, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Member
Author
|
/forcemerge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bug: https://pms.uniontech.com/bug-view-358389.html https://pms.uniontech.com/bug-view-358387.html