Multilabel support & Label refactoring (#17)
All checks were successful
Build ptprnt / build (push) Successful in 3m47s
All checks were successful
Build ptprnt / build (push) Successful in 3m47s
Reviewed-on: moritz/ptouch-prnt#17
This commit was merged in pull request #17.
This commit is contained in:
@@ -45,7 +45,15 @@ std::vector<std::shared_ptr<IPrinterDriver>> PrinterService::detectPrinters() {
|
||||
for (auto& usbDev : usbDevs) {
|
||||
auto driver = driverFactory->create(usbDev->getUsbId());
|
||||
if (driver != nullptr) {
|
||||
mDetectedPrinters.push_back(driver);
|
||||
// Attach the USB device to the printer driver
|
||||
// Convert unique_ptr to shared_ptr for attachment
|
||||
std::shared_ptr<libusbwrap::IUsbDevice> sharedUsbDev = std::move(usbDev);
|
||||
if (driver->attachUsbDevice(sharedUsbDev)) {
|
||||
mDetectedPrinters.push_back(driver);
|
||||
spdlog::debug("Successfully attached USB device to printer driver: {}", driver->getName());
|
||||
} else {
|
||||
spdlog::warn("Failed to attach USB device to printer driver: {}", driver->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +67,9 @@ std::shared_ptr<IPrinterDriver> PrinterService::selectPrinter(const std::string&
|
||||
auto driverFactory = std::make_unique<PrinterDriverFactory>();
|
||||
auto printer = driverFactory->createByName(printerName);
|
||||
if (printer) {
|
||||
// For virtual/fake printers, call attachUsbDevice with nullptr to initialize
|
||||
// For real printers selected explicitly, they would need actual USB device
|
||||
printer->attachUsbDevice(nullptr);
|
||||
mCurrentPrinter = printer;
|
||||
spdlog::info("Using explicitly selected printer: {}", printerName);
|
||||
return mCurrentPrinter;
|
||||
|
||||
Reference in New Issue
Block a user