Skip to content

feat(treeland): Enhance screen recording support for TreeLand environ…#762

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
dengzhongyuan365-dev:treelandcommit1
Nov 27, 2025
Merged

feat(treeland): Enhance screen recording support for TreeLand environ…#762
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
dengzhongyuan365-dev:treelandcommit1

Conversation

@dengzhongyuan365-dev

Copy link
Copy Markdown
Member

…ment

  • Implement the treelandRecord function to handle video recording using the ext-image-copy-capture protocol.
  • Update RecordProcess to manage recording lifecycle for TreeLand, including starting and stopping recordings.
  • Add checks for protocol availability and integrate event handling for recording status.
  • Modify utility functions to accommodate both Wayland and TreeLand modes, ensuring proper event handling and input passthrough.
  • Update UI components to reflect the new recording capabilities in TreeLand.
  • This enhancement expands the screen recording functionality to support the TreeLand environment, improving user experience and feature accessibility.

特性(treeland): 增强对 TreeLand 环境的屏幕录制支持

  • 实现 treelandRecord 函数,使用 ext-image-copy-capture 协议来处理视频录制。
  • 更新 RecordProcess 以管理 TreeLand 的录制生命周期,包括启动和停止录制。
  • 添加协议可用性检查,并集成对录制状态的事件处理。
  • 修改工具函数以适应 Wayland 和 TreeLand 两种模式,确保正确的事件处理和输入透传。
  • 更新用户界面(UI)组件,以反映 TreeLand 中的新录制功能。
  • 本次增强将屏幕录制功能扩展到 TreeLand 环境,从而改善用户体验和功能可访问性。

…ment

- Implement the `treelandRecord` function to handle video recording using the ext-image-copy-capture protocol.
- Update `RecordProcess` to manage recording lifecycle for TreeLand, including starting and stopping recordings.
- Add checks for protocol availability and integrate event handling for recording status.
- Modify utility functions to accommodate both Wayland and TreeLand modes, ensuring proper event handling and input passthrough.
- Update UI components to reflect the new recording capabilities in TreeLand.
- This enhancement expands the screen recording functionality to support the TreeLand environment, improving user experience and feature accessibility.

特性(treeland): 增强对 TreeLand 环境的屏幕录制支持

- 实现 `treelandRecord` 函数,使用 ext-image-copy-capture 协议来处理视频录制。
- 更新 `RecordProcess` 以管理 TreeLand 的录制生命周期,包括启动和停止录制。
- 添加协议可用性检查,并集成对录制状态的事件处理。
- 修改工具函数以适应 Wayland 和 TreeLand 两种模式,确保正确的事件处理和输入透传。
- 更新用户界面(UI)组件,以反映 TreeLand 中的新录制功能。
- 本次增强将屏幕录制功能扩展到 TreeLand 环境,从而改善用户体验和功能可访问性。
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我来对这个代码变更进行详细审查:

  1. 代码结构和逻辑改进:

优点:

  • 将TreeLand环境检测从isWaylandProtocol()中分离,新增isTreelandEnvironment()函数,使代码逻辑更清晰
  • 为TreeLand环境添加了专门的录屏功能支持,使用ext-image-copy-capture协议
  • 添加了新的快捷键Ctrl+Alt+R用于停止录屏,提高了用户体验

需要改进的地方:

  • treelandRecord()函数中的错误处理可以更加完善,比如添加重试机制
  • 建议将TreeLand相关的配置参数提取为常量,如超时时间1000ms
  1. 代码质量改进:

优点:

  • 添加了详细的日志输出,便于调试
  • 使用了QEventLoop进行异步等待,代码结构合理

需要改进的地方:

  • treelandRecord()函数过长,建议拆分成更小的函数
  • 部分重复代码可以提取为公共函数,如环境检测逻辑
  1. 性能优化建议:
  • 在treelandRecord()中,可以考虑缓存QScreen实例,避免重复获取
  • ExtCaptureRecorder的创建和销毁可以优化为对象池模式
  • 可以考虑延迟初始化TreeLand相关组件
  1. 安全性改进:
  • 建议在treelandRecord()中添加对savePath的合法性检查
  • 录制过程中应该添加权限验证
  • 建议对ExtCaptureRecorder的通信添加加密机制
  1. 具体改进建议:
// 1. 添加配置常量
namespace Config {
    constexpr int PROTOCOL_WAIT_TIMEOUT = 1000; // ms
    constexpr int MAX_RETRY_COUNT = 3;
}

// 2. 改进treelandRecord函数
void RecordProcess::treelandRecord()
{
    qCDebug(dsrApp) << "Starting TreeLand recording...";
    
    if (!validateSavePath(savePath)) {
        qCCritical(dsrApp) << "Invalid save path";
        return;
    }

    initProcess();
    
    ExtCaptureRecorder *extRecorder = createExtRecorder();
    if (!extRecorder) {
        qCCritical(dsrApp) << "Failed to create recorder";
        return;
    }

    if (!waitForProtocol(extRecorder)) {
        delete extRecorder;
        return;
    }

    setupRecorderConnections(extRecorder);
    
    if (!startRecording(extRecorder)) {
        delete extRecorder;
        return;
    }

    storeRecorder(extRecorder);
}

// 3. 添加辅助函数
bool RecordProcess::validateSavePath(const QString& path)
{
    // 实现路径验证逻辑
    return true;
}

ExtCaptureRecorder* RecordProcess::createExtRecorder()
{
    return new ExtCaptureRecorder(this);
}

bool RecordProcess::waitForProtocol(ExtCaptureRecorder* recorder)
{
    if (recorder->isAvailable()) {
        return true;
    }

    QEventLoop waitLoop;
    QTimer timeoutTimer;
    timeoutTimer.setSingleShot(true);
    timeoutTimer.setInterval(Config::PROTOCOL_WAIT_TIMEOUT);
    
    // 使用智能指针管理连接
    QMetaObject::Connection conn = connect(recorder, &ExtCaptureRecorder::protocolAvailable, 
        [&waitLoop, &conn]() {
            QObject::disconnect(conn);
            waitLoop.quit();
        });

    timeoutTimer.start();
    waitLoop.exec();

    return recorder->isAvailable();
}
  1. 其他建议:
  • 考虑添加单元测试覆盖TreeLand相关功能
  • 建议添加配置文件支持,允许用户自定义TreeLand相关参数
  • 可以添加性能监控,记录录制过程中的资源使用情况

这些改进将使代码更加健壮、安全和易于维护。

@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 27, 2025

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot deepin-bot Bot merged commit 3c8a917 into linuxdeepin:develop/snipe Nov 27, 2025
7 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