Skip to content

表格识别 - #944

Closed
dengzhongyuan365-dev wants to merge 4 commits into
linuxdeepin:masterfrom
dengzhongyuan365-dev:newfeat-10080
Closed

dengzhongyuan365-dev wants to merge 4 commits into
linuxdeepin:masterfrom
dengzhongyuan365-dev:newfeat-10080

Conversation

@dengzhongyuan365-dev

@dengzhongyuan365-dev dengzhongyuan365-dev commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

feat(pin): run table recognition on pin image
Link dtk6tablerecognizer and wire the loader into the pin window so an
image can be recognized and rendered in the new UI.

链接 dtk6tablerecognizer 并把识别流程接入贴图窗口,对贴图内容执行
表格识别;贴图工具栏新增识别入口,D-Bus 接口开放对应调用。

Log: 接入贴图表格识别流程
PMS: TASK-393987
Influence: 贴图窗口可发起表格识别,依赖 libdtk6tablerecognizer。

Summary by Sourcery

Integrate table recognition into screenshot and pin workflows so users can recognize table content and copy the results in Excel-compatible format.

New Features:

  • Add table recognition for captured and pinned images, including asynchronous recognition feedback and successful results rendered in a copyable Excel-compatible dialog.
  • Expose table recognition through the pin window toolbar, Alt+T shortcut, and D-Bus API.

Enhancements:

  • Add themed table-recognition progress, error, and result overlays with localized messaging and accessibility identifiers.

Build:

  • Link the pin screenshot component against dtk6tablerecognizer and add its packaging dependency.

Chores:

  • Add table-recognition icons and related UI resources.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dengzhongyuan365-dev

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

@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR links the DTK table-recognition library and routes screenshot images through a new D-Bus API into the pinned-image window, where users can start recognition from the toolbar or Alt+T, observe themed progress/error states, and copy successful HTML results as Excel-compatible clipboard content.

Sequence diagram for table recognition from screenshot to clipboard

sequenceDiagram
    actor User
    participant Recorder as ScreenshotRecorder
    participant DBus as PinScreenShotsDBus
    participant Pin as PinnedImageWindow
    participant Loader as TableRecognizerLoader
    participant DTK as DTableRecognizer
    participant Clipboard

    User->>Recorder: click tableRecogn or press Alt+T
    Recorder->>DBus: openImageAndNameForTable(image, imageName, point)
    DBus->>Pin: openImageForTable(image, imageName, point)
    Pin->>Loader: recognize(image)
    Loader->>DTK: recognizeAsync(image, timeout)
    DTK-->>Loader: recognitionDone(result)
    Loader-->>Pin: recognitionFinished(success, html, error)
    alt recognition succeeds
        Pin-->>User: show TableResultDialog
        User->>Pin: click Copy as Excel format
        Pin->>Clipboard: setMimeData(html)
    else recognition fails
        Pin-->>User: show error toast
    end
Loading

File-Level Changes

Change Details Files
Integrate the DTK table-recognition backend and expose an asynchronous recognition wrapper.
  • Link the dtk6tablerecognizer package through qmake and packaging dependencies.
  • Add a loader that starts recognition with a timeout and forwards typed completion/error results.
  • Add table-specific D-Bus serialization, adaptor XML, and invokable entry points.
debian/control
src/pin_screenshots/pin_screenshots.pro
src/pin_screenshots/table/tablerecognizerloader.cpp
src/pin_screenshots/table/tablerecognizerloader.h
src/dbusinterface/pinscreenshotsinterface.h
src/pin_screenshots/pinscreenshots.cpp
src/pin_screenshots/pinscreenshots.h
src/pin_screenshots/service/dbuspinscreenshotsadaptor.cpp
src/pin_screenshots/service/dbuspinscreenshotsadaptor.h
Add table recognition actions to the screenshot and pinned-image workflows.
  • Add the toolbar button, accessibility identifiers, icon resources, tooltip, and Alt+T shortcut.
  • Introduce a table-recognition function state and route screenshot content through D-Bus into a new pin window.
  • Disable the action on the lock screen and preserve the recognition image without normal screenshot saving.
assets/icons/icons.qrc
assets/icons/texts/table-recognition_32px.svg
src/accessibility/acTextDefine.h
src/main_window.cpp
src/main_window.h
src/widgets/subtoolwidget.cpp
src/widgets/subtoolwidget.h
src/widgets/toolbar.cpp
src/widgets/toolbar.h
src/pin_screenshots/accessibility/acTextDefine.h
src/pin_screenshots/icons/icons.qrc
src/pin_screenshots/icons/texts/table-recognition_32px.svg
src/pin_screenshots/ui/subtoolwidget.cpp
src/pin_screenshots/ui/subtoolwidget.h
src/pin_screenshots/ui/toolbarwidget.cpp
src/pin_screenshots/ui/toolbarwidget.h
Build the pinned-window recognition UI for progress, errors, and successful results.
  • Show a themed loading overlay while recognition runs and map library error codes to localized toasts.
  • Display recognized HTML in a success dialog with copy-as-Excel clipboard support and cancel handling.
  • Use DTK blur, floating widgets, theme-aware colors, positioning, overlay raising, and custom table-recognition artwork.
src/pin_screenshots/putils.cpp
src/pin_screenshots/putils.h
src/pin_screenshots/ui/tableglasspanel.cpp
src/pin_screenshots/ui/tableglasspanel.h
src/pin_screenshots/ui/tablerecognizingwidget.cpp
src/pin_screenshots/ui/tablerecognizingwidget.h
src/pin_screenshots/ui/tablerecognizetoast.cpp
src/pin_screenshots/ui/tablerecognizetoast.h
src/pin_screenshots/ui/tableresultdialog.cpp
src/pin_screenshots/ui/tableresultdialog.h
src/pin_screenshots/icons/texts/table_close.svg
src/pin_screenshots/icons/texts/table_error.svg
src/pin_screenshots/icons/texts/tableresult_success.svg
src/pin_screenshots/mainwindow.cpp
src/pin_screenshots/mainwindow.h
Add localized strings for the new table-recognition interactions.
  • Translate progress, success, failure, timeout, busy, action, and tooltip text for Simplified and Traditional Chinese locales.
translations/deepin-screen-recorder_zh_CN.ts
translations/deepin-screen-recorder_zh_HK.ts
translations/deepin-screen-recorder_zh_TW.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/pin_screenshots/mainwindow.cpp" line_range="214" />
<code_context>
+    if (success) {
+        // 贴图窗口是置顶的无边框窗口,顶层对话框会被遮挡,这里使用窗口内浮层。
+        if (!m_tableResultDialog) {
+            m_tableResultDialog = new TableResultDialog(html, m_image, this);
+        }
+        m_tableResultDialog->setBackdropImage(m_image);
</code_context>
<issue_to_address>
**Clipboard keeps the previous table**

When a later recognition succeeds in the same pin window, `onTableRecognitionFinished` reuses `m_tableResultDialog` without updating its constructor-stored `m_html`, so `copyToClipboard()` copies the previous run’s table instead of the latest result.

Update the dialog’s stored HTML or recreate the dialog for each successful recognition.

Also at `src/pin_screenshots/mainwindow.cpp:213`.
</issue_to_address>

### Comment 2
<location path="src/main_window.cpp" line_range="4028" />
<code_context>
+        m_functionType = status::tablerecogn;
+        m_pinInterface = new PinScreenShotsInterface(
+            "com.deepin.PinScreenShots", "/com/deepin/PinScreenShots", QDBusConnection::sessionBus(), this);
+        saveScreenShot();
+        QImage tableImage = m_resultPixmap.toImage();
+        QDBusPendingCall pendingCall =
</code_context>
<issue_to_address>
**Treeland recognition gets no fresh capture**

When table recognition is launched in a Treeland session, the table branch calls `saveScreenShot()` even in Treeland mode, instead of using the Treeland capture path used by OCR. The image passed to the pin window is consequently not captured through that platform path, and recognition receives an invalid or stale image.

Route Treeland table recognition through the same capture path as OCR before sending the image to the pin window.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/pin_screenshots/mainwindow.cpp
Comment thread src/main_window.cpp Outdated
Add result dialog, progress widget, failure toast and glass panel for
table recognition, composed from DTK widgets only.

新增表格识别结果弹窗、识别进度、失败提示与毛玻璃面板,全部由 DTK
控件组合实现;同时补充深色主题取色工具与图标资源。

Log: 新增表格识别 UI 控件
PMS: TASK-393987
Influence: 提供表格识别所需的 UI 组件,尚未接入识别流程。
Link dtk6tablerecognizer and wire the loader into the pin window so an
image can be recognized and rendered in the new UI.

链接 dtk6tablerecognizer 并把识别流程接入贴图窗口,对贴图内容执行
表格识别;贴图工具栏新增识别入口,D-Bus 接口开放对应调用。

Log: 接入贴图表格识别流程
PMS: TASK-393987
Influence: 贴图窗口可发起表格识别,依赖 libdtk6tablerecognizer。
Add a table recognition button between OCR and pin in the screenshot
toolbar, which opens the pin window and starts recognition.

截图工具栏在文字识别与贴图之间新增表格识别入口,点击后跳转贴图
窗口并发起表格识别;同步补充无障碍名称与图标资源。

Log: 截图工具栏新增表格识别入口
PMS: TASK-393987
Influence: 截图模式下可直接发起表格识别,入口位于 OCR 与贴图之间。
Update zh_CN/zh_HK/zh_TW translations with the new table recognition
strings.

更新 zh_CN/zh_HK/zh_TW 翻译,补充表格识别相关文案。

Log: 更新表格识别翻译
PMS: TASK-393987
Influence: 表格识别相关界面文案可正确国际化。
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.

2 participants