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 老早就有顶部 "
恢复默认词库" 按钮接 jewelry.resetAll
- open_fullsize_view (双击大图弹内嵌 viewer) 当前用 Qt.openUrlExternally
打开系统查看器替代,UX 不同但功能等价
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Showing
1 changed file
with
42 additions
and
1 deletions
| ... | @@ -37,6 +37,36 @@ Item { | ... | @@ -37,6 +37,36 @@ Item { |
| 37 | 37 | ||
| 38 | // ➕ 添加词条对话框传参 | 38 | // ➕ 添加词条对话框传参 |
| 39 | property string addingCategory: "" | 39 | property string addingCategory: "" |
| 40 | // 单类别"恢复默认"对话框传参 | ||
| 41 | property string resetCategoryName: "" | ||
| 42 | |||
| 43 | // 字段右键菜单 | ||
| 44 | Menu { | ||
| 45 | id: fieldCtxMenu | ||
| 46 | property string targetCategory: "" | ||
| 47 | MenuItem { | ||
| 48 | text: "恢复 \"" + fieldCtxMenu.targetCategory + "\" 的默认词库" | ||
| 49 | onTriggered: { | ||
| 50 | tab.resetCategoryName = fieldCtxMenu.targetCategory | ||
| 51 | confirmResetCategoryDialog.open() | ||
| 52 | } | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | MessageDialog { | ||
| 57 | id: confirmResetCategoryDialog | ||
| 58 | title: "确认恢复" | ||
| 59 | text: "确定要恢复 \"" + tab.resetCategoryName + "\" 的默认词库吗?\n这将删除该类别下所有自定义词条。" | ||
| 60 | buttons: MessageDialog.Yes | MessageDialog.No | ||
| 61 | onAccepted: { | ||
| 62 | if (tab.resetCategoryName) { | ||
| 63 | jewelry.resetCategory(tab.resetCategoryName) | ||
| 64 | tab.statusText = "● 已恢复 \"" + tab.resetCategoryName + "\" 默认词库" | ||
| 65 | tab.statusColor = App.Theme.success | ||
| 66 | tab.resetCategoryName = "" | ||
| 67 | } | ||
| 68 | } | ||
| 69 | } | ||
| 40 | 70 | ||
| 41 | function updateField(category, value) { | 71 | function updateField(category, value) { |
| 42 | var copy = Object.assign({}, tab.formData) | 72 | var copy = Object.assign({}, tab.formData) |
| ... | @@ -281,11 +311,22 @@ Item { | ... | @@ -281,11 +311,22 @@ Item { |
| 281 | spacing: 4 | 311 | spacing: 4 |
| 282 | 312 | ||
| 283 | CaptionLabel { | 313 | CaptionLabel { |
| 284 | text: modelData | 314 | text: modelData + " ▾" |
| 285 | font.pointSize: App.Theme.fontBase | 315 | font.pointSize: App.Theme.fontBase |
| 286 | color: tab.isLocked(modelData) | 316 | color: tab.isLocked(modelData) |
| 287 | ? App.Theme.textTertiary | 317 | ? App.Theme.textTertiary |
| 288 | : App.Theme.textPrimary | 318 | : App.Theme.textPrimary |
| 319 | |||
| 320 | // 右键 caption → 字段菜单("恢复默认词库"),与旧 reset_category_library 等价 | ||
| 321 | MouseArea { | ||
| 322 | anchors.fill: parent | ||
| 323 | acceptedButtons: Qt.RightButton | ||
| 324 | cursorShape: Qt.PointingHandCursor | ||
| 325 | onClicked: function(mouse) { | ||
| 326 | fieldCtxMenu.targetCategory = modelData | ||
| 327 | fieldCtxMenu.popup() | ||
| 328 | } | ||
| 329 | } | ||
| 289 | } | 330 | } |
| 290 | RowLayout { | 331 | RowLayout { |
| 291 | Layout.fillWidth: true | 332 | Layout.fillWidth: true | ... | ... |
-
Please register or sign in to post a comment