feat: Improve XPS print quality by using printer DPI-aware rendering#205
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom Nov 13, 2025
Merged
feat: Improve XPS print quality by using printer DPI-aware rendering#205deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
deepin pr auto review我来分析一下这段代码的改进意见:
class DocSheet {
private:
// 添加为私有成员函数
QRect calculateTargetRect(const QSize& sourceSize, const QRectF& pageRect) const {
if (!sourceSize.isValid() || sourceSize.isEmpty()) {
return QRect();
}
qreal targetWidth = pageRect.width();
qreal targetHeight = targetWidth * static_cast<qreal>(sourceSize.height()) / static_cast<qreal>(sourceSize.width());
if (targetHeight > pageRect.height()) {
targetHeight = pageRect.height();
targetWidth = targetHeight * static_cast<qreal>(sourceSize.width()) / static_cast<qreal>(sourceSize.height());
}
const int left = qRound((pageRect.width() - targetWidth) / 2.0);
const int top = qRound((pageRect.height() - targetHeight) / 2.0);
return QRect(left, top, qMax(1, qRound(targetWidth)), qMax(1, qRound(targetHeight)));
}
};
// 在 calculatePrintTargetSize 中添加 DPI 上限检查
QSize DocSheet::calculatePrintTargetSize(int pageIndex, const QPrinter &printer, const QRectF &pageRect) const {
if (!printer.isValid()) {
qCWarning(appLog) << "Invalid printer object";
return QSize();
}
// ... 现有代码 ...
// 添加 DPI 上限检查
constexpr int kMaxPrintDpi = 1200;
if (printerDpi > kMaxPrintDpi) {
qCWarning(appLog) << "Printer DPI too high, clamping to" << kMaxPrintDpi;
printerDpi = kMaxPrintDpi;
}
// ... 其余代码 ...
}这些改进将提高代码的可维护性、性能和安全性,同时保持代码的功能完整性。 |
lzwind
approved these changes
Nov 13, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: LiHua000, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/forcemerge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Log: as title
task:https://pms.uniontech.com/task-view-383459.html