Skip to content

fix(camera): use combobox for photo output format - #516

Open
Resurgamz wants to merge 1 commit into
linuxdeepin:release/eaglefrom
Resurgamz:bugfix-156865-picformat-combobox
Open

fix(camera): use combobox for photo output format#516
Resurgamz wants to merge 1 commit into
linuxdeepin:release/eaglefrom
Resurgamz:bugfix-156865-picformat-combobox

Conversation

@Resurgamz

@Resurgamz Resurgamz commented Aug 13, 2026

Copy link
Copy Markdown

fix(camera): 照片输出格式改为下拉框

PMS: https://pms.uniontech.com/bug-view-156865.html
基线(base): 5a8a1a95a3cde2db35a48658f53a566fc97430e1(release/eagle)

根因分析

设置界面"输出格式-照片"显示为静态文本而非下拉框。根因:src/assets/resource/settings.jsonoutsetting.outformat.picformat 的控件类型声明为自定义 formatLabel,对应工厂 createFormatLabelOptionHandlesrc/src/mainwindow.cpp)只渲染只读 DLabel(" JPG");而同组 vidformat 已是 combobox。两者类型不一致导致照片格式不是下拉框。

关键证据:

  • settings.json:166-170 / panel_settings.json:164-168picformat type=formatLabelvidformat type=combobox
  • mainwindow.cpp:134createFormatLabelOptionHandle 渲染静态 DLabel,无下拉交互。

(问题点 1、2:分割线/行高/间距根因在 DTK5 dtkwidget 上游 content.cpp 硬编码,不在本仓库,经根因复核不在本次范围。)

修复方案

仿照同组已正常工作的 vidformat(combobox + items + onValueChanged emit videoFormatChanged)镜像实现 picformat

  1. settings.json / panel_settings.jsonpicformat type formatLabelcombobox,default " JPG"0(JPG)。
  2. Settings.cpp::init:为 picformat 填充下拉项 ["JPG","PNG"]setData("items", ...))。
  3. Settings.cpp::onValueChanged:新增 picformat 分支,发出 photoFormatChanged(QString)(带越界保护,镜像 vidformat)。
  4. Settings.h:声明 photoFormatChanged(QString) 信号。

combobox 为 DTK 内建类型,DSettingsDialog 自动渲染下拉框,无需自定义工厂;formatLabel 工厂注册保留(panel 模式 vidformat 仍用)。

改动安全评估

低风险。onValueChanged 仅通过 connect(DSettings::valueChanged) 接入,无直接调用者;本次为纯新增兄弟分支,不改签名、不触碰既有分支(含近期 shutter-audio 修复逻辑),无回归风险。

已知遗留(本次按批准范围仅修 Settings 侧)

photoFormatChanged 信号当前无消费者:照片保存路径仍硬编码 .jpgvideowidget.cpp:771)与 img.save(...,"JPG")majorimageprocessingthread.cpp:123/421/440)。即用户选 PNG 时照片仍以 JPG 保存。完整端到端(PNG 实际保存)需追加 videowidget.cpp / majorimageprocessingthread.cpp / mainwindow.cpp 消费侧接线,超出本次批准文件范围,留待后续。

Summary by Sourcery

Switch photo output format setting to a combobox and emit a dedicated change signal for it.

New Features:

  • Add a configurable photo output format with JPG/PNG options exposed via a combobox in the settings UI.

Enhancements:

  • Wire the photo output format setting into the settings change flow by emitting a photoFormatChanged signal when the value changes.

1. 将 settings.json 与 panel_settings.json 中 outsetting.outformat.picformat 的控件类型由 formatLabel 改为 combobox,默认值改为索引 0;
2. 在 Settings::init 中仿照 vidformat 为 picformat 填充下拉项(JPG/PNG);
3. 在 Settings::onValueChanged 中新增 picformat 分支发出 photoFormatChanged 信号,并在 Settings.h 声明该信号;

=====================================

1. changed the widget type of outsetting.outformat.picformat from formatLabel to combobox in settings.json and panel_settings.json, with default index 0;
2. populated picformat combobox items (JPG/PNG) in Settings::init, mirroring vidformat;
3. added a picformat branch in Settings::onValueChanged to emit photoFormatChanged, and declared the signal in Settings.h;

Log: 设置界面"输出格式-照片"由静态标签改为下拉框,与视频格式下拉框保持一致

PMS: https://pms.uniontech.com/bug-view-156865.html

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

Sorry @Resurgamz, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Resurgamz

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

@github-actions

Copy link
Copy Markdown

CLA Assistant Lite bot:

如果你是以企业贡献者的身份进行提交,请联系我们签署企业贡献者许可协议
If you submit as corporate contributor, please contact us to sign our Corporate Contributor License Agreement

感谢您的提交,我们非常感谢。 像许多开源项目一样,在接受您的贡献之前,我们要求您签署我们的个人贡献者许可协议。 您只需发布与以下格式相同的评论即可签署个人贡献者许可协议
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Individual Contributor License Agreement before we can accept your contribution. You can sign the Individual Contributor License Agreement by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA.

You can retrigger this bot by commenting recheck in this Pull Request

@sourcery-ai

sourcery-ai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Switches the photo output format setting from a custom read-only label to a standard combobox, mirroring the existing video format combobox, and wires it into the settings change signal pipeline via a new photoFormatChanged signal.

Sequence diagram for handling photo format combobox changes

sequenceDiagram
    actor User
    participant DSettingsDialog
    participant DSettings
    participant Settings

    User->>DSettingsDialog: select photo format (e.g. PNG)
    DSettingsDialog->>DSettings: setOption("outsetting.outformat.picformat", value)
    DSettings-->>Settings: valueChanged(key, value)
    Settings->>Settings: onValueChanged(key, value)
    Settings->>Settings: photoFormatChanged(photoFormat)
Loading

File-Level Changes

Change Details Files
Introduce a combobox-based photo format setting with items and value-change handling analogous to the existing video format combobox.
  • Populate a new photoFormatList (JPG, PNG) and assign it to the outsetting.outformat.picformat option via setData("items", ...).
  • Extend Settings::onValueChanged with a guarded branch for outsetting.outformat.picformat that translates the combobox index into a format string and emits photoFormatChanged.
src/src/Settings.cpp
Expose a dedicated signal for photo format changes so other components can subscribe to the user’s selection.
  • Declare a photoFormatChanged(QString format) signal alongside videoFormatChanged, with brief documentation indicating it represents the still-photo format.
src/src/Settings.h
Change the photo format UI configuration from a custom formatLabel to a combobox so that DSettingsDialog renders a dropdown instead of a static label.
  • Update outsetting.outformat.picformat type from formatLabel to combobox in the settings resource configuration.
  • Adjust the default value for picformat from a literal JPG label to a numeric combobox index consistent with other combobox options.
src/assets/resource/panel_settings.json
src/assets/resource/settings.json

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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:92分

■ 【总体评价】

代码实现了拍照照片格式的可选功能,逻辑清晰且无安全风险
实现了下拉框选择并正确发送信号,扣分主要因为键值匹配方式不够严谨

■ 【详细分析】

  • 1.语法逻辑(基本正确)✓

代码在 Settings.cpp 的 onValueChanged 方法中新增了 picformat 的处理逻辑,正确进行了列表越界检查并提取字符串发送信号。JSON 文件的类型和默认值修改符合预期。
潜在问题:使用 key.startsWith 判断配置项可能匹配到意外的前缀子串;QVariant 与 int 直接比较依赖隐式转换。
建议:将 startsWith 改为 == 精确匹配;显式使用 value.toInt() 进行比较。

  • 2.代码质量(良好)✓

代码风格与现有 videoFormatChanged 保持一致,信号声明带有完整的 Doxygen 注释,变量命名清晰,无冗余代码。
潜在问题:无
建议:无

  • 3.代码性能(无性能问题)✓

字符串列表操作仅在配置变化时触发,开销极小,不影响性能。
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次修改仅涉及配置读取和信号发送,未引入外部输入处理或危险操作,无安全风险。

  • 建议:无

■ 【改进建议代码示例】

// Settings.cpp
void Settings::onValueChanged(const QString & key, const QVariant & value)
{
    // ... existing code ...

    if (key == "outsetting.outformat.picformat") {
        QPointer<DSettingsOption> formatOpt = m_settings->option("outsetting.outformat.picformat");
        int index = value.toInt();
        QStringList items = formatOpt->data("items").toStringList();
        if (index >= 0 && items.size() > index) {
            QString photoFormat = items[index];
            emit photoFormatChanged(photoFormat);
        }
    }
}

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