3 Commits

Author SHA1 Message Date
f8a008a105 Reorganize folders, interface for both cli parser and core module
Some checks failed
Build ptprnt / build (push) Failing after 41s
2025-10-13 21:00:16 +02:00
81b0f25f32 Fix multiple lines and printer selection 2025-10-13 20:35:58 +02:00
69810e1c5c Refactor cli setup and printer selection logic into separate classes
All checks were successful
Build ptprnt / build (push) Successful in 3m49s
2025-10-13 20:29:14 +02:00
28 changed files with 119 additions and 110 deletions

View File

@@ -88,7 +88,6 @@
}, },
"clangd.onConfigChanged": "restart", "clangd.onConfigChanged": "restart",
"cSpell.words": [ "cSpell.words": [
"fakelabel",
"fontsize", "fontsize",
"halign", "halign",
"libusb", "libusb",

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2025 Moritz Martinius Copyright (C) 2024-2025 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2025 Moritz Martinius Copyright (C) 2024-2025 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -23,10 +23,10 @@
#include <spdlog/sinks/stdout_color_sinks.h> #include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include "PrinterDriverFactory.hpp"
#include "cli/CliParser.hpp" #include "cli/CliParser.hpp"
#include "cli/interface/ICliParser.hpp" #include "cli/interface/ICliParser.hpp"
#include "constants.hpp" #include "constants.hpp"
#include "core/PrinterDriverFactory.hpp"
#include "core/PrinterService.hpp" #include "core/PrinterService.hpp"
#include "core/interface/IPrinterService.hpp" #include "core/interface/IPrinterService.hpp"
#include "graphics/LabelBuilder.hpp" #include "graphics/LabelBuilder.hpp"

View File

@@ -21,7 +21,7 @@
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include "core/PrinterDriverFactory.hpp" #include "PrinterDriverFactory.hpp"
namespace ptprnt::core { namespace ptprnt::core {

View File

@@ -23,9 +23,9 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "../printers/interface/IPrinterDriver.hpp"
#include "interface/IPrinterService.hpp" #include "interface/IPrinterService.hpp"
#include "libusbwrap/UsbDeviceFactory.hpp" #include "../libusbwrap/UsbDeviceFactory.hpp"
#include "printers/interface/IPrinterDriver.hpp"
namespace ptprnt::core { namespace ptprnt::core {

View File

@@ -23,8 +23,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "graphics/interface/ILabel.hpp" #include "../../printers/interface/IPrinterDriver.hpp"
#include "printers/interface/IPrinterDriver.hpp" #include "../../graphics/interface/ILabel.hpp"
namespace ptprnt::core { namespace ptprnt::core {

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2025 Moritz Martinius Copyright (C) 2023-2025 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2025 Moritz Martinius Copyright (C) 2023-2025 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2025 Moritz Martinius Copyright (C) 2024-2025 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2023-2025 Moritz Martinius Copyright (C) 2023-2024 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2023-2025 Moritz Martinius Copyright (C) 2023-2024 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2023-2025 Moritz Martinius Copyright (C) 2023-2024 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2023-2025 Moritz Martinius Copyright (C) 2023 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2023-2025 Moritz Martinius Copyright (C) 2023-2024 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2023-2025 Moritz Martinius Copyright (C) 2023 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2022-2025 Moritz Martinius Copyright (C) 2022-2023 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,34 +1,34 @@
ptprnt_hpps = files( ptprnt_hpps = files (
'cli/CliParser.hpp', 'libusbwrap/interface/IUsbDeviceFactory.hpp',
'core/PrinterDriverFactory.hpp', 'libusbwrap/interface/IUsbDevice.hpp',
'core/PrinterService.hpp', 'libusbwrap/UsbDeviceFactory.hpp',
'libusbwrap/LibUsbTypes.hpp',
'libusbwrap/UsbDevice.hpp',
'interface/IPrinterDriver.hpp',
'interface/IPrinterTypes.hpp',
'printers/P700Printer.hpp',
'printers/FakePrinter.hpp',
'PtouchPrint.hpp',
'PrinterDriverFactory.hpp',
'graphics/Bitmap.hpp', 'graphics/Bitmap.hpp',
'graphics/Label.hpp', 'graphics/Label.hpp',
'graphics/LabelBuilder.hpp', 'graphics/LabelBuilder.hpp',
'graphics/Monochrome.hpp', 'graphics/Monochrome.hpp',
'libusbwrap/LibUsbTypes.hpp', 'cli/CliParser.hpp',
'libusbwrap/UsbDevice.hpp', 'core/PrinterService.hpp'
'libusbwrap/UsbDeviceFactory.hpp',
'libusbwrap/interface/IUsbDevice.hpp',
'libusbwrap/interface/IUsbDeviceFactory.hpp',
'printers/FakePrinter.hpp',
'printers/P700Printer.hpp',
'printers/interface/IPrinterDriver.hpp',
'printers/interface/IPrinterTypes.hpp',
'PtouchPrint.hpp',
) )
ptprnt_srcs = files( ptprnt_srcs = files (
'cli/CliParser.cpp', 'PtouchPrint.cpp',
'core/PrinterDriverFactory.cpp', 'PrinterDriverFactory.cpp',
'core/PrinterService.cpp', 'printers/P700Printer.cpp',
'graphics/Bitmap.cpp', 'printers/FakePrinter.cpp',
'graphics/Label.cpp', 'graphics/Label.cpp',
'graphics/LabelBuilder.cpp', 'graphics/LabelBuilder.cpp',
'graphics/Bitmap.cpp',
'graphics/Monochrome.cpp', 'graphics/Monochrome.cpp',
'libusbwrap/UsbDevice.cpp',
'libusbwrap/UsbDeviceFactory.cpp', 'libusbwrap/UsbDeviceFactory.cpp',
'printers/FakePrinter.cpp', 'libusbwrap/UsbDevice.cpp',
'printers/P700Printer.cpp', 'cli/CliParser.cpp',
'PtouchPrint.cpp', 'core/PrinterService.cpp'
) )

View File

@@ -19,25 +19,27 @@
#include "FakePrinter.hpp" #include "FakePrinter.hpp"
#include <cairo.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <cairo.h>
#include <chrono>
#include <cstdint> #include <cstdint>
#include <iomanip>
#include <sstream>
#include <stdexcept> #include <stdexcept>
#include <vector> #include <vector>
#include <chrono>
#include <iomanip>
#include <sstream>
#include "graphics/Monochrome.hpp" #include "../graphics/Monochrome.hpp"
namespace ptprnt::printer { namespace ptprnt::printer {
const PrinterInfo FakePrinter::mInfo = {.driverName = "FakePrinter", const PrinterInfo FakePrinter::mInfo = {
.driverName = "FakePrinter",
.name = "Virtual Test Printer", .name = "Virtual Test Printer",
.version = "v1.0", .version = "v1.0",
.usbId{0x0000, 0x0000}, // No USB ID - virtual printer created explicitly .usbId{0x0000, 0x0000}, // No USB ID - virtual printer created explicitly
.pixelLines = 128}; .pixelLines = 128
};
const std::string_view FakePrinter::getDriverName() { const std::string_view FakePrinter::getDriverName() {
return mInfo.driverName; return mInfo.driverName;
@@ -92,8 +94,8 @@ bool FakePrinter::printMonochromeData(const graphics::MonochromeData& data) {
auto printed = simulatePrinting(data); auto printed = simulatePrinting(data);
mLastPrint = std::make_unique<graphics::Bitmap<graphics::ALPHA8>>(std::move(printed)); mLastPrint = std::make_unique<graphics::Bitmap<graphics::ALPHA8>>(std::move(printed));
spdlog::info("FakePrinter: Successfully 'printed' label ({}x{} pixels)", mLastPrint->getWidth(), spdlog::info("FakePrinter: Successfully 'printed' label ({}x{} pixels)",
mLastPrint->getHeight()); mLastPrint->getWidth(), mLastPrint->getHeight());
// Save to timestamped PNG file // Save to timestamped PNG file
std::string filename = generateTimestampedFilename(); std::string filename = generateTimestampedFilename();
@@ -118,8 +120,7 @@ bool FakePrinter::printLabel(const std::unique_ptr<graphics::ILabel> label) {
// Transform to portrait orientation for printing // Transform to portrait orientation for printing
monoData.transformTo(graphics::Orientation::PORTRAIT); monoData.transformTo(graphics::Orientation::PORTRAIT);
spdlog::debug("FakePrinter: Label surface is {}x{}, transformed to portrait", label->getWidth(), spdlog::debug("FakePrinter: Label surface is {}x{}, transformed to portrait", label->getWidth(), label->getHeight());
label->getHeight());
return printMonochromeData(monoData); return printMonochromeData(monoData);
} }
@@ -176,8 +177,8 @@ graphics::Bitmap<graphics::ALPHA8> FakePrinter::simulatePrinting(const graphics:
// Set the pixels in the result bitmap // Set the pixels in the result bitmap
result.setPixels(pixels); result.setPixels(pixels);
spdlog::debug("FakePrinter: Simulation complete, reconstructed {}x{} bitmap", result.getWidth(), spdlog::debug("FakePrinter: Simulation complete, reconstructed {}x{} bitmap",
result.getHeight()); result.getWidth(), result.getHeight());
return result; return result;
} }
@@ -217,8 +218,13 @@ bool FakePrinter::saveBitmapToPng(const graphics::Bitmap<graphics::ALPHA8>& bitm
// Create Cairo surface // Create Cairo surface
int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
cairo_surface_t* surface = cairo_image_surface_create_for_data(reinterpret_cast<unsigned char*>(argbPixels.data()), cairo_surface_t* surface = cairo_image_surface_create_for_data(
CAIRO_FORMAT_ARGB32, width, height, stride); reinterpret_cast<unsigned char*>(argbPixels.data()),
CAIRO_FORMAT_ARGB32,
width,
height,
stride
);
if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) { if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
spdlog::error("FakePrinter: Failed to create Cairo surface: {}", spdlog::error("FakePrinter: Failed to create Cairo surface: {}",
@@ -247,7 +253,9 @@ std::string FakePrinter::generateTimestampedFilename() const {
// Format: fakelabel_YYYYMMDD_HHMMSS.png // Format: fakelabel_YYYYMMDD_HHMMSS.png
std::stringstream ss; std::stringstream ss;
ss << "fakelabel_" << std::put_time(std::localtime(&time), "%Y%m%d_%H%M%S") << ".png"; ss << "fakelabel_"
<< std::put_time(std::localtime(&time), "%Y%m%d_%H%M%S")
<< ".png";
return ss.str(); return ss.str();
} }

View File

@@ -19,15 +19,15 @@
#pragma once #pragma once
#include <cstdint>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <cstdint>
#include "graphics/Bitmap.hpp"
#include "interface/IPrinterDriver.hpp" #include "interface/IPrinterDriver.hpp"
#include "interface/IPrinterTypes.hpp" #include "interface/IPrinterTypes.hpp"
#include "libusbwrap/LibUsbTypes.hpp" #include "../libusbwrap/LibUsbTypes.hpp"
#include "libusbwrap/interface/IUsbDevice.hpp" #include "../libusbwrap/interface/IUsbDevice.hpp"
#include "../graphics/Bitmap.hpp"
namespace ptprnt::printer { namespace ptprnt::printer {

View File

@@ -28,9 +28,9 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
#include "graphics/Bitmap.hpp" #include "../graphics/Bitmap.hpp"
#include "graphics/Monochrome.hpp" #include "../graphics/Monochrome.hpp"
#include "libusbwrap/LibUsbTypes.hpp" #include "../libusbwrap/LibUsbTypes.hpp"
#include "spdlog/fmt/bin_to_hex.h" #include "spdlog/fmt/bin_to_hex.h"
namespace ptprnt::printer { namespace ptprnt::printer {

View File

@@ -27,8 +27,8 @@
#include "interface/IPrinterDriver.hpp" #include "interface/IPrinterDriver.hpp"
#include "interface/IPrinterTypes.hpp" #include "interface/IPrinterTypes.hpp"
#include "libusbwrap/LibUsbTypes.hpp" #include "../libusbwrap/LibUsbTypes.hpp"
#include "libusbwrap/interface/IUsbDevice.hpp" #include "../libusbwrap/interface/IUsbDevice.hpp"
namespace ptprnt::printer { namespace ptprnt::printer {
namespace p700::commands { namespace p700::commands {

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2025 Moritz Martinius Copyright (C) 2023-2025 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -22,11 +22,11 @@
#include <memory> #include <memory>
#include <string_view> #include <string_view>
#include "../../graphics/Bitmap.hpp"
#include "../../graphics/Monochrome.hpp"
#include "../../graphics/interface/ILabel.hpp"
#include "../../libusbwrap/interface/IUsbDevice.hpp"
#include "IPrinterTypes.hpp" #include "IPrinterTypes.hpp"
#include "graphics/Bitmap.hpp"
#include "graphics/Monochrome.hpp"
#include "graphics/interface/ILabel.hpp"
#include "libusbwrap/interface/IUsbDevice.hpp"
namespace ptprnt { namespace ptprnt {
class IPrinterDriver { class IPrinterDriver {

View File

@@ -1,6 +1,6 @@
/* /*
ptrnt - print labels on linux ptrnt - print labels on linux
Copyright (C) 2025 Moritz Martinius Copyright (C) 2023-2024 Moritz Martinius
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <string>
#include <string_view> #include <string_view>
#include <vector> #include <vector>

0
src/ptprnt.log Normal file
View File

View File

@@ -1,10 +1,9 @@
[wrap-file] [wrap-file]
directory = CLI11-2.5.0 directory = CLI11-2.3.2
source_url = https://github.com/CLIUtils/CLI11/archive/refs/tags/v2.5.0.tar.gz source_url = https://github.com/CLIUtils/CLI11/archive/refs/tags/v2.3.2.tar.gz
source_filename = CLI11-2.5.0.tar.gz source_filename = CLI11-2.3.2.tar.gz
source_hash = 17e02b4cddc2fa348e5dbdbb582c59a3486fa2b2433e70a0c3bacb871334fd55 source_hash = aac0ab42108131ac5d3344a9db0fdf25c4db652296641955720a4fbe52334e22
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/cli11_2.5.0-2/CLI11-2.5.0.tar.gz wrapdb_version = 2.3.2-1
wrapdb_version = 2.5.0-2
[provide] [provide]
dependency_names = CLI11 cli11 = CLI11_dep

View File

@@ -1,13 +1,13 @@
[wrap-file] [wrap-file]
directory = googletest-1.17.0 directory = googletest-1.14.0
source_url = https://github.com/google/googletest/archive/refs/tags/v1.17.0.tar.gz source_url = https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz
source_filename = googletest-1.17.0.tar.gz source_filename = gtest-1.14.0.tar.gz
source_hash = 65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c source_hash = 8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7
patch_filename = gtest_1.17.0-4_patch.zip patch_filename = gtest_1.14.0-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.17.0-4/get_patch patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.14.0-1/get_patch
patch_hash = 3abf7662d09db706453a5b064a1e914678c74b9d9b0b19382747ca561d0d8750 patch_hash = 2e693c7d3f9370a7aa6dac802bada0874d3198ad4cfdf75647b818f691182b50
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/gtest_1.17.0-4/googletest-1.17.0.tar.gz source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/gtest_1.14.0-1/gtest-1.14.0.tar.gz
wrapdb_version = 1.17.0-4 wrapdb_version = 1.14.0-1
[provide] [provide]
gtest = gtest_dep gtest = gtest_dep

View File

@@ -36,3 +36,5 @@ foreach test : tests
), ),
) )
endforeach endforeach