Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/frame/ccentralwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,9 @@ void Page::closeEvent(QCloseEvent *event)
void Page::adjustViewScaleRatio()
{
if (nullptr != view()) {
int viewportWidth = view()->viewport()->width();
int viewportHeight = view()->viewport()->height();
const int margin = 20;
int viewportWidth = view()->viewport()->width() - margin * 2;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Imported images keep the old scale

When an image is imported through the type-1 adaptation path or DrawBoard::loadImage(), those paths do not call adjustViewScaleRatio(), so an oversized canvas keeps its previous scale and can reach the viewport edges.

Call adjustViewScaleRatio() on both image-import paths.

Prompt for AI agents
In `src/frame/ccentralwidget.cpp` at line 718:

**Imported images keep the old scale**

When an image is imported through the type-1 adaptation path or `DrawBoard::loadImage()`, those paths do not call `adjustViewScaleRatio()`, so an oversized canvas keeps its previous scale and can reach the viewport edges.

Call `adjustViewScaleRatio()` on both image-import paths.

int viewportHeight = view()->viewport()->height() - margin * 2;
Comment on lines +718 to +719

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Canvas stays at minimum zoom

When either viewport dimension is below 40px during an adjustment, the 20px margin subtraction makes an available dimension nonpositive, so the fit ratio is nonpositive and PageView::scaleWithCenter() clamps it to 0.1; the canvas is left at minimum zoom instead of fitting. An image-load adjustment stays there after a later resize.

Prevent nonpositive fit dimensions and rerun the adjustment when the viewport is enlarged.

Prompt for AI agents
In `src/frame/ccentralwidget.cpp` at lines 718-719:

**Canvas stays at minimum zoom**

When either viewport dimension is below 40px during an adjustment, the 20px margin subtraction makes an available dimension nonpositive, so the fit ratio is nonpositive and `PageView::scaleWithCenter()` clamps it to 0.1; the canvas is left at minimum zoom instead of fitting. An image-load adjustment stays there after a later resize.

Prevent nonpositive fit dimensions and rerun the adjustment when the viewport is enlarged.

Comment on lines +718 to +719

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Canvas exceeds the margins

When the canvas needs a fit ratio below 0.1, PageView::scaleWithCenter() clamps the requested ratio to 0.1, so the canvas remains larger than the margin-reduced viewport and reaches or extends beyond its edges.

Allow this fit adjustment to use ratios below 0.1.

Prompt for AI agents
In `src/frame/ccentralwidget.cpp` at lines 718-719:

**Canvas exceeds the margins**

When the canvas needs a fit ratio below 0.1, `PageView::scaleWithCenter()` clamps the requested ratio to 0.1, so the canvas remains larger than the margin-reduced viewport and reaches or extends beyond its edges.

Allow this fit adjustment to use ratios below 0.1.

qreal sceneWidth = scene()->width();
qreal sceneHeight = scene()->height();
if (viewportWidth < sceneWidth || viewportHeight < sceneHeight) {
Expand Down
Loading