- Created .gitignore to exclude build artifacts and dependencies. - Added package.json and package-lock.json for project dependencies and scripts. - Included pnpm workspace configuration for managing packages. - Implemented TypeScript configuration in tsconfig.json. - Added README.md with project description and usage instructions. - Introduced native code for DES encryption and decryption in C/C++. - Created initial decoded data structure for handling scan results. - Established basic file structure for decoded outputs and native builds.
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import fs from "fs";
|
|
import os from "os";
|
|
import path from "path";
|
|
import { QIcon, QSize, QSvgWidget } from "@nodegui/nodegui";
|
|
|
|
const cacheDir = path.join(os.tmpdir(), "des-key-cracker-icons");
|
|
const iconCache = new Map<string, QIcon>();
|
|
const svgKeepAlive: QSvgWidget[] = [];
|
|
|
|
export const ICON_SIZE = new QSize(16, 16);
|
|
export const BUTTON_ICON_GAP = 4;
|
|
export const BUTTON_ICON_SIZE = new QSize(16 + BUTTON_ICON_GAP, 16);
|
|
export const LOGO_SIZE = 28;
|
|
export const ACCENT = "#5eead4";
|
|
export const INK = "#e8eef4";
|
|
|
|
function lucideFile(name: string): string {
|
|
return require.resolve(`lucide-static/icons/${name}.svg`);
|
|
}
|
|
|
|
export function tintedSvgPath(name: string, color: string, gapRightPx = 0): string {
|
|
const key = `${name}-${color.replace("#", "")}${gapRightPx ? `-g${gapRightPx}` : ""}`;
|
|
fs.mkdirSync(cacheDir, { recursive: true });
|
|
const out = path.join(cacheDir, `${key}.svg`);
|
|
let svg = fs.readFileSync(lucideFile(name), "utf8").replace(/currentColor/g, color);
|
|
if (gapRightPx > 0) {
|
|
const extra = (gapRightPx * 24) / 16;
|
|
svg = svg
|
|
.replace(/viewBox="0 0 24 24"/, `viewBox="0 0 ${24 + extra} 24"`)
|
|
.replace(/width="24"/, `width="${24 + extra}"`);
|
|
}
|
|
fs.writeFileSync(out, svg);
|
|
return out;
|
|
}
|
|
|
|
export function lucideIcon(name: string, color = INK, gapRightPx = 0): QIcon {
|
|
const key = `${name}:${color}:${gapRightPx}`;
|
|
let cached = iconCache.get(key);
|
|
if (!cached) {
|
|
cached = new QIcon(tintedSvgPath(name, color, gapRightPx));
|
|
iconCache.set(key, cached);
|
|
}
|
|
return cached;
|
|
}
|
|
|
|
export function buttonIcon(name: string, color = INK): QIcon {
|
|
return lucideIcon(name, color, BUTTON_ICON_GAP);
|
|
}
|
|
|
|
export function lucideSvg(name: string, color: string, size: number): QSvgWidget {
|
|
const widget = new QSvgWidget();
|
|
widget.setObjectName("svgIcon");
|
|
widget.load(tintedSvgPath(name, color));
|
|
widget.setFixedWidth(size);
|
|
widget.setFixedHeight(size);
|
|
svgKeepAlive.push(widget);
|
|
return widget;
|
|
}
|