Skip to content

feat(kpod): show K-Pod macros in Options and import them from a K4 backup - #10

Closed
tcpreplay-dev wants to merge 1 commit into
mainfrom
feat/kpod-macro-view-and-k4-backup-import
Closed

tcpreplay-dev wants to merge 1 commit into
mainfrom
feat/kpod-macro-view-and-k4-backup-import

Conversation

@tcpreplay-dev

Copy link
Copy Markdown
Owner

What

The K-Pod Options page now shows all sixteen K-Pod button macros, and macros can be imported from a K4 backup file.

K-Pod page

Sixteen slots as a table — tap column left, hold column right, Button / Name / CAT Command. Read-only: MacroDialog (Fn > MACROS) stays the only editor, so there is no second writer on the same QSettings array and two open views cannot clobber each other. The page reloads on macrosChanged, so an edit made in Fn > MACROS shows up here immediately.

The bindings themselves already worked — HardwareController emits K-pod.<n>T / K-pod.<n>H on tap and hold, MacroController dispatches whatever RadioSettings holds — but the only place to see them was MacroDialog's flat list of every macro slot in the application.

Rest of the page was rearranged to fit the dialog's default width: status and enable share a row, Device Summary is two property/value pairs per row instead of seven full-width rows, and the page scrolls.

Import from K4 Backup

No K4 CAT command reads or writes macro text. MS is Mic Setup (MSabcde;); neither the Programmer's Reference D5 in resources/k4_cat_commands.json nor Elecraft's published rev D4 documents any macro accessor.

The K4's backup utility does export them — Fn > hold BACKUP writes K4_SN<serial>/k4macros.json, one of its six selectable categories being "PF Key and K-Pod Macros". The new button reads that file.

It is a file picker and nothing more: no volume scanning, no startup probing, no guessing where a stick is mounted. Before writing, the import compares every slot against what QK4 holds and asks for confirmation, naming each macro that would be overwritten, defaulting to No. Slots absent from the file are untouched. It covers every slot the backup carries — 16 K-Pod, PF1-4, Fn.F1-8, REM ANT.

Why the slot map is explicit

The file's names are close enough to MacroIds to be dangerous: Kpod.1T against K-pod.1T, REM.ANT against REM_ANT, while Fn.F1-F8 and PF1-PF4 match exactly. A mistranslation would write macros into slots nothing dispatches and look entirely successful. Hence a lookup table rather than prefix surgery, unknown slots skipped with a log line, and tests asserting no raw backup name survives into the store.

Also

RadioSettings::setMacros() for the bulk path — one file write and one macrosChanged for the whole import instead of one of each per macro.

Testing

  • tests/test_k4macrobackup.cpp, 12 cases covering slot translation, empty-command slots, unknown slots, verbatim commands, malformed JSON
  • Full suite 15/15, build clean with no new warnings
  • Parser verified end-to-end against a real backup stick: 17 assigned macros, all IDs translated correctly

🤖 Generated with Claude Code

@tcpreplay-dev tcpreplay-dev reopened this Sep 2, 2026
@tcpreplay-dev
tcpreplay-dev force-pushed the feat/kpod-macro-view-and-k4-backup-import branch from 18731eb to 99ab468 Compare September 2, 2026 02:07
@tcpreplay-dev

Copy link
Copy Markdown
Owner Author

Screenshot:
image

…ckup

The K-Pod page listed device descriptors and an enable checkbox, but said
nothing about what the eight buttons actually do. The bindings existed —
HardwareController emits "K-pod.<n>T" / "K-pod.<n>H" on every tap and hold,
and MacroController dispatches whatever RadioSettings holds for those IDs —
but the only place to see them was MacroDialog's flat list of every macro
slot in the application, K-Pod entries interleaved with PF, Fn and keyboard
ones.

The page now shows all sixteen slots as a table: tap column left, hold column
right, Button / Name / CAT Command. They are read-only. MacroDialog remains
the single editor, so there is no second writer on the same QSettings array
and no chance of two open views clobbering each other; the page reloads on
macrosChanged, so an edit made in Fn > MACROS appears here immediately. The
rest of the page was rearranged to fit the dialog's default width — status and
enable share a row, and Device Summary is two property/value pairs per row
instead of seven full-width rows.

Macros can also come from the radio, though not over CAT. No K4 command reads
or writes macro text: MS is Mic Setup (MSabcde;), and neither the Programmer's
Reference D5 shipped in resources/k4_cat_commands.json nor Elecraft's published
rev D4 documents any macro accessor. What the K4 does offer is its backup
utility — Fn > hold BACKUP writes K4_SN<serial>/k4macros.json, one of six
selectable categories being "PF Key and K-Pod Macros".

"Import from K4 Backup..." on the K-Pod page reads that file. It is deliberately
a file picker and nothing more: no volume scanning, no startup probing, no
inference about where a USB stick might be mounted. The user says where the file
is. Before writing anything the import compares every slot against what QK4
already holds and asks for confirmation, naming each macro that would be
overwritten, defaulting to No. Slots absent from the file are untouched.

The file's slot names are close enough to QK4's MacroIds to be dangerous —
"Kpod.1T" against "K-pod.1T", "REM.ANT" against "REM_ANT", while Fn.F1-F8 and
PF1-PF4 match exactly. The translation is therefore an explicit table rather
than prefix surgery, unknown slots are skipped with a log line, and the tests
assert that no raw backup name survives into the store. A mistranslation would
write macros into slots nothing dispatches and look entirely successful.

RadioSettings gains setMacros() for the bulk path, which writes the file and
emits macrosChanged once for the whole import rather than once per macro.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tcpreplay-dev
tcpreplay-dev force-pushed the feat/kpod-macro-view-and-k4-backup-import branch from 99ab468 to 94d981f Compare September 2, 2026 03:40
@tcpreplay-dev

Copy link
Copy Markdown
Owner Author

Closing for now — will rework this branch. Branch retained.

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.

1 participant