Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add promark settings in device menu #311

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/node/electron-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,17 +493,18 @@ const onMenuClick = (data: {
uuid: data.uuid,
machineName: data.machineName,
};
if (mainWindow) {
const window = BrowserWindow.getFocusedWindow();
if (window) {
if (editingStandardInput) {
if (data.id === 'REDO') {
mainWindow.webContents.redo();
window.webContents.redo();
}
if (data.id === 'UNDO') {
mainWindow.webContents.undo();
window.webContents.undo();
}
} else {
console.log('Send', data);
mainWindow.webContents.send(events.MENU_CLICK, data);
window.webContents.send(events.MENU_CLICK, data);
}
} else {
console.log('Menu event triggered but window does not exist.');
Expand Down
161 changes: 77 additions & 84 deletions src/node/menu-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {

import DeviceInfo from 'interfaces/DeviceInfo';
import i18n from 'helpers/i18n';
import { adorModels, promarkModels } from 'app/actions/beambox/constant';

import events from './ipc-events';

Expand Down Expand Up @@ -500,9 +501,9 @@ function buildMenuItems(
submenu: [
{ id: 'MATERIAL_TEST_GENERATOR', label: r.tools.material_test_generator, click: callback },
{ id: 'QR_CODE_GENERATOR', label: r.tools.qr_code_generator, click: callback },
{ id: 'BOX_GEN', label: r.tools.boxgen, click: callback }
]
})
{ id: 'BOX_GEN', label: r.tools.boxgen, click: callback },
],
});

const accountSubmenu = buildAccountMenuItems(callback, accountInfo);
menuItems.push({
Expand Down Expand Up @@ -543,90 +544,82 @@ function buildDeviceMenu(
data: DeviceInfo,
isDevMode = false
) {
const { serial, source, name } = data;
const menuLabel = data.source === 'lan' ? data.name : `${data.name} (USB)`;
const { serial, source, name, model } = data;
const menuLabel = source === 'lan' ? name : `${name} (USB)`;
const machineName = name;
let modelType = 'beambox-series';
if (['ado1'].includes(data.model)) modelType = 'ador-series';
const isAdor = adorModels.has(model);
const isPromark = promarkModels.has(model);
const isBeamo = model === 'fbm1';
const handleClick = (item: MenuItem) => callback({ ...item, uuid, serial, machineName, source });
let submenu: MenuItemConstructorOptions[] = [
{
id: 'DASHBOARD',
label: r.dashboard,
click: handleClick,
},
{
id: 'MACHINE_INFO',
label: r.machine_info,
click: handleClick,
},
const submenu: MenuItemConstructorOptions[] = [
{ id: 'DASHBOARD', label: r.dashboard, click: handleClick },
{ id: 'MACHINE_INFO', label: r.machine_info, click: handleClick },
isPromark
? { id: 'PROMARK_SETTINGS', label: i18n.lang.promark_settings?.title, click: handleClick }
: null,
{ type: 'separator' },
{
id: 'CALIBRATE_BEAMBOX_CAMERA',
label: r.calibrate_beambox_camera,
click: handleClick,
},
];

if (data.model === 'fbm1') {
submenu.push({
id: 'CALIBRATE_BEAMBOX_CAMERA_BORDERLESS',
label: r.calibrate_beambox_camera_borderless,
click: handleClick,
});
submenu.push({
id: 'CALIBRATE_DIODE_MODULE',
label: r.calibrate_diode_module,
click: handleClick,
});
} else if (modelType === 'ador-series') {
if (isDevMode) {
submenu.push({
id: 'CALIBRATE_CAMERA_V2_FACTORY',
label: `${r.calibrate_beambox_camera} (Factory)`,
click: handleClick,
});
}
submenu.push(
{
id: 'CALIBRATE_PRINTER_MODULE',
label: r.calibrate_printer_module,
click: handleClick,
},
{
id: 'CALIBRATE_IR_MODULE',
label: r.calibrate_ir_module,
click: handleClick,
}
);
if (isDevMode) {
submenu.push({
id: 'CATRIDGE_CHIP_SETTING',
label: 'Catridge Chip Setting',
click: handleClick,
});
}
}
submenu.push({ type: 'separator' });
if (modelType === 'ador-series') {
submenu.push({
id: 'CAMERA_CALIBRATION_DATA',
label: r.camera_calibration_data,
submenu: [
{
id: 'UPLOAD_CALIBRATION_DATA',
label: r.upload_data,
{ id: 'CALIBRATE_BEAMBOX_CAMERA', label: r.calibrate_beambox_camera, click: handleClick },
isBeamo
? {
id: 'CALIBRATE_BEAMBOX_CAMERA_BORDERLESS',
label: r.calibrate_beambox_camera_borderless,
click: handleClick,
},
{
id: 'DOWNLOAD_CALIBRATION_DATA',
label: r.download_data,
}
: null,
isBeamo
? {
id: 'CALIBRATE_DIODE_MODULE',
label: r.calibrate_diode_module,
click: handleClick,
},
],
});
}
submenu = submenu.concat([
}
: null,
isAdor && isDevMode
? {
id: 'CALIBRATE_CAMERA_V2_FACTORY',
label: `${r.calibrate_beambox_camera} (Factory)`,
click: handleClick,
}
: null,
isAdor
? {
id: 'CALIBRATE_PRINTER_MODULE',
label: r.calibrate_printer_module,
click: handleClick,
}
: null,
isAdor
? {
id: 'CALIBRATE_IR_MODULE',
label: r.calibrate_ir_module,
click: handleClick,
}
: null,
isAdor && isDevMode
? {
id: 'CATRIDGE_CHIP_SETTING',
label: 'Catridge Chip Setting',
click: handleClick,
}
: null,
{ type: 'separator' },
isAdor
? {
id: 'CAMERA_CALIBRATION_DATA',
label: r.camera_calibration_data,
submenu: [
{
id: 'UPLOAD_CALIBRATION_DATA',
label: r.upload_data,
click: handleClick,
},
{
id: 'DOWNLOAD_CALIBRATION_DATA',
label: r.download_data,
click: handleClick,
},
],
}
: null,
{
id: 'UPDATE_FIRMWARE',
label: r.update_firmware,
Expand Down Expand Up @@ -678,7 +671,7 @@ function buildDeviceMenu(
},
],
},
]);
].filter(Boolean) as MenuItemConstructorOptions[];

return new MenuItem({
label: menuLabel,
Expand Down Expand Up @@ -794,7 +787,7 @@ class MenuManager extends EventEmitter {

onMenuClick = (data: MenuData): void => {
if (data.id) {
const eventData: MenuData = {...data};
const eventData: MenuData = { ...data };
if (data.uuid && data.source) {
const menuId = getDeviceMenuId(data.uuid, { source: data.source });
if (this.deviceList[menuId]) {
Expand Down
Loading