Files
vibemake-pcb-studio/common/eda_base_frame_help_menu.ts
T
likang 7e01147566
CI / typecheck + test + build (push) Has been cancelled
Initial commit: import VibeMake PCB Studio
2026-11-03 11:20:08 +08:00

98 lines
3.6 KiB
TypeScript

// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2026 ZiroEDA and contributors.
// Portions derived from KiCad, copyright The KiCad Developers. See NOTICE.md.
// Modified by VibeMake to expose only local hotkey help.
/**
* EDA_BASE_FRAME::AddStandardHelpMenu (common/eda_base_frame.cpp), ported.
*
* void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
* {
* COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
* ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
*
* helpMenu->Add( ACTIONS::help );
* helpMenu->Add( ACTIONS::gettingStarted );
* helpMenu->Add( ACTIONS::listHotKeys );
* helpMenu->Add( ACTIONS::getInvolved );
* helpMenu->Add( ACTIONS::donate );
* helpMenu->Add( ACTIONS::reportBug );
*
* helpMenu->AppendSeparator();
* helpMenu->Add( ACTIONS::about );
*
* aMenuBar->Append( helpMenu, _( "&Help" ) );
* }
*
* The point of this file is that there is one of it. Fourteen frames call that
* function - eeschema, pcbnew, gerbview, pl_editor, the symbol and footprint
* editors and viewers, cvpcb, the simulator, the 3D viewer, bitmap2component,
* the calculator and the project manager - so every KiCad Help menu is the same
* seven entries, because there is only one place they are written.
*
* Earlier copies were written separately and had drifted into eight different
* menus. This shared version retains local hotkey help. The About action and
* dialog remain available to the application for legal/diagnostic use, but the
* branded About button is hidden from the user-facing Help menu.
*
* KiCad donation, contribution, documentation, bug-report and support-chat
* actions are not shown because VibeMake has not published those destinations.
*/
import type { Menu } from '@ziroeda/wx/menu.js';
import { ACTIONS } from './tool/actions.js';
import type { TOOL_ACTION } from './tool/tool_action.js';
export interface HelpMenuHandlers {
/** ACTIONS::listHotKeys - opens DIALOG_LIST_HOTKEYS. */
showHotkeys: () => void;
/** ACTIONS::about, retained for direct callers even though its menu row is hidden. */
showAbout: () => void;
}
/** Compatibility hook retained for builds that provide their own support chat. */
export function setSupportChatOpener(aOpen: (() => void) | null): void {
// Support chat is intentionally disabled in the VibeMake build.
void aOpen;
}
/**
* A frame whose Help menu is `ACTION_MENU( false, commonControl )`: each row
* runs its action on the frame's TOOL_MANAGER, where COMMON_CONTROL answers
* it (`common/tool/common_control.ts`).
*/
export interface HelpMenuToolManager {
RunAction(aAction: TOOL_ACTION): unknown;
}
/**
* The Help menu, identical in every frame, as upstream's is.
*
* External destinations are intentionally omitted until VibeMake publishes its
* own help and support endpoints. The About row is also hidden by product
* request; the dialog implementation remains available for attribution pages.
*/
export function standardHelpMenu(h: HelpMenuHandlers | HelpMenuToolManager): Menu {
if ('RunAction' in h) {
const run = (a: TOOL_ACTION) => (): void => {
h.RunAction(a);
};
return helpMenu({
showHotkeys: run(ACTIONS.listHotKeys),
});
}
return helpMenu({
showHotkeys: h.showHotkeys,
});
}
function helpMenu(r: { showHotkeys: () => void }): Menu {
return {
label: 'Help',
items: [
// ACTIONS::listHotKeys, .DefaultHotkey( MD_CTRL + WXK_F1 ).
{ label: 'List Hotkeys...', shortcut: 'Ctrl+F1', action: r.showHotkeys },
],
};
}