Skip to content

fix: AI screenshot actions should save to UOS AI assistant instead of…#756

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
dengzhongyuan365-dev:bug-fix-334287
Nov 17, 2025
Merged

fix: AI screenshot actions should save to UOS AI assistant instead of…#756
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
dengzhongyuan365-dev:bug-fix-334287

Conversation

@dengzhongyuan365-dev

Copy link
Copy Markdown
Member

… clipboard only

  • Modified mouseDblClickEF() to call saveScreenShot() when isHideToolBar is true in AI screenshot mode
  • Updated Enter key shortcuts (returnSC, enterSC) to use saveScreenShot() instead of saveScreenShotToClipboardOnly() in AI mode
  • Ensures screenshotSaved signal is triggered to emit CustomDone signal for UOS AI integration
  • Maintains backward compatibility for normal screenshot workflow and scrollshot functionality

This fix resolves the issue where AI screenshot Q&A feature incorrectly saved screenshots to clipboard only, now properly sends screenshots to UOS AI assistant input box as expected.

修复:AI截图操作应保存到UOS AI助手而非仅保存到剪贴板

  • 修改mouseDblClickEF()方法,在AI截图模式下(isHideToolBar为true时)调用saveScreenShot()
  • 更新Enter键快捷键(returnSC, enterSC),在AI模式下使用saveScreenShot()而非saveScreenShotToClipboardOnly()
  • 确保触发screenshotSaved信号以发送CustomDone信号给UOS AI集成
  • 保持对普通截图工作流程和滚动截图功能的向后兼容性

此修复解决了AI截图问答功能错误地仅将截图保存到剪贴板的问题,
现在能够正确地将截图发送到UOS AI助手输入框中。

bug: https://pms.uniontech.com/bug-view-334287.html

… clipboard only

- Modified mouseDblClickEF() to call saveScreenShot() when isHideToolBar is true in AI screenshot mode
- Updated Enter key shortcuts (returnSC, enterSC) to use saveScreenShot() instead of saveScreenShotToClipboardOnly() in AI mode
- Ensures screenshotSaved signal is triggered to emit CustomDone signal for UOS AI integration
- Maintains backward compatibility for normal screenshot workflow and scrollshot functionality

This fix resolves the issue where AI screenshot Q&A feature incorrectly saved screenshots to clipboard only,
now properly sends screenshots to UOS AI assistant input box as expected.

修复:AI截图操作应保存到UOS AI助手而非仅保存到剪贴板

- 修改mouseDblClickEF()方法,在AI截图模式下(isHideToolBar为true时)调用saveScreenShot()
- 更新Enter键快捷键(returnSC, enterSC),在AI模式下使用saveScreenShot()而非saveScreenShotToClipboardOnly()
- 确保触发screenshotSaved信号以发送CustomDone信号给UOS AI集成
- 保持对普通截图工作流程和滚动截图功能的向后兼容性

此修复解决了AI截图问答功能错误地仅将截图保存到剪贴板的问题,
现在能够正确地将截图发送到UOS AI助手输入框中。

bug: https://pms.uniontech.com/bug-view-334287.html
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我来对这段代码进行审查:

  1. 代码逻辑分析:
    这段代码主要处理截图保存的逻辑,涉及三种情况:
  • Return键快捷键处理
  • Enter键快捷键处理
  • 鼠标双击事件处理
    在每种情况下,都根据isHideToolBar的值来决定是调用saveScreenShot()还是saveScreenShotToClipboardOnly()。
  1. 代码质量问题:
  • 代码重复:三个地方都使用了相同的if-else逻辑,建议抽取成单独的函数
  • 命名规范:isHideToolBar应该遵循驼峰命名法,改为isHideToolBar或m_isHideToolBar更合适
  • 代码注释:缺少对isHideToolBar变量作用的说明
  1. 性能问题:
    当前代码性能没有明显问题,因为只是简单的条件判断。

  2. 安全问题:
    代码安全性良好,没有发现明显的安全隐患。

改进建议:

// 添加私有辅助方法
void MainWindow::handleSaveAction()
{
    if (status::shot == m_functionType) {
        if (isHideToolBar) {
            saveScreenShot();
        } else {
            saveScreenShotToClipboardOnly();
        }
    }
}

void MainWindow::initSaveShortcut()
{
    // Return键处理
    connect(returnSC, &QShortcut::activated, this, [this] {
        if (status::shot == m_functionType || status::scrollshot == m_functionType) {
            qCDebug(dsrApp) << "shortcut : returnSC (key: enter)";
            handleSaveAction();
        }
    });

    // Enter键处理
    connect(enterSC, &QShortcut::activated, this, [this] {
        if (status::shot == m_functionType || status::scrollshot == m_functionType) {
            qCDebug(dsrApp) << "shortcut : enterSC (key: enter)";
            handleSaveAction();
        }
        if (status::record == m_functionType && Utils::isWaylandMode)
            m_showButtons->showContentButtons(KEY_ENTER);
    });
}

int MainWindow::mouseDblClickEF(QMouseEvent *mouseEvent, bool &needRepaint)
{
    if (mouseEvent->button() == Qt::LeftButton) {
        if (status::shot == m_functionType) {
            qCDebug(dsrApp) << "双击鼠标按钮!进行截图保存!";
            handleSaveAction();
        }
    }
    return 1;
}

改进后的代码:

  1. 将重复的逻辑抽取到handleSaveAction()方法中,提高代码复用性
  2. 使用[this]捕获列表代替[=],避免不必要的值拷贝
  3. 保持了原有的功能不变,但代码结构更清晰
  4. 更容易维护,如果需要修改保存逻辑,只需修改一处

其他建议:

  1. 建议添加isHideToolBar变量的注释,说明其具体作用
  2. 可以考虑将status::shot == m_functionType的判断也移入handleSaveAction()中
  3. 如果这个功能会被频繁调用,可以考虑将handleSaveAction()声明为inline函数

@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dengzhongyuan365-dev

Copy link
Copy Markdown
Member Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot deepin-bot Bot merged commit 2608839 into linuxdeepin:develop/snipe Nov 17, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants