Skip to content
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

Refactor gui_templates.h #7159

Merged
merged 10 commits into from
Mar 27, 2024
Merged

Refactor gui_templates.h #7159

merged 10 commits into from
Mar 27, 2024

Conversation

Rossmaxx
Copy link
Contributor

@Rossmaxx Rossmaxx commented Mar 24, 2024

I started off trying to remove the QApplication::desktop call per #6614 but I ended up doing a refactor.

I removed the duplicate pointSizeF function and merged it into the pointSize function.

There's a chance that this PR might improve HiDPI support as I did some changes in that area but haven't tested.

Todo: delete the file and find a new home for the pointSize function (should we really keep a file for a single function?)

inviting @michaelgregorius for review

@michaelgregorius
Copy link
Contributor

Looks good to me! 👍

Concerning the new home for the functionality: is there some kind of GUI helpers file where it could move?

include/gui_templates.h Outdated Show resolved Hide resolved
}

// to calculate DPI of a screen to make it HiDPI ready
qreal devicePixelRatio = QGuiApplication::primaryScreen()->devicePixelRatio();
Copy link
Contributor

Choose a reason for hiding this comment

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

When using QGuiApplication::primaryScreen() i think there could be some issues when Switching the App to an other Monitor with an diffrent DPI, We should grab the current Monitor for our Window

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get what you mean but can you suggest a way to handle this one properly?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is something that should be handled by the GUI framework, i.e. by Qt. It just one example of why using these functions in application code is problematic.

Using code like this also won't do the "right thing" when LMMS is in the middle of being dragged from one screen to another with different DPI values. Qt likely knows that one part of the application rectangle must be rendered with different settings than the other and can do so. The application code does not even have the knowledge of the current state ("I am shown on two different monitors.") and cannot do the right thing.

@Rossmaxx
Copy link
Contributor Author

there some kind of GUI helpers file where it could move?

Looking at the sources, i didn't really find a more suitable file.

@michaelgregorius
Copy link
Contributor

there some kind of GUI helpers file where it could move?

Looking at the sources, i didn't really find a more suitable file.

If it only contains this single function then another option might be to rename the file to HiDpiHelper.h or similar. The goal might then even be to adjust all places such that the file becomes superfluous and can be removed. The file would then reflect the ongoing transition to make LMMS work on HiDPI screens.

@Rossmaxx
Copy link
Contributor Author

I'll hold off on the rename for now, to reduce the diff.

@Rossmaxx
Copy link
Contributor Author

I am thinking of moving this to the gui namespace but i am doubtful about the changes I need to make in plugin code. + I have some other minor changes in mind which I'll test soon.

@michaelgregorius
Copy link
Contributor

I am thinking of moving this to the gui namespace but i am doubtful about the changes I need to make in plugin code. + I have some other minor changes in mind which I'll test soon.

Such a move would definitively make sense. The code should only be used from GUI code and not from core code anyway.

@Rossmaxx
Copy link
Contributor Author

This pr got 2 approvals but it ain't ready for merge yet. I got a few more minor cleanups to do. So can you wait for an extra day.

@Veratil
Copy link
Contributor

Veratil commented Mar 27, 2024

This pr got 2 approvals but it ain't ready for merge yet. I got a few more minor cleanups to do. So can you wait for an extra day.

Mark it as a draft and it will prevent merge 🙂

@messmerd messmerd marked this pull request as draft March 27, 2024 02:03
@Rossmaxx
Copy link
Contributor Author

I'm done with my changes, let the ci run before i make this pr ready for review.

@Rossmaxx Rossmaxx marked this pull request as ready for review March 27, 2024 12:12
@sakertooth sakertooth merged commit 286d157 into LMMS:master Mar 27, 2024
9 checks passed
@Rossmaxx Rossmaxx deleted the qapp-desktop-remove branch March 28, 2024 07:40
@Rossmaxx Rossmaxx mentioned this pull request Mar 28, 2024
25 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants