feat: Add configurable QR code sizing options (#3)
Some checks failed
CI / style (push) Has been cancelled
CI / build-client (push) Has been cancelled
CI / build-amd64 (push) Has been cancelled
CI / build-tester (push) Has been cancelled
CI / test (cockroachdb) (push) Has been cancelled
CI / test (mariadb) (push) Has been cancelled
CI / test (postgres) (push) Has been cancelled
CI / test (sqlite) (push) Has been cancelled
CI / build-arm64 (push) Has been cancelled
CI / build-armv7 (push) Has been cancelled
CI / publish-images (push) Has been cancelled
CI / publish-release (push) Has been cancelled

Addresses https://github.com/Donkie/Spoolman/issues/671

Changes:
- Remove fixed 50% max-width constraint on QR code container
- Add qrCodePadding setting (0-10mm, default 2mm) for white space
- Add qrCodeMaxWidth setting (0-100%, 0 = auto/fit-content)
- Add UI controls (slider + input) for both new settings
- Settings are disabled when QR code is turned off

The previous behavior forced QR codes to 50% width when label text
was shown, wasting label space on small labels. New default uses
fit-content for optimal sizing while allowing manual control.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-14 19:57:52 -06:00
parent cbb2940193
commit d17a66b0ec
3 changed files with 80 additions and 3 deletions

View File

@@ -123,7 +123,12 @@
"no": "No",
"simple": "Simple",
"withIcon": "With Icon"
}
},
"qrCodePadding": "QR Code Padding",
"qrCodePaddingTooltip": "White space around the QR code for better scanning reliability",
"qrCodeMaxWidth": "QR Code Max Width",
"qrCodeMaxWidthTooltip": "Maximum width of QR code as percentage of label. Set to 0 for automatic sizing.",
"auto": "Auto"
},
"spoolSelect": {
"title": "Select Spools",

View File

@@ -22,6 +22,8 @@ export interface QRCodePrintSettings {
showContent?: boolean;
showQRCodeMode?: "no" | "simple" | "withIcon";
textSize?: number;
qrCodePadding?: number; // in mm, default 2
qrCodeMaxWidth?: number; // percentage 0-100, 0 = no constraint (auto)
printSettings: PrintSettings;
}

View File

@@ -41,6 +41,8 @@ const QRCodePrintingDialog: React.FC<QRCodePrintingDialogProps> = ({
const showContent = printSettings?.showContent === undefined ? true : printSettings?.showContent;
const showQRCodeMode = printSettings?.showQRCodeMode || "withIcon";
const textSize = printSettings?.textSize || 3;
const qrCodePadding = printSettings?.qrCodePadding ?? 2;
const qrCodeMaxWidth = printSettings?.qrCodeMaxWidth ?? 0; // 0 = auto (no constraint)
const elements = items.map((item) => {
return (
@@ -155,6 +157,73 @@ const QRCodePrintingDialog: React.FC<QRCodePrintingDialogProps> = ({
</Col>
</Row>
</Form.Item>
<Form.Item label={t("printing.qrcode.qrCodePadding")} tooltip={t("printing.qrcode.qrCodePaddingTooltip")}>
<Row>
<Col span={12}>
<Slider
disabled={showQRCodeMode === "no"}
tooltip={{ formatter: (value) => `${value} mm` }}
min={0}
max={5}
value={qrCodePadding}
step={0.5}
onChange={(value) => {
printSettings.qrCodePadding = value;
setPrintSettings(printSettings);
}}
/>
</Col>
<Col span={12}>
<InputNumber
disabled={showQRCodeMode === "no"}
min={0}
max={10}
step={0.5}
style={{ margin: "0 16px" }}
value={qrCodePadding}
addonAfter="mm"
onChange={(value) => {
printSettings.qrCodePadding = value ?? 2;
setPrintSettings(printSettings);
}}
/>
</Col>
</Row>
</Form.Item>
<Form.Item label={t("printing.qrcode.qrCodeMaxWidth")} tooltip={t("printing.qrcode.qrCodeMaxWidthTooltip")}>
<Row>
<Col span={12}>
<Slider
disabled={showQRCodeMode === "no"}
tooltip={{ formatter: (value) => (value === 0 ? t("printing.qrcode.auto") : `${value}%`) }}
min={0}
max={100}
value={qrCodeMaxWidth}
step={5}
onChange={(value) => {
printSettings.qrCodeMaxWidth = value;
setPrintSettings(printSettings);
}}
/>
</Col>
<Col span={12}>
<InputNumber
disabled={showQRCodeMode === "no"}
min={0}
max={100}
step={5}
style={{ margin: "0 16px" }}
value={qrCodeMaxWidth}
addonAfter="%"
placeholder={t("printing.qrcode.auto")}
onChange={(value) => {
printSettings.qrCodeMaxWidth = value ?? 0;
setPrintSettings(printSettings);
}}
/>
</Col>
</Row>
</Form.Item>
{extraSettings}
</>
@@ -168,14 +237,15 @@ const QRCodePrintingDialog: React.FC<QRCodePrintingDialogProps> = ({
}
.print-page .print-qrcode-container {
max-width: ${showContent ? "50%" : "100%"};
max-width: ${qrCodeMaxWidth > 0 ? `${qrCodeMaxWidth}%` : "fit-content"};
display: flex;
flex-shrink: 0;
}
.print-page .print-qrcode {
width: auto !important;
height: auto !important;
padding: 2mm;
padding: ${qrCodePadding}mm;
}
.print-page .print-qrcode-title {