be3c1b5e by 柴进

fix(style-designer): 补字段右键"恢复单类别默认词库"

旧 reset_category_library + open_fullsize_view(双击大图)等几个零散点,
盘 image_generator.py 时漏了 — 现在把 reset_category 这个最实用的补上。

QML wiring:
  - StyleDesignerTab 加 Menu fieldCtxMenu(targetCategory 属性)+
    MessageDialog 二次确认
  - 每个字段 CaptionLabel 加 MouseArea 监听右键,弹 fieldCtxMenu
    标签文字加 "  ▾" 提示有右键菜单
  - 走桥层 jewelry.resetCategory(category)(task #12 已就位)

注:
  - reset_all_library 老早就有顶部 ":arrows_counterclockwise: 恢复默认词库" 按钮接 jewelry.resetAll
  - open_fullsize_view (双击大图弹内嵌 viewer) 当前用 Qt.openUrlExternally
    打开系统查看器替代,UX 不同但功能等价

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ae36efe3
......@@ -37,6 +37,36 @@ Item {
// ➕ 添加词条对话框传参
property string addingCategory: ""
// 单类别"恢复默认"对话框传参
property string resetCategoryName: ""
// 字段右键菜单
Menu {
id: fieldCtxMenu
property string targetCategory: ""
MenuItem {
text: "恢复 \"" + fieldCtxMenu.targetCategory + "\" 的默认词库"
onTriggered: {
tab.resetCategoryName = fieldCtxMenu.targetCategory
confirmResetCategoryDialog.open()
}
}
}
MessageDialog {
id: confirmResetCategoryDialog
title: "确认恢复"
text: "确定要恢复 \"" + tab.resetCategoryName + "\" 的默认词库吗?\n这将删除该类别下所有自定义词条。"
buttons: MessageDialog.Yes | MessageDialog.No
onAccepted: {
if (tab.resetCategoryName) {
jewelry.resetCategory(tab.resetCategoryName)
tab.statusText = "● 已恢复 \"" + tab.resetCategoryName + "\" 默认词库"
tab.statusColor = App.Theme.success
tab.resetCategoryName = ""
}
}
}
function updateField(category, value) {
var copy = Object.assign({}, tab.formData)
......@@ -281,11 +311,22 @@ Item {
spacing: 4
CaptionLabel {
text: modelData
text: modelData + " ▾"
font.pointSize: App.Theme.fontBase
color: tab.isLocked(modelData)
? App.Theme.textTertiary
: App.Theme.textPrimary
// 右键 caption → 字段菜单("恢复默认词库"),与旧 reset_category_library 等价
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
cursorShape: Qt.PointingHandCursor
onClicked: function(mouse) {
fieldCtxMenu.targetCategory = modelData
fieldCtxMenu.popup()
}
}
}
RowLayout {
Layout.fillWidth: true
......