diff --git a/.gitignore b/.gitignore index 7b47731..2bb0631 100644 --- a/.gitignore +++ b/.gitignore @@ -45,12 +45,17 @@ NUL # vscode .vscode .clang-format +.cache/ compile_commands.json # AI .roomodes project_journal/ .roo/ +.cursor/ +.kiro/ +.specstory/ +.claude/ # deepin-IDE .unioncode @@ -66,3 +71,7 @@ project_journal/ *.tar.gz *.log *.substvars + +# OpenMemory - IDE/Assistant specific rules +.qoder/rules/openmemory.md +CLAUDE.md diff --git a/src/device/scannerdevice.cpp b/src/device/scannerdevice.cpp index 1186c09..214d8f0 100644 --- a/src/device/scannerdevice.cpp +++ b/src/device/scannerdevice.cpp @@ -18,7 +18,7 @@ using namespace DDLog; -#define ADD_TEST_DEVICE 1 +#define ADD_TEST_DEVICE 0 // ================================================================= // ScannerDevice Implementation (UI Thread) @@ -200,6 +200,38 @@ QList ScannerDevice::getSupportedResolutions() return m_supportedResolutions; } +// Paper size methods +void ScannerDevice::setPaperSize(PaperSize size) +{ + m_currentPaperSize = size; +} + +ScannerDevice::PaperSize ScannerDevice::getPaperSize() const +{ + return m_currentPaperSize; +} + +QSizeF ScannerDevice::getPaperSizeDimensions(PaperSize size) +{ + switch(size) { + case PAPER_SIZE_A3: + return QSizeF(297, 420); // A3: 297×420mm (standard ISO size) + case PAPER_SIZE_A4: + return QSizeF(210, 297); // A4: 210×297mm (standard ISO size) + case PAPER_SIZE_A5: + return QSizeF(148, 210); // A5: 148×210mm (standard ISO size) + case PAPER_SIZE_A6: + return QSizeF(105, 148); // A6: 105×148mm (standard ISO size) + case PAPER_SIZE_B4: + return QSizeF(250, 353); // B4: 250×353mm (standard ISO size) + case PAPER_SIZE_B5: + return QSizeF(176, 250); // B5: 176×250mm (standard ISO size) + case PAPER_SIZE_AUTO: + default: + return QSizeF(210, 297); // Default to A4 + } +} + // --- SLOTS to handle results from worker --- void ScannerDevice::onWorkerError(const QString &errorMessage) diff --git a/src/device/scannerdevice.h b/src/device/scannerdevice.h index bcd2cf9..37ac200 100644 --- a/src/device/scannerdevice.h +++ b/src/device/scannerdevice.h @@ -29,6 +29,17 @@ class ScannerDevice : public DeviceBase SCAN_MODE_ADF_DUPLEX // ADF duplex scan }; Q_ENUM(ScanMode) + + enum PaperSize { + PAPER_SIZE_AUTO = 0, // Auto detect + PAPER_SIZE_A4 = 1, // 210×297mm + PAPER_SIZE_A3 = 2, // 297×420mm + PAPER_SIZE_A5 = 3, // 148×210mm + PAPER_SIZE_A6 = 4, // 105×148mm + PAPER_SIZE_B4 = 5, // 250×353mm + PAPER_SIZE_B5 = 6 // 176×250mm + }; + Q_ENUM(PaperSize) explicit ScannerDevice(QObject *parent = nullptr); ~ScannerDevice() override; @@ -52,6 +63,11 @@ class ScannerDevice : public DeviceBase bool setResolution(int dpi); int getResolution() const; QList getSupportedResolutions(); + + // Paper size methods + void setPaperSize(PaperSize size); + PaperSize getPaperSize() const; + static QSizeF getPaperSizeDimensions(PaperSize size); // Returns size in mm signals: // Signals to trigger worker operations @@ -85,6 +101,7 @@ private slots: QList m_supportedScanModes; int m_currentResolutionDPI = 300; ScanMode m_currentScanMode = SCAN_MODE_FLATBED; + PaperSize m_currentPaperSize = PAPER_SIZE_A4; }; // --- Worker Class for background scanning --- diff --git a/src/libofd/include/ofd/ofd_writer.h b/src/libofd/include/ofd/ofd_writer.h index ae21802..60cdbed 100644 --- a/src/libofd/include/ofd/ofd_writer.h +++ b/src/libofd/include/ofd/ofd_writer.h @@ -27,25 +27,31 @@ class Writer bool createFromImages(const QString &outputPath, const QVector &images, float leftMargin = 0.0f, - float topMargin = 0.0f); + float topMargin = 0.0f, + float pageWidth = 210.0f, + float pageHeight = 297.0f); private: void createOFDXmlFile(const QString &path); void createDocFile(const QString &path, float leftM, float topM, - const QVector &images); + const QVector &images, + float pageWidth = 210.0f, float pageHeight = 297.0f); void createResourceFiles(const QString &path, const QVector &images); // XML写入辅助函数 - void writeDocumentHeader(QTextStream &stream, int maxId); + void writeDocumentHeader(QTextStream &stream, int maxId, + float pageWidth = 210.0f, float pageHeight = 297.0f); void writeDocumentFooter(QTextStream &stream); void writePublicResHeader(QTextStream &stream); void writePublicResFooter(QTextStream &stream, bool hasImages); void writePage(QTextStream &docStream, QTextStream &publicResStream, const QString &pagesPath, const QVector &images, - int pageIndex, float leftM, float topM, int ¤tId); + int pageIndex, float leftM, float topM, int ¤tId, + float pageWidth = 210.0f, float pageHeight = 297.0f); void createPageContent(const QString &path, const QString &minX, const QString &minY, const QString &maxX, - const QString &maxY, int &id, bool hasImage); + const QString &maxY, int &id, bool hasImage, + float pageWidth = 210.0f, float pageHeight = 297.0f); // 压缩相关函数 bool compressOFD(const QString &outputPath, const QString &sourcePath); @@ -56,7 +62,8 @@ class Writer bool removeDir(const QString &dirPath); // 图像处理辅助函数 - QSize calculateImageSize(const QImage &image, float leftM, float topM); + QSize calculateImageSize(const QImage &image, float leftM, float topM, + float pageWidth = 210.0f, float pageHeight = 297.0f); }; } // namespace ofd diff --git a/src/libofd/src/ofd_writer.cpp b/src/libofd/src/ofd_writer.cpp index e3af2f8..59ac64b 100644 --- a/src/libofd/src/ofd_writer.cpp +++ b/src/libofd/src/ofd_writer.cpp @@ -40,7 +40,9 @@ Writer::~Writer() {} bool Writer::createFromImages(const QString &outputPath, const QVector &images, float leftMargin, - float topMargin) + float topMargin, + float pageWidth, + float pageHeight) { QFileInfo fileInfo(outputPath); QString tempPath = QDir::tempPath() + QDir::separator() + fileInfo.baseName(); @@ -51,7 +53,7 @@ bool Writer::createFromImages(const QString &outputPath, QString basePath = tempPath + QDir::separator(); createOFDXmlFile(basePath); - createDocFile(basePath, leftMargin, topMargin, images); + createDocFile(basePath, leftMargin, topMargin, images, pageWidth, pageHeight); bool success = compressOFD(outputPath, tempPath); removeDir(tempPath); @@ -92,14 +94,14 @@ void Writer::createOFDXmlFile(const QString &path) file.close(); } -void Writer::writeDocumentHeader(QTextStream &stream, int maxId) +void Writer::writeDocumentHeader(QTextStream &stream, int maxId, float pageWidth, float pageHeight) { stream << "\n" << "\n" << " \n" << " " << maxId << "\n" << " \n" - << " 0.00 0.00 " << PAGE_WIDTH << " " << PAGE_HEIGHT << "\n" + << " 0.00 0.00 " << pageWidth << " " << pageHeight << "\n" << " \n" << " PublicRes.xml\n" << " \n" @@ -129,7 +131,8 @@ void Writer::writePublicResFooter(QTextStream &stream, bool hasImages) stream << "\n"; } -QSize Writer::calculateImageSize(const QImage &image, float leftM, float topM) +QSize Writer::calculateImageSize(const QImage &image, float leftM, float topM, + float pageWidth, float pageHeight) { double width = (double)image.width() * 1000 / image.dotsPerMeterX(); double height = (double)image.height() * 1000 / image.dotsPerMeterY(); @@ -137,7 +140,7 @@ QSize Writer::calculateImageSize(const QImage &image, float leftM, float topM) double scaledWidth = width * DPI_FACTOR; double scaledHeight = height * DPI_FACTOR; - QRect pageRect(leftM * 25.4, topM * 25.4, PAGE_WIDTH * 25.4, PAGE_HEIGHT * 25.4); + QRect pageRect(leftM * 25.4, topM * 25.4, pageWidth * 25.4, pageHeight * 25.4); QSize size(scaledWidth, scaledHeight); size.scale(pageRect.size(), Qt::KeepAspectRatio); @@ -147,7 +150,9 @@ QSize Writer::calculateImageSize(const QImage &image, float leftM, float topM) void Writer::createDocFile(const QString &path, float leftM, float topM, - const QVector &images) + const QVector &images, + float pageWidth, + float pageHeight) { QString docPath = path + DOC_DIR; QDir(docPath).mkpath("."); @@ -175,7 +180,7 @@ void Writer::createDocFile(const QString &path, int maxId = images.isEmpty() ? 5 : 2 + images.count() * 5; int currentId = 1; - writeDocumentHeader(docStream, maxId); + writeDocumentHeader(docStream, maxId, pageWidth, pageHeight); writePublicResHeader(publicResStream); if (!images.isEmpty()) { @@ -187,7 +192,7 @@ void Writer::createDocFile(const QString &path, pagesPath += QDir::separator(); for (int i = 0; i < (images.isEmpty() ? 1 : images.size()); ++i) { - writePage(docStream, publicResStream, pagesPath, images, i, leftM, topM, currentId); + writePage(docStream, publicResStream, pagesPath, images, i, leftM, topM, currentId, pageWidth, pageHeight); } writeDocumentFooter(docStream); @@ -199,7 +204,8 @@ void Writer::createDocFile(const QString &path, void Writer::writePage(QTextStream &docStream, QTextStream &publicResStream, const QString &pagesPath, const QVector &images, - int pageIndex, float leftM, float topM, int ¤tId) + int pageIndex, float leftM, float topM, int ¤tId, + float pageWidth, float pageHeight) { docStream << QString("") .arg(currentId).arg(pageIndex); @@ -209,17 +215,17 @@ void Writer::writePage(QTextStream &docStream, QTextStream &publicResStream, QString contentPath = pageDirPath + QDir::separator() + "Content.xml"; if (images.isEmpty()) { - createPageContent(contentPath, "0", "0", "0", "0", currentId, false); + createPageContent(contentPath, "0", "0", "0", "0", currentId, false, pageWidth, pageHeight); } else { const QImage &image = images.at(pageIndex); - QSize size = calculateImageSize(image, leftM, topM); + QSize size = calculateImageSize(image, leftM, topM, pageWidth, pageHeight); QString maxWidth = QString::number(size.width() / 25.4 - leftM, 'f', 2); QString maxHeight = QString::number(size.height() / 25.4 - topM, 'f', 2); QString minX = QString::number(leftM, 'f', 2); QString minY = QString::number(topM, 'f', 2); - createPageContent(contentPath, minX, minY, maxWidth, maxHeight, currentId, true); + createPageContent(contentPath, minX, minY, maxWidth, maxHeight, currentId, true, pageWidth, pageHeight); publicResStream << QString(" \n").arg(currentId) << QString(" Image_%1.png\n").arg(pageIndex + 1) @@ -230,7 +236,8 @@ void Writer::writePage(QTextStream &docStream, QTextStream &publicResStream, void Writer::createPageContent(const QString &path, const QString &minX, const QString &minY, const QString &maxX, - const QString &maxY, int &id, bool hasImage) + const QString &maxY, int &id, bool hasImage, + float pageWidth, float pageHeight) { QFile file(path); if (!file.open(QIODevice::WriteOnly)) { @@ -247,7 +254,7 @@ void Writer::createPageContent(const QString &path, const QString &minX, stream << "\n" << "\n" << " \n" - << " 0.00 0.00 " << PAGE_WIDTH << " " << PAGE_HEIGHT << "\n" + << " 0.00 0.00 " << pageWidth << " " << pageHeight << "\n" << " \n" << " \n" << QString(" \n").arg(id++); @@ -255,14 +262,14 @@ void Writer::createPageContent(const QString &path, const QString &minX, // 背景路径对象 stream << QString(" \n" << " \n" << " M 0.00 0.00 L " - << PAGE_WIDTH + 0.01 << " 0.00 L " - << PAGE_WIDTH + 0.01 << " " << PAGE_HEIGHT << " L " - << "0.00 " << PAGE_HEIGHT << " L " + << pageWidth + 0.01 << " 0.00 L " + << pageWidth + 0.01 << " " << pageHeight << " L " + << "0.00 " << pageHeight << " L " << "0.00 0.00 C \n" << " \n"; diff --git a/src/ui/scanwidget.cpp b/src/ui/scanwidget.cpp index fe4bbd1..93077b6 100644 --- a/src/ui/scanwidget.cpp +++ b/src/ui/scanwidget.cpp @@ -17,6 +17,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include @@ -123,6 +128,17 @@ void ScanWidget::setupUI() formatLayout->addWidget(m_formatCombo); groupLayout->addLayout(formatLayout); + // Paper size options + m_paperSizeLabel = new DLabel(tr("Paper Size")); + m_paperSizeLabel->setFixedWidth(SETTING_LABEL_WIDTH); + m_paperSizeCombo = new QComboBox(); + m_paperSizeCombo->setMaximumWidth(SETTING_COMBO_WIDTH); + QHBoxLayout *paperSizeLayout = new QHBoxLayout(); + paperSizeLayout->setSpacing(20); + paperSizeLayout->addWidget(m_paperSizeLabel); + paperSizeLayout->addWidget(m_paperSizeCombo); + groupLayout->addLayout(paperSizeLayout); + settingsLayout->addWidget(settingsGroup); settingsLayout->addSpacing(20); @@ -196,6 +212,7 @@ void ScanWidget::setupDeviceMode(DeviceBase* device, QString name) m_resolutionCombo->clear(); m_colorCombo->clear(); m_formatCombo->clear(); + m_paperSizeCombo->clear(); m_device = device; if (m_isScanner) { @@ -210,10 +227,23 @@ void ScanWidget::setupDeviceMode(DeviceBase* device, QString name) const QStringList colorModes = { tr("Color"), tr("Grayscale"), tr("Black White") }; m_colorCombo->addItems(colorModes); m_formatCombo->addItems(FORMATS); + + // Add paper size options + const QStringList paperSizes = { + tr("Auto"), + "A4 (210×297mm)", + "A3 (297×420mm)", + "A5 (148×210mm)", + "A6 (105×148mm)", + "B4 (250×353mm)", + "B5 (176×250mm)" + }; + m_paperSizeCombo->addItems(paperSizes); // 设置初始选中项 m_colorCombo->setCurrentIndex(m_imageSettings->colorMode); m_formatCombo->setCurrentIndex(m_imageSettings->format); + m_paperSizeCombo->setCurrentIndex(m_imageSettings->paperSize); updateDeviceSettings(); @@ -240,6 +270,7 @@ void ScanWidget::connectDeviceSignals(bool bind) connect(m_resolutionCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &ScanWidget::onResolutionChanged); connect(m_colorCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &ScanWidget::onColorModeChanged); connect(m_formatCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &ScanWidget::onFormatChanged); + connect(m_paperSizeCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &ScanWidget::onPaperSizeChanged); } else { disconnect(m_device, &DeviceBase::previewUpdated, this, &ScanWidget::onUpdatePreview); disconnect(m_device, &DeviceBase::imageCaptured, this, &ScanWidget::onScanFinished); @@ -256,6 +287,7 @@ void ScanWidget::connectDeviceSignals(bool bind) disconnect(m_resolutionCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &ScanWidget::onResolutionChanged); disconnect(m_colorCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &ScanWidget::onColorModeChanged); disconnect(m_formatCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &ScanWidget::onFormatChanged); + disconnect(m_paperSizeCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &ScanWidget::onPaperSizeChanged); } } @@ -420,6 +452,21 @@ void ScanWidget::onFormatChanged(int index) emit deviceSettingsChanged(); } +void ScanWidget::onPaperSizeChanged(int index) +{ + m_imageSettings->paperSize = index; + + // Update scanner device paper size + if (m_device && m_isScanner) { + auto scanner = dynamic_cast(m_device); + if (scanner) { + scanner->setPaperSize(static_cast(index)); + } + } + + emit deviceSettingsChanged(); +} + QString ScanWidget::getSaveDirectory() { if (m_saveDir.isEmpty()) { @@ -469,6 +516,34 @@ void ScanWidget::onScanFinished(const QImage &image) // 使用改进的黑白转换算法 processedImage = convertToBlackWhite(image); } + + // Paper size handling + ScannerDevice::PaperSize targetPaperSize = static_cast(m_imageSettings->paperSize); + + // Get current DPI for scaling + int currentDPI = 300; // Default DPI + if (m_device && m_isScanner) { + auto scanner = dynamic_cast(m_device); + if (scanner) { + currentDPI = scanner->getResolution(); + } + } + + // Handle paper size detection and scaling + if (targetPaperSize == ScannerDevice::PAPER_SIZE_AUTO) { + // Auto-detect paper size + ScannerDevice::PaperSize detectedSize = detectPaperSize(processedImage); + qDebug() << "Auto-detected paper size:" << detectedSize; + + // Scale to detected size if needed + if (detectedSize != ScannerDevice::PAPER_SIZE_AUTO) { + processedImage = scaleToPaperSize(processedImage, detectedSize, currentDPI); + } + } else { + // Use manually selected paper size + qDebug() << "Using selected paper size:" << targetPaperSize; + processedImage = scaleToPaperSize(processedImage, targetPaperSize, currentDPI); + } QString filePath = QDir(scanDir).filePath(fileName); bool saveSuccess = false; @@ -479,7 +554,36 @@ void ScanWidget::onScanFinished(const QImage &image) QPrinter printer(QPrinter::HighResolution); printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFileName(filePath); - printer.setPageSize(QPageSize(QPageSize::A4)); + + // Set page size based on selected paper size + QPageSize::PageSizeId pageSizeId = QPageSize::A4; // Default + switch (targetPaperSize) { + case ScannerDevice::PAPER_SIZE_A3: + pageSizeId = QPageSize::A3; + break; + case ScannerDevice::PAPER_SIZE_A4: + pageSizeId = QPageSize::A4; + break; + case ScannerDevice::PAPER_SIZE_A5: + pageSizeId = QPageSize::A5; + break; + case ScannerDevice::PAPER_SIZE_A6: + pageSizeId = QPageSize::A6; + break; + case ScannerDevice::PAPER_SIZE_B4: + pageSizeId = QPageSize::B4; + break; + case ScannerDevice::PAPER_SIZE_B5: + pageSizeId = QPageSize::B5; + break; + case ScannerDevice::PAPER_SIZE_AUTO: + default: + // For auto mode, use the detected paper size or default to A4 + // Note: The image has already been scaled to the correct size + pageSizeId = QPageSize::A4; + break; + } + printer.setPageSize(QPageSize(pageSizeId)); QPainter painter; if (painter.begin(&printer)) { @@ -499,7 +603,12 @@ void ScanWidget::onScanFinished(const QImage &image) // Write OFD file ofd::Writer writer; - saveSuccess = writer.createFromImages(filePath, images, 0, 0); + + // Get paper size dimensions in mm for OFD + QSizeF paperSizeMM = ScannerDevice::getPaperSizeDimensions(targetPaperSize); + + saveSuccess = writer.createFromImages(filePath, images, 0, 0, + paperSizeMM.width(), paperSizeMM.height()); if (!saveSuccess) { qCWarning(app) << "Failed to create OFD file"; } @@ -731,3 +840,128 @@ QImage ScanWidget::convertToBlackWhite(const QImage &sourceImage) return finalResult; } +ScannerDevice::PaperSize ScanWidget::detectPaperSize(const QImage &image) +{ + if (image.isNull()) { + return ScannerDevice::PAPER_SIZE_A4; // Default to A4 + } + + // Get current DPI from scanner device + int currentDPI = 300; // Default DPI + if (m_device && m_isScanner) { + auto scanner = dynamic_cast(m_device); + if (scanner) { + currentDPI = scanner->getResolution(); + } + } + + // Calculate physical dimensions in millimeters + double widthMM = (image.width() * 25.4) / currentDPI; + double heightMM = (image.height() * 25.4) / currentDPI; + + qDebug() << "Detected image size:" << widthMM << "x" << heightMM << "mm"; + + // Define paper size tolerances (in mm) + const double tolerance = 15.0; // 15mm tolerance for detection + + // Map of paper sizes to their dimensions + QMap paperSizes = { + {ScannerDevice::PAPER_SIZE_A3, QSizeF(297, 420)}, + {ScannerDevice::PAPER_SIZE_A4, QSizeF(210, 297)}, + {ScannerDevice::PAPER_SIZE_A5, QSizeF(148, 210)}, + {ScannerDevice::PAPER_SIZE_A6, QSizeF(105, 148)}, + {ScannerDevice::PAPER_SIZE_B4, QSizeF(250, 353)}, + {ScannerDevice::PAPER_SIZE_B5, QSizeF(176, 250)} + }; + + // Find the best matching paper size + ScannerDevice::PaperSize bestMatch = ScannerDevice::PAPER_SIZE_A4; + double minError = std::numeric_limits::max(); + + for (auto it = paperSizes.begin(); it != paperSizes.end(); ++it) { + QSizeF paperSize = it.value(); + + // Check both orientations + double error1 = qAbs(widthMM - paperSize.width()) + qAbs(heightMM - paperSize.height()); + double error2 = qAbs(widthMM - paperSize.height()) + qAbs(heightMM - paperSize.width()); + + double minErrorForThisSize = qMin(error1, error2); + + if (minErrorForThisSize < minError && minErrorForThisSize <= tolerance * 2) { + minError = minErrorForThisSize; + bestMatch = it.key(); + } + } + + qDebug() << "Detected paper size:" << bestMatch; + return bestMatch; +} + +QImage ScanWidget::scaleToPaperSize(const QImage &image, ScannerDevice::PaperSize targetSize, int dpi) +{ + if (image.isNull() || targetSize == ScannerDevice::PAPER_SIZE_AUTO) { + return image; + } + + // Get target paper dimensions in mm + QSizeF targetSizeMM = ScannerDevice::getPaperSizeDimensions(targetSize); + + // Convert target dimensions to pixels at given DPI + int targetWidth = qRound((targetSizeMM.width() * dpi) / 25.4); + int targetHeight = qRound((targetSizeMM.height() * dpi) / 25.4); + + QSize targetPixelSize(targetWidth, targetHeight); + + // Check if scaling is needed + // If image is smaller than target size, don't scale up (avoid quality loss) + if (image.width() <= targetWidth && image.height() <= targetHeight) { + qDebug() << "Image is smaller than target size, no scaling applied"; + return image; + } + + // Determine if we need to consider orientation + bool needsRotation = false; + QSize scaledSize = image.size(); + + // Calculate scaling factors for both orientations + double scaleNormal = qMin((double)targetWidth / image.width(), + (double)targetHeight / image.height()); + double scaleRotated = qMin((double)targetWidth / image.height(), + (double)targetHeight / image.width()); + + // Choose the better scaling (allows rotation if it provides better fit) + if (scaleRotated > scaleNormal * 1.1) { // 10% threshold for preferring rotation + needsRotation = true; + scaledSize = QSize(qRound(image.height() * scaleRotated), + qRound(image.width() * scaleRotated)); + } else { + scaledSize = QSize(qRound(image.width() * scaleNormal), + qRound(image.height() * scaleNormal)); + } + + qDebug() << "Scaling from" << image.size() << "to" << scaledSize; + + // Perform scaling with high quality + QImage scaledImage = image.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); + + // If rotation is needed, rotate the image + if (needsRotation) { + QTransform transform; + transform.rotate(90); + scaledImage = scaledImage.transformed(transform, Qt::SmoothTransformation); + } + + // Create final image with exact target dimensions, centered + QImage finalImage(targetWidth, targetHeight, image.format()); + finalImage.fill(Qt::white); // White background for letter/paper images + + QPainter painter(&finalImage); + int x = (targetWidth - scaledImage.width()) / 2; + int y = (targetHeight - scaledImage.height()) / 2; + painter.drawImage(x, y, scaledImage); + painter.end(); + + qDebug() << "Final image size:" << finalImage.size(); + return finalImage; +} + diff --git a/src/ui/scanwidget.h b/src/ui/scanwidget.h index 49bf749..b7084cc 100644 --- a/src/ui/scanwidget.h +++ b/src/ui/scanwidget.h @@ -26,6 +26,7 @@ struct ImageSettings { int colorMode = 0; // 0=COLOR, 1=GRAYSCALE, 2=BLACKWHITE int format = 0; // 0=PNG, 1=JPG, 2=BMP, 3=TIFF, 4=PDF, 5=OFD + int paperSize = 1; // 0=AUTO, 1=A4, 2=A3, 3=A5, 4=A6, 5=B4, 6=B5 }; class ScanWidget : public QWidget @@ -58,6 +59,7 @@ private slots: void onColorModeChanged(int index); void onFormatChanged(int index); void onScanModeChanged(int index); + void onPaperSizeChanged(int index); void onScanFinished(const QImage &image); void handleDeviceError(const QString &error); void onDeviceOpened(); @@ -68,6 +70,10 @@ private slots: void updateDeviceSettings(); void resetPreview(); QImage convertToBlackWhite(const QImage &sourceImage); + + // Paper size handling methods + ScannerDevice::PaperSize detectPaperSize(const QImage &image); + QImage scaleToPaperSize(const QImage &image, ScannerDevice::PaperSize targetSize, int dpi); DeviceBase* m_device = nullptr; bool m_isScanner; @@ -82,6 +88,10 @@ private slots: QComboBox *m_resolutionCombo; QComboBox *m_colorCombo; QComboBox *m_formatCombo; + + // Paper size controls + DLabel *m_paperSizeLabel; + QComboBox *m_paperSizeCombo; QScopedPointer m_imageSettings; QPlainTextEdit *m_historyEdit; // Scan history display box diff --git a/translations/deepin-scanner.ts b/translations/deepin-scanner.ts index 2f5bce9..1b2874d 100644 --- a/translations/deepin-scanner.ts +++ b/translations/deepin-scanner.ts @@ -25,17 +25,17 @@ MainWindow - + Scanner Manager - + Loading devices... - + Opening device... @@ -43,87 +43,127 @@ ScanWidget - + Scan Settings - + Resolution - + Color Mode - + Image Format - + + Paper Size + 纸张尺寸 + + + Scan - + View Scanned Image - + Scan history will be shown here - + Scan Mode - + Flatbed - + Video Format - + Color - + Grayscale - + Black White - + + Auto + 自动 + + + + A4 (210×297mm) + + + + + A3 (297×420mm) + + + + + A5 (148×210mm) + + + + + A6 (105×148mm) + + + + + B4 (250×353mm) + + + + + B5 (176×250mm) + + + + Device not initialized - + Initializing preview... - + Device preview not available - + No preview image @@ -131,37 +171,51 @@ ScannerDevice - - No scanner devices found. Possible solutions: -1. Ensure scanner is connected and powered on -2. Run command: sudo gpasswd -a $USER scanner -3. Restart SANE: sudo service saned restart -4. Install required driver package: sudo apt-get install libsane-extras -5. For network scanners, check network configuration -6. Reconnect USB cable or restart computer + + Failed to get device list: %1 - - - - - Scanner not opened + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + ScannerWorker - - Failed to get scanner parameters: %1 + + Failed to open SANE device '%1': %2 - + + Scanner not opened + + + + Failed to start scan: %1 - - Failed to save test image + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 @@ -251,32 +305,32 @@ - + Failed to enqueue buffer: %1 - + Failed to start video stream: %1 - + Device not initialized or invalid file descriptor - + Failed to start video stream, capture failed - + Failed to get image frame - + Failed to capture valid image, please check camera connection diff --git a/translations/deepin-scanner_de.ts b/translations/deepin-scanner_de.ts index 2f5bce9..0f09d3f 100644 --- a/translations/deepin-scanner_de.ts +++ b/translations/deepin-scanner_de.ts @@ -25,17 +25,17 @@ MainWindow - + Scanner Manager - + Loading devices... - + Opening device... @@ -43,87 +43,127 @@ ScanWidget - + Scan Settings - + Resolution - + Color Mode - + Image Format - + + Paper Size + Papierformat + + + Scan - + View Scanned Image - + Scan history will be shown here - + Scan Mode - + Flatbed - + Video Format - + Color - + Grayscale - + Black White - + + Auto + Automatisch + + + + A4 (210×297mm) + + + + + A3 (297×420mm) + + + + + A5 (148×210mm) + + + + + A6 (105×148mm) + + + + + B4 (250×353mm) + + + + + B5 (176×250mm) + + + + Device not initialized - + Initializing preview... - + Device preview not available - + No preview image @@ -131,37 +171,51 @@ ScannerDevice - - No scanner devices found. Possible solutions: -1. Ensure scanner is connected and powered on -2. Run command: sudo gpasswd -a $USER scanner -3. Restart SANE: sudo service saned restart -4. Install required driver package: sudo apt-get install libsane-extras -5. For network scanners, check network configuration -6. Reconnect USB cable or restart computer + + Failed to get device list: %1 - - - - - Scanner not opened + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + ScannerWorker - - Failed to get scanner parameters: %1 + + Failed to open SANE device '%1': %2 - + + Scanner not opened + + + + Failed to start scan: %1 - - Failed to save test image + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 @@ -251,32 +305,32 @@ - + Failed to enqueue buffer: %1 - + Failed to start video stream: %1 - + Device not initialized or invalid file descriptor - + Failed to start video stream, capture failed - + Failed to get image frame - + Failed to capture valid image, please check camera connection diff --git a/translations/deepin-scanner_en_US.ts b/translations/deepin-scanner_en_US.ts index 1524c35..9fbadf3 100644 --- a/translations/deepin-scanner_en_US.ts +++ b/translations/deepin-scanner_en_US.ts @@ -25,17 +25,17 @@ MainWindow - + Scanner Manager Scanner Manager - + Loading devices... Loading devices... - + Opening device... Opening device... @@ -43,87 +43,97 @@ ScanWidget - + Scan Settings Scan Settings - + Resolution Resolution - + Color Mode Color Mode - + Image Format Image Format - + + Paper Size + Paper Size + + + Scan Scan - + View Scanned Image View Scanned Image - + Scan history will be shown here Scan history will be shown here - + Scan Mode Scan Mode - + Flatbed Flatbed - + Video Format Video Format - + Color Color - + Grayscale Grayscale - + Black White Black White - + + Auto + Auto + + + Device not initialized Device not initialized - + Initializing preview... Initializing preview... - + Device preview not available Device preview not available - + No preview image No preview image @@ -131,7 +141,6 @@ ScannerDevice - No scanner devices found. Possible solutions: 1. Ensure scanner is connected and powered on 2. Run command: sudo gpasswd -a $USER scanner @@ -139,7 +148,7 @@ 4. Install required driver package: sudo apt-get install libsane-extras 5. For network scanners, check network configuration 6. Reconnect USB cable or restart computer - No scanner devices found. Possible solutions: + No scanner devices found. Possible solutions: 1. Ensure scanner is connected and powered on 2. Run command: sudo gpasswd -a $USER scanner 3. Restart SANE: sudo service saned restart @@ -148,24 +157,68 @@ 6. Reconnect USB cable or restart computer - Scanner not opened - Scanner not opened + Scanner not opened - Failed to get scanner parameters: %1 - Failed to get scanner parameters: %1 + Failed to get scanner parameters: %1 - Failed to start scan: %1 - Failed to start scan: %1 + Failed to start scan: %1 - Failed to save test image - Failed to save test image + Failed to save test image + + + + Failed to get device list: %1 + + + + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + + + ScannerWorker + + + Failed to open SANE device '%1': %2 + + + + + Scanner not opened + Scanner not opened + + + + Failed to start scan: %1 + Failed to start scan: %1 + + + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 + @@ -254,32 +307,32 @@ Buffer reinitialization failed - + Failed to enqueue buffer: %1 Failed to enqueue buffer: %1 - + Failed to start video stream: %1 Failed to start video stream: %1 - + Device not initialized or invalid file descriptor Device not initialized or invalid file descriptor - + Failed to start video stream, capture failed Failed to start video stream, capture failed - + Failed to get image frame Failed to get image frame - + Failed to capture valid image, please check camera connection Failed to capture valid image, please check camera connection diff --git a/translations/deepin-scanner_es.ts b/translations/deepin-scanner_es.ts index 2f5bce9..0b9e533 100644 --- a/translations/deepin-scanner_es.ts +++ b/translations/deepin-scanner_es.ts @@ -25,17 +25,17 @@ MainWindow - + Scanner Manager - + Loading devices... - + Opening device... @@ -43,87 +43,127 @@ ScanWidget - + Scan Settings - + Resolution - + Color Mode - + Image Format - + + Paper Size + Tamaño del papel + + + Scan - + View Scanned Image - + Scan history will be shown here - + Scan Mode - + Flatbed - + Video Format - + Color - + Grayscale - + Black White - + + Auto + Automático + + + + A4 (210×297mm) + + + + + A3 (297×420mm) + + + + + A5 (148×210mm) + + + + + A6 (105×148mm) + + + + + B4 (250×353mm) + + + + + B5 (176×250mm) + + + + Device not initialized - + Initializing preview... - + Device preview not available - + No preview image @@ -131,37 +171,51 @@ ScannerDevice - - No scanner devices found. Possible solutions: -1. Ensure scanner is connected and powered on -2. Run command: sudo gpasswd -a $USER scanner -3. Restart SANE: sudo service saned restart -4. Install required driver package: sudo apt-get install libsane-extras -5. For network scanners, check network configuration -6. Reconnect USB cable or restart computer + + Failed to get device list: %1 - - - - - Scanner not opened + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + ScannerWorker - - Failed to get scanner parameters: %1 + + Failed to open SANE device '%1': %2 - + + Scanner not opened + + + + Failed to start scan: %1 - - Failed to save test image + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 @@ -251,32 +305,32 @@ - + Failed to enqueue buffer: %1 - + Failed to start video stream: %1 - + Device not initialized or invalid file descriptor - + Failed to start video stream, capture failed - + Failed to get image frame - + Failed to capture valid image, please check camera connection diff --git a/translations/deepin-scanner_it.ts b/translations/deepin-scanner_it.ts index 2f5bce9..246875b 100644 --- a/translations/deepin-scanner_it.ts +++ b/translations/deepin-scanner_it.ts @@ -25,17 +25,17 @@ MainWindow - + Scanner Manager - + Loading devices... - + Opening device... @@ -43,87 +43,127 @@ ScanWidget - + Scan Settings - + Resolution - + Color Mode - + Image Format - + + Paper Size + Formato carta + + + Scan - + View Scanned Image - + Scan history will be shown here - + Scan Mode - + Flatbed - + Video Format - + Color - + Grayscale - + Black White - + + Auto + Automatico + + + + A4 (210×297mm) + + + + + A3 (297×420mm) + + + + + A5 (148×210mm) + + + + + A6 (105×148mm) + + + + + B4 (250×353mm) + + + + + B5 (176×250mm) + + + + Device not initialized - + Initializing preview... - + Device preview not available - + No preview image @@ -131,37 +171,51 @@ ScannerDevice - - No scanner devices found. Possible solutions: -1. Ensure scanner is connected and powered on -2. Run command: sudo gpasswd -a $USER scanner -3. Restart SANE: sudo service saned restart -4. Install required driver package: sudo apt-get install libsane-extras -5. For network scanners, check network configuration -6. Reconnect USB cable or restart computer + + Failed to get device list: %1 - - - - - Scanner not opened + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + ScannerWorker - - Failed to get scanner parameters: %1 + + Failed to open SANE device '%1': %2 - + + Scanner not opened + + + + Failed to start scan: %1 - - Failed to save test image + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 @@ -251,32 +305,32 @@ - + Failed to enqueue buffer: %1 - + Failed to start video stream: %1 - + Device not initialized or invalid file descriptor - + Failed to start video stream, capture failed - + Failed to get image frame - + Failed to capture valid image, please check camera connection diff --git a/translations/deepin-scanner_ja.ts b/translations/deepin-scanner_ja.ts index 2f5bce9..bd75462 100644 --- a/translations/deepin-scanner_ja.ts +++ b/translations/deepin-scanner_ja.ts @@ -25,17 +25,17 @@ MainWindow - + Scanner Manager - + Loading devices... - + Opening device... @@ -43,87 +43,127 @@ ScanWidget - + Scan Settings - + Resolution - + Color Mode - + Image Format - + + Paper Size + 用紙サイズ + + + Scan - + View Scanned Image - + Scan history will be shown here - + Scan Mode - + Flatbed - + Video Format - + Color - + Grayscale - + Black White - + + Auto + 自動 + + + + A4 (210×297mm) + + + + + A3 (297×420mm) + + + + + A5 (148×210mm) + + + + + A6 (105×148mm) + + + + + B4 (250×353mm) + + + + + B5 (176×250mm) + + + + Device not initialized - + Initializing preview... - + Device preview not available - + No preview image @@ -131,37 +171,51 @@ ScannerDevice - - No scanner devices found. Possible solutions: -1. Ensure scanner is connected and powered on -2. Run command: sudo gpasswd -a $USER scanner -3. Restart SANE: sudo service saned restart -4. Install required driver package: sudo apt-get install libsane-extras -5. For network scanners, check network configuration -6. Reconnect USB cable or restart computer + + Failed to get device list: %1 - - - - - Scanner not opened + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + ScannerWorker - - Failed to get scanner parameters: %1 + + Failed to open SANE device '%1': %2 - + + Scanner not opened + + + + Failed to start scan: %1 - - Failed to save test image + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 @@ -251,32 +305,32 @@ - + Failed to enqueue buffer: %1 - + Failed to start video stream: %1 - + Device not initialized or invalid file descriptor - + Failed to start video stream, capture failed - + Failed to get image frame - + Failed to capture valid image, please check camera connection diff --git a/translations/deepin-scanner_pl.ts b/translations/deepin-scanner_pl.ts index 2f5bce9..cb731c0 100644 --- a/translations/deepin-scanner_pl.ts +++ b/translations/deepin-scanner_pl.ts @@ -25,17 +25,17 @@ MainWindow - + Scanner Manager - + Loading devices... - + Opening device... @@ -43,87 +43,127 @@ ScanWidget - + Scan Settings - + Resolution - + Color Mode - + Image Format - + + Paper Size + Rozmiar papieru + + + Scan - + View Scanned Image - + Scan history will be shown here - + Scan Mode - + Flatbed - + Video Format - + Color - + Grayscale - + Black White - + + Auto + Automatyczny + + + + A4 (210×297mm) + + + + + A3 (297×420mm) + + + + + A5 (148×210mm) + + + + + A6 (105×148mm) + + + + + B4 (250×353mm) + + + + + B5 (176×250mm) + + + + Device not initialized - + Initializing preview... - + Device preview not available - + No preview image @@ -131,37 +171,51 @@ ScannerDevice - - No scanner devices found. Possible solutions: -1. Ensure scanner is connected and powered on -2. Run command: sudo gpasswd -a $USER scanner -3. Restart SANE: sudo service saned restart -4. Install required driver package: sudo apt-get install libsane-extras -5. For network scanners, check network configuration -6. Reconnect USB cable or restart computer + + Failed to get device list: %1 - - - - - Scanner not opened + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + ScannerWorker - - Failed to get scanner parameters: %1 + + Failed to open SANE device '%1': %2 - + + Scanner not opened + + + + Failed to start scan: %1 - - Failed to save test image + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 @@ -251,32 +305,32 @@ - + Failed to enqueue buffer: %1 - + Failed to start video stream: %1 - + Device not initialized or invalid file descriptor - + Failed to start video stream, capture failed - + Failed to get image frame - + Failed to capture valid image, please check camera connection diff --git a/translations/deepin-scanner_pt_BR.ts b/translations/deepin-scanner_pt_BR.ts index 2f5bce9..ed32853 100644 --- a/translations/deepin-scanner_pt_BR.ts +++ b/translations/deepin-scanner_pt_BR.ts @@ -25,17 +25,17 @@ MainWindow - + Scanner Manager - + Loading devices... - + Opening device... @@ -43,87 +43,127 @@ ScanWidget - + Scan Settings - + Resolution - + Color Mode - + Image Format - + + Paper Size + Tamanho do papel + + + Scan - + View Scanned Image - + Scan history will be shown here - + Scan Mode - + Flatbed - + Video Format - + Color - + Grayscale - + Black White - + + Auto + Automático + + + + A4 (210×297mm) + + + + + A3 (297×420mm) + + + + + A5 (148×210mm) + + + + + A6 (105×148mm) + + + + + B4 (250×353mm) + + + + + B5 (176×250mm) + + + + Device not initialized - + Initializing preview... - + Device preview not available - + No preview image @@ -131,37 +171,51 @@ ScannerDevice - - No scanner devices found. Possible solutions: -1. Ensure scanner is connected and powered on -2. Run command: sudo gpasswd -a $USER scanner -3. Restart SANE: sudo service saned restart -4. Install required driver package: sudo apt-get install libsane-extras -5. For network scanners, check network configuration -6. Reconnect USB cable or restart computer + + Failed to get device list: %1 - - - - - Scanner not opened + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + ScannerWorker - - Failed to get scanner parameters: %1 + + Failed to open SANE device '%1': %2 - + + Scanner not opened + + + + Failed to start scan: %1 - - Failed to save test image + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 @@ -251,32 +305,32 @@ - + Failed to enqueue buffer: %1 - + Failed to start video stream: %1 - + Device not initialized or invalid file descriptor - + Failed to start video stream, capture failed - + Failed to get image frame - + Failed to capture valid image, please check camera connection diff --git a/translations/deepin-scanner_sq.ts b/translations/deepin-scanner_sq.ts index 2f5bce9..05c9792 100644 --- a/translations/deepin-scanner_sq.ts +++ b/translations/deepin-scanner_sq.ts @@ -25,17 +25,17 @@ MainWindow - + Scanner Manager - + Loading devices... - + Opening device... @@ -43,87 +43,127 @@ ScanWidget - + Scan Settings - + Resolution - + Color Mode - + Image Format - + + Paper Size + Madhesia e letërs + + + Scan - + View Scanned Image - + Scan history will be shown here - + Scan Mode - + Flatbed - + Video Format - + Color - + Grayscale - + Black White - + + Auto + Automatik + + + + A4 (210×297mm) + + + + + A3 (297×420mm) + + + + + A5 (148×210mm) + + + + + A6 (105×148mm) + + + + + B4 (250×353mm) + + + + + B5 (176×250mm) + + + + Device not initialized - + Initializing preview... - + Device preview not available - + No preview image @@ -131,37 +171,51 @@ ScannerDevice - - No scanner devices found. Possible solutions: -1. Ensure scanner is connected and powered on -2. Run command: sudo gpasswd -a $USER scanner -3. Restart SANE: sudo service saned restart -4. Install required driver package: sudo apt-get install libsane-extras -5. For network scanners, check network configuration -6. Reconnect USB cable or restart computer + + Failed to get device list: %1 - - - - - Scanner not opened + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + ScannerWorker - - Failed to get scanner parameters: %1 + + Failed to open SANE device '%1': %2 - + + Scanner not opened + + + + Failed to start scan: %1 - - Failed to save test image + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 @@ -251,32 +305,32 @@ - + Failed to enqueue buffer: %1 - + Failed to start video stream: %1 - + Device not initialized or invalid file descriptor - + Failed to start video stream, capture failed - + Failed to get image frame - + Failed to capture valid image, please check camera connection diff --git a/translations/deepin-scanner_uk.ts b/translations/deepin-scanner_uk.ts index 2f5bce9..aea5324 100644 --- a/translations/deepin-scanner_uk.ts +++ b/translations/deepin-scanner_uk.ts @@ -25,17 +25,17 @@ MainWindow - + Scanner Manager - + Loading devices... - + Opening device... @@ -43,87 +43,127 @@ ScanWidget - + Scan Settings - + Resolution - + Color Mode - + Image Format - + + Paper Size + Розмір паперу + + + Scan - + View Scanned Image - + Scan history will be shown here - + Scan Mode - + Flatbed - + Video Format - + Color - + Grayscale - + Black White - + + Auto + Авто + + + + A4 (210×297mm) + + + + + A3 (297×420mm) + + + + + A5 (148×210mm) + + + + + A6 (105×148mm) + + + + + B4 (250×353mm) + + + + + B5 (176×250mm) + + + + Device not initialized - + Initializing preview... - + Device preview not available - + No preview image @@ -131,37 +171,51 @@ ScannerDevice - - No scanner devices found. Possible solutions: -1. Ensure scanner is connected and powered on -2. Run command: sudo gpasswd -a $USER scanner -3. Restart SANE: sudo service saned restart -4. Install required driver package: sudo apt-get install libsane-extras -5. For network scanners, check network configuration -6. Reconnect USB cable or restart computer + + Failed to get device list: %1 - - - - - Scanner not opened + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + ScannerWorker - - Failed to get scanner parameters: %1 + + Failed to open SANE device '%1': %2 - + + Scanner not opened + + + + Failed to start scan: %1 - - Failed to save test image + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 @@ -251,32 +305,32 @@ - + Failed to enqueue buffer: %1 - + Failed to start video stream: %1 - + Device not initialized or invalid file descriptor - + Failed to start video stream, capture failed - + Failed to get image frame - + Failed to capture valid image, please check camera connection diff --git a/translations/deepin-scanner_zh_CN.ts b/translations/deepin-scanner_zh_CN.ts index 8456ad5..47d3a83 100644 --- a/translations/deepin-scanner_zh_CN.ts +++ b/translations/deepin-scanner_zh_CN.ts @@ -37,17 +37,17 @@ Scanner functionality will be unavailable. 扫描器错误 - + Scanner Manager 扫描管理器 - + Loading devices... 正在加载设备... - + Opening device... 正在打开设备... @@ -55,32 +55,37 @@ Scanner functionality will be unavailable. ScanWidget - + Scan Settings 扫描设置 - + Resolution 分辨率 - + Color Mode 色彩模式 - + Image Format 图像格式 - + + Paper Size + 纸张尺寸 + + + View Scanned Image 查看已扫描图像 - + Scan 扫描 @@ -89,12 +94,12 @@ Scanner functionality will be unavailable. 保存 - + Scan Mode 扫描模式 - + Flatbed 平板扫描 @@ -103,22 +108,22 @@ Scanner functionality will be unavailable. 双面扫描 - + Video Format 视频格式 - + Color 彩色 - + Grayscale 灰度 - + Black White 黑白 @@ -127,27 +132,32 @@ Scanner functionality will be unavailable. ADF - + Scan history will be shown here 扫描历史将在此处显示 - + + Auto + 自动 + + + Device not initialized 设备未初始化 - + Initializing preview... 正在初始化预览... - + Device preview not available 设备预览不可用 - + No preview image 无预览图像 @@ -155,7 +165,6 @@ Scanner functionality will be unavailable. ScannerDevice - No scanner devices found. Possible solutions: 1. Ensure scanner is connected and powered on 2. Run command: sudo gpasswd -a $USER scanner @@ -163,7 +172,7 @@ Scanner functionality will be unavailable. 4. Install required driver package: sudo apt-get install libsane-extras 5. For network scanners, check network configuration 6. Reconnect USB cable or restart computer - 未找到扫描设备。可能的解决方案: + 未找到扫描设备。可能的解决方案: 1. 确保扫描仪已连接并通电 2. 运行命令:sudo gpasswd -a $USER scanner 3. 重启SANE:sudo service saned restart @@ -172,27 +181,68 @@ Scanner functionality will be unavailable. 6. 重新连接USB线或重启电脑 - - - - Scanner not opened - 扫描仪未打开 + 扫描仪未打开 - Failed to get scanner parameters: %1 - 获取扫描仪参数失败:%1 + 获取扫描仪参数失败:%1 - Failed to start scan: %1 - 开始扫描失败:%1 + 开始扫描失败:%1 - Failed to save test image - 保存测试图像失败 + 保存测试图像失败 + + + + Failed to get device list: %1 + + + + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + + + ScannerWorker + + + Failed to open SANE device '%1': %2 + + + + + Scanner not opened + 扫描仪未打开 + + + + Failed to start scan: %1 + 开始扫描失败:%1 + + + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 + @@ -285,32 +335,32 @@ Scanner functionality will be unavailable. 缓冲区重新初始化失败 - + Failed to enqueue buffer: %1 缓冲队列失败:%1 - + Failed to start video stream: %1 启动视频流失败:%1 - + Device not initialized or invalid file descriptor 设备未初始化或文件描述符无效 - + Failed to start video stream, capture failed 启动视频流失败,捕获失败 - + Failed to get image frame 获取图像帧失败 - + Failed to capture valid image, please check camera connection 捕获有效图像失败,请检查摄像头连接 diff --git a/translations/deepin-scanner_zh_HK.ts b/translations/deepin-scanner_zh_HK.ts index 039beec..3531706 100644 --- a/translations/deepin-scanner_zh_HK.ts +++ b/translations/deepin-scanner_zh_HK.ts @@ -37,17 +37,17 @@ Scanner functionality will be unavailable. 掃描器錯誤 - + Scanner Manager 掃描管理器 - + Loading devices... 加載設備... - + Opening device... 正在打開設備... @@ -55,32 +55,37 @@ Scanner functionality will be unavailable. ScanWidget - + Scan Settings 掃描設定 - + Resolution 解析度 - + Color Mode 色彩模式 - + Image Format 圖像格式 - + + Paper Size + 紙張尺寸 + + + View Scanned Image 查看掃描圖像 - + Scan 掃描 @@ -89,12 +94,12 @@ Scanner functionality will be unavailable. 儲存 - + Scan Mode 掃描模式 - + Flatbed 平板掃描 @@ -103,22 +108,22 @@ Scanner functionality will be unavailable. 雙面掃描 - + Video Format 視頻格式 - + Color 彩色 - + Grayscale 灰度 - + Black White 黑白 @@ -127,27 +132,32 @@ Scanner functionality will be unavailable. ADF - + Scan history will be shown here 掃描歷史將顯示在這裡 - + + Auto + 自動 + + + Device not initialized 設備未初始化 - + Initializing preview... 正在初始化預覽... - + Device preview not available 設備預覽不可用 - + No preview image 無預覽圖像 @@ -155,7 +165,6 @@ Scanner functionality will be unavailable. ScannerDevice - No scanner devices found. Possible solutions: 1. Ensure scanner is connected and powered on 2. Run command: sudo gpasswd -a $USER scanner @@ -163,7 +172,7 @@ Scanner functionality will be unavailable. 4. Install required driver package: sudo apt-get install libsane-extras 5. For network scanners, check network configuration 6. Reconnect USB cable or restart computer - 未找到掃描設備。可能的解決方案: + 未找到掃描設備。可能的解決方案: 1. 確保掃描儀已連接並通電 2. 運行命令:sudo gpasswd -a $USER scanner 3. 重啟SANE:sudo service saned restart @@ -172,27 +181,68 @@ Scanner functionality will be unavailable. 6. 重新連接USB線或重啟電腦 - - - - Scanner not opened - 掃描儀未打開 + 掃描儀未打開 - Failed to get scanner parameters: %1 - 獲取掃描儀參數失敗:%1 + 獲取掃描儀參數失敗:%1 - Failed to start scan: %1 - 開始掃描失敗:%1 + 開始掃描失敗:%1 - Failed to save test image - 保存測試圖像失敗 + 保存測試圖像失敗 + + + + Failed to get device list: %1 + + + + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + + + ScannerWorker + + + Failed to open SANE device '%1': %2 + + + + + Scanner not opened + 掃描儀未打開 + + + + Failed to start scan: %1 + 開始掃描失敗:%1 + + + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 + @@ -285,32 +335,32 @@ Scanner functionality will be unavailable. 緩衝區重新初始化失敗 - + Failed to enqueue buffer: %1 緩衝隊列失敗:%1 - + Failed to start video stream: %1 啟動視頻流失敗:%1 - + Device not initialized or invalid file descriptor 設備未初始化或文件描述符無效 - + Failed to start video stream, capture failed 啟動視頻流失敗,捕獲失敗 - + Failed to get image frame 獲取圖像幀失敗 - + Failed to capture valid image, please check camera connection 捕獲有效圖像失敗,請檢查攝像頭連接 diff --git a/translations/deepin-scanner_zh_TW.ts b/translations/deepin-scanner_zh_TW.ts index 1195a59..2659055 100644 --- a/translations/deepin-scanner_zh_TW.ts +++ b/translations/deepin-scanner_zh_TW.ts @@ -37,17 +37,17 @@ Scanner functionality will be unavailable. 掃描器錯誤 - + Scanner Manager 掃描管理器 - + Loading devices... 載入設備中... - + Opening device... 開啟設備中... @@ -55,32 +55,37 @@ Scanner functionality will be unavailable. ScanWidget - + Scan Settings 掃描設定 - + Resolution 解析度 - + Color Mode 色彩模式 - + Image Format 圖像格式 - + + Paper Size + 紙張尺寸 + + + View Scanned Image 查看掃描圖像 - + Scan 掃描 @@ -89,12 +94,12 @@ Scanner functionality will be unavailable. 儲存 - + Scan Mode 掃描模式 - + Flatbed 平板掃描 @@ -103,22 +108,22 @@ Scanner functionality will be unavailable. 雙面掃描 - + Video Format 影片格式 - + Color 彩色 - + Grayscale 灰階 - + Black White 黑白 @@ -127,27 +132,32 @@ Scanner functionality will be unavailable. ADF - + Scan history will be shown here 掃描歷史將顯示在這裡 - + + Auto + 自動 + + + Device not initialized 設備未初始化 - + Initializing preview... 正在初始化預覽... - + Device preview not available 設備預覽不可用 - + No preview image 無預覽圖像 @@ -155,7 +165,6 @@ Scanner functionality will be unavailable. ScannerDevice - No scanner devices found. Possible solutions: 1. Ensure scanner is connected and powered on 2. Run command: sudo gpasswd -a $USER scanner @@ -163,7 +172,7 @@ Scanner functionality will be unavailable. 4. Install required driver package: sudo apt-get install libsane-extras 5. For network scanners, check network configuration 6. Reconnect USB cable or restart computer - 未找到掃描設備。可能的解決方案: + 未找到掃描設備。可能的解決方案: 1. 確保掃描儀已連接並通電 2. 運行命令:sudo gpasswd -a $USER scanner 3. 重啟SANE:sudo service saned restart @@ -172,27 +181,68 @@ Scanner functionality will be unavailable. 6. 重新連接USB線或重啟電腦 - - - - Scanner not opened - 掃描儀未開啟 + 掃描儀未開啟 - Failed to get scanner parameters: %1 - 獲取掃描儀參數失敗:%1 + 獲取掃描儀參數失敗:%1 - Failed to start scan: %1 - 開始掃描失敗:%1 + 開始掃描失敗:%1 - Failed to save test image - 儲存測試圖像失敗 + 儲存測試圖像失敗 + + + + Failed to get device list: %1 + + + + + A scan is already in progress. + + + + + Failed to load scanned image from temp file. + + + + + ScannerWorker + + + Failed to open SANE device '%1': %2 + + + + + Scanner not opened + 掃描儀未開啟 + + + + Failed to start scan: %1 + 開始掃描失敗:%1 + + + + Failed to open temporary output file. + + + + + Scan canceled by user + + + + + Scan failed during read: %1 + @@ -285,32 +335,32 @@ Scanner functionality will be unavailable. 緩衝區重新初始化失敗 - + Failed to enqueue buffer: %1 緩衝佇列失敗:%1 - + Failed to start video stream: %1 啟動影片流失敗:%1 - + Device not initialized or invalid file descriptor 設備未初始化或檔案描述符無效 - + Failed to start video stream, capture failed 啟動影片流失敗,擷取失敗 - + Failed to get image frame 獲取圖像幀失敗 - + Failed to capture valid image, please check camera connection 擷取有效圖像失敗,請檢查攝影機連接