Skip to content

Add option to load project extent when project is loaded #62176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

merydian
Copy link
Contributor

@merydian merydian commented Jun 6, 2025

Description

Adds an option to load the extent saved under Project Properties -> View Settings -> Set Project Full Extent for the main canvas when a project is loaded. Also reworks the setting to use QgsExtentWidget instead of QgsExtentGroupBox.

Original idea by @3nids.

image

@github-actions github-actions bot added this to the 3.44.0 milestone Jun 6, 2025
@merydian merydian force-pushed the feat/load-project-canvas-with-project branch 3 times, most recently from c842450 to 0f83a24 Compare June 6, 2025 07:47
Copy link
Contributor

github-actions bot commented Jun 6, 2025

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 0f83a24)

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 1f5d152)

Copy link
Member

@3nids 3nids left a comment

Choose a reason for hiding this comment

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

Good job! One thing forgot: we need to take care of a potential difference in CRS from the map canvas (not the main) being different from. the project.

@@ -3271,7 +3271,7 @@ void QgsMapCanvas::readProject( const QDomDocument &doc )
// never manually set the crs for the main canvas - this is instead connected to the project CRS
setDestinationCrs( tmpSettings.destinationCrs() );
}
setExtent( tmpSettings.extent() );
Copy link
Member

Choose a reason for hiding this comment

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

Why are you removing this?

What we have to do here:
If the option is activated, we have to transform the extent to the CRS of the canvas and use it.
If the options is not activated, keep the existing code.


if ( QgsProject::instance()->viewSettings()->canvasUseProjectExtent() )
{
zoomFull();
Copy link
Member

Choose a reason for hiding this comment

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

I would not add this here, and leave the handling to be done in QgsMapCanvas (see my other comment)

@3nids
Copy link
Member

3nids commented Jun 6, 2025

The main goal here is to allow the possibility to set a default map extent for the project that will always be used independently of the what is saved.

The question then is how do we handle different map canvas, but we didn't want to over-engineer this.
I see 2 options: apply for all canvases (as done now) or only for the main one.

*
* \since QGIS 3.44
*/
void loadCanvasChanged();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need a signal for this, you can remove it.

@3nids
Copy link
Member

3nids commented Jun 6, 2025

After thoughts, maybe it's cleaner and better to apply this only on the main canvas.
So rephrase:
Use as extent for each canvas when opening the project to Use as extent for the main map canvas when opening the project.

@agiudiceandrea agiudiceandrea added the Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. label Jun 6, 2025
@qgis-bot
Copy link
Collaborator

qgis-bot commented Jun 6, 2025

@merydian
This pull request has been tagged as requiring documentation.

A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged.

Please update the description (not the comments) with helpful description and screenshot to help the work from documentors.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

@merydian merydian force-pushed the feat/load-project-canvas-with-project branch from 0f83a24 to d2e2d90 Compare June 7, 2025 15:20
@merydian merydian requested a review from 3nids June 7, 2025 15:21
@merydian merydian force-pushed the feat/load-project-canvas-with-project branch from d2e2d90 to 1f5d152 Compare June 7, 2025 16:25
@nyalldawson nyalldawson added the Frozen Feature freeze - Do not merge! label Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frozen Feature freeze - Do not merge! Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants