From 92839a1c61a4d189c166285cb6361c6392d6fdc8 Mon Sep 17 00:00:00 2001 From: Resurgamz <108165585+Resurgamz@users.noreply.github.com> Date: Thu, 13 Aug 2026 20:30:56 +0800 Subject: [PATCH] fix(camera): use combobox for photo output format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/assets/resource/panel_settings.json | 4 ++-- src/assets/resource/settings.json | 4 ++-- src/src/Settings.cpp | 12 ++++++++++++ src/src/Settings.h | 6 ++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/assets/resource/panel_settings.json b/src/assets/resource/panel_settings.json index ad800144..0921efd7 100644 --- a/src/assets/resource/panel_settings.json +++ b/src/assets/resource/panel_settings.json @@ -167,8 +167,8 @@ { "key": "picformat", "name": "Photo:", - "type":"formatLabel", - "default": " JPG" + "type":"combobox", + "default": 0 }, { "key": "vidformat", diff --git a/src/assets/resource/settings.json b/src/assets/resource/settings.json index 90d8354b..a7202f6e 100644 --- a/src/assets/resource/settings.json +++ b/src/assets/resource/settings.json @@ -165,8 +165,8 @@ { "key": "picformat", "name": "Photo:", - "type":"formatLabel", - "default": " JPG" + "type":"combobox", + "default": 0 }, { "key": "vidformat", diff --git a/src/src/Settings.cpp b/src/src/Settings.cpp index 4009d21a..fd6d387c 100644 --- a/src/src/Settings.cpp +++ b/src/src/Settings.cpp @@ -70,6 +70,10 @@ void Settings::init() } m_settings->option("outsetting.outformat.vidformat")->setData("items", videoFormatList); + QStringList photoFormatList; + photoFormatList << tr("JPG") << tr("PNG"); + m_settings->option("outsetting.outformat.picformat")->setData("items", photoFormatList); + m_settings->setBackend(m_backend); connect(m_settings, &DSettings::valueChanged, this, &Settings::onValueChanged); @@ -269,6 +273,14 @@ void Settings::onValueChanged(const QString & key, const QVariant & value) emit videoFormatChanged(videoFormat); } } + + if (key.startsWith("outsetting.outformat.picformat")) { + QPointer formatOpt = m_settings->option("outsetting.outformat.picformat"); + if (value >= 0 && formatOpt->data("items").toStringList().size() > value.toInt()) { + QString photoFormat = formatOpt->data("items").toStringList()[value.toInt()]; + emit photoFormatChanged(photoFormat); + } + } } Settings::~Settings() diff --git a/src/src/Settings.h b/src/src/Settings.h index 77c0472f..5fbf54e1 100644 --- a/src/src/Settings.h +++ b/src/src/Settings.h @@ -154,6 +154,12 @@ public slots: */ void videoFormatChanged(QString format); + /** + * @brief photoFormatChanged 拍照照片格式 + * @param format 照片格式 + */ + void photoFormatChanged(QString format); + private: Settings(); static Settings m_instance;