dazscript-framework 1.0.24 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dazscript-framework",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "author": "Freddy Diaz",
5
5
  "license": "MPL-2.0",
6
6
  "description": "",
@@ -10,6 +10,7 @@ export default class GroupBoxBuilder implements IWidgetBuilder<DzGroupBox> {
10
10
  private _style: { flat?: boolean }
11
11
  private _visible: Observable<boolean>
12
12
  private _enabled: Observable<boolean>
13
+ private _checked: Observable<boolean>
13
14
  private _columns: number = 1
14
15
  private _height: number | null = null
15
16
  private _minHeight: number | null = null
@@ -50,6 +51,13 @@ export default class GroupBoxBuilder implements IWidgetBuilder<DzGroupBox> {
50
51
  return this
51
52
  }
52
53
 
54
+ checkable(value: boolean | Observable<boolean> = true): this {
55
+ this._checked = typeof value === 'boolean'
56
+ ? new Observable(value)
57
+ : value
58
+ return this
59
+ }
60
+
53
61
  visible(value: boolean | Observable<boolean>): this {
54
62
  this._visible = typeof value === 'boolean'
55
63
  ? new Observable(value)
@@ -90,6 +98,10 @@ export default class GroupBoxBuilder implements IWidgetBuilder<DzGroupBox> {
90
98
  groupBox.title = this._title?.value
91
99
  groupBox.flat = this._style?.flat
92
100
  groupBox.columns = this._columns
101
+ if (this._checked) {
102
+ groupBox.checkable = true
103
+ groupBox.checked = this._checked.value
104
+ }
93
105
  if (this._height !== null) groupBox.height = this._height
94
106
  if (this._minHeight !== null) groupBox.minHeight = this._minHeight
95
107
  if (this._maxHeight !== null) groupBox.maxHeight = this._maxHeight
@@ -98,6 +110,15 @@ export default class GroupBoxBuilder implements IWidgetBuilder<DzGroupBox> {
98
110
  groupBox.title = text
99
111
  })
100
112
 
113
+ if (this._checked) {
114
+ this._checked.connect((checked) => {
115
+ groupBox.checked = checked
116
+ })
117
+ groupBox.toggled.scriptConnect((checked) => {
118
+ this._checked.value = checked
119
+ })
120
+ }
121
+
101
122
  new LayoutBuilder(this.context)
102
123
  .parent(groupBox)
103
124
  .direction(this._direction)
@@ -12,7 +12,7 @@ import { TreeNode } from '@dsf/lib/tree-node'
12
12
  import { promptKeyboardShortcut } from '@dsf/shared/set-keyboard-shortcut'
13
13
  import { readFromFile, saveToFile } from './file-helper'
14
14
  import { getCanonicalInstallerEntry, toActionKey } from './custom-action-installer-entries'
15
- import { canResetSetupShortcut, getDisplayedSetupShortcut, resetSetupShortcut, setSetupShortcut, updateShortcutOverrideState } from './custom-action-installer-shortcuts'
15
+ import { canResetSetupShortcut, getDisplayedSetupShortcut, resetSetupShortcut, resetSetupShortcuts, setSetupShortcut, updateShortcutOverrideState } from './custom-action-installer-shortcuts'
16
16
  import { getScriptPath } from './script-helper'
17
17
 
18
18
  type InstallerEntry = {
@@ -397,6 +397,7 @@ class InstallerSelectionDialog extends BasicDialog {
397
397
  debug(`[Setup] context menu row resolved item="${this.safeListItemText(contextItem, 1)}" entry="${entry?.action?.text ?? ''}"`)
398
398
  const canSetShortcut = Boolean(entry)
399
399
  const canResetShortcut = Boolean(entry && canResetSetupShortcut(entry))
400
+ const canResetAllShortcuts = this.entries.some(canResetSetupShortcut)
400
401
 
401
402
  const items = [
402
403
  {
@@ -413,6 +414,10 @@ class InstallerSelectionDialog extends BasicDialog {
413
414
  this.resetDefaultShortcut(entry)
414
415
  }
415
416
  },
417
+ {
418
+ text: 'Reset All Shortcuts to Defaults',
419
+ activated: () => this.resetAllDefaultShortcuts()
420
+ },
416
421
  {},
417
422
  { text: 'Check All', activated: () => this.checkVisible(listView, true) },
418
423
  { text: 'Uncheck All', activated: () => this.checkVisible(listView, false) }
@@ -421,6 +426,7 @@ class InstallerSelectionDialog extends BasicDialog {
421
426
  return new PopupMenuBuilder(this.builder.context).items(...items).build((menu) => {
422
427
  menu.setItemEnabled(0, canSetShortcut)
423
428
  menu.setItemEnabled(1, canResetShortcut)
429
+ menu.setItemEnabled(2, canResetAllShortcuts)
424
430
  })
425
431
  }
426
432
 
@@ -498,6 +504,15 @@ class InstallerSelectionDialog extends BasicDialog {
498
504
  this.refreshListEvent$.trigger()
499
505
  }
500
506
 
507
+ private resetAllDefaultShortcuts() {
508
+ const resettableEntries = this.entries.filter(canResetSetupShortcut)
509
+ if (resettableEntries.length === 0) return
510
+
511
+ resetSetupShortcuts(resettableEntries)
512
+ debug(`[Setup] reset ${resettableEntries.length} shortcuts to defaults`)
513
+ this.refreshListEvent$.trigger()
514
+ }
515
+
501
516
  private checkVisible(listView: DzListView, onOff: boolean) {
502
517
  if (!this.keywords$.value?.trim()) {
503
518
  checkAll(listView, onOff)
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest'
2
2
  import {
3
3
  canResetSetupShortcut,
4
4
  getDisplayedSetupShortcut,
5
+ resetSetupShortcuts,
5
6
  resetSetupShortcut,
6
7
  setSetupShortcut,
7
8
  updateShortcutOverrideState
@@ -80,6 +81,29 @@ describe('setup shortcut state', () => {
80
81
  expect(canResetSetupShortcut(entry)).toBe(false)
81
82
  })
82
83
 
84
+ it('resets all shortcut entries to their defaults', () => {
85
+ const installed = shortcutState({
86
+ installedActionName: 'installed-guid',
87
+ defaultShortcut: 'Ctrl+P',
88
+ installedShortcut: 'F12',
89
+ effectiveShortcut: 'F12',
90
+ isShortcutOverridden: true
91
+ })
92
+ const pending = shortcutState({
93
+ defaultShortcut: '',
94
+ effectiveShortcut: 'Ctrl+Alt+K'
95
+ })
96
+
97
+ resetSetupShortcuts([installed, pending])
98
+
99
+ expect(installed.installedShortcut).toBe('Ctrl+P')
100
+ expect(installed.effectiveShortcut).toBe('Ctrl+P')
101
+ expect(installed.isShortcutOverridden).toBe(false)
102
+ expect(pending.installedShortcut).toBe('')
103
+ expect(pending.effectiveShortcut).toBe('')
104
+ expect(pending.isShortcutOverridden).toBe(false)
105
+ })
106
+
83
107
  it('displays custom marker when installed shortcut was changed outside setup', () => {
84
108
  const entry = shortcutState({
85
109
  installedActionName: 'installed-guid',
@@ -47,3 +47,7 @@ export const resetSetupShortcut = (entry: InstallerShortcutState): void => {
47
47
  entry.effectiveShortcut = defaultShortcut
48
48
  updateShortcutOverrideState(entry)
49
49
  }
50
+
51
+ export const resetSetupShortcuts = (entries: InstallerShortcutState[]): void => {
52
+ entries.forEach(resetSetupShortcut)
53
+ }