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

Qt deprecation fix #5619

Merged
merged 3 commits into from
Sep 13, 2020
Merged

Qt deprecation fix #5619

merged 3 commits into from
Sep 13, 2020

Conversation

uthidata
Copy link
Contributor

Fix Qt deprecation warnings

  • Replace QWheelEvent::delta with angleDelta

  • Replace QWheelEvent::orientation with comparison of angleDelta.x and y

  • Remove Qt::WindowFlags parameters when adding SubWindows

  • Remove QFileDialog::Options parameters when opening files
    These parameters are currently not used anywhere.

  • Use QFlag(0) when initializing items in ladspaPortDialog instead of 0

  • Use explicit enum when specifying QStyle state in ComboBox's paintEvent

  • Use QElapsedTimer instead of QTime where appropriate

  • Use QAtomicPointer::loadRelaxed() instead of load()

  • Use QSet(list.begin(), list.end()) instead of list.toSet()

  • Use Qt::endl in QTextStream

  • Use QString::isEmpty() instead of comparing to QString::null

  • Use QFontMetrics::horizontalAdvance instead of width

  • Use QWheelEvent::position() instead of pos()

@LmmsBot
Copy link

LmmsBot commented Aug 10, 2020

🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩

Linux

Windows

macOS

🤖
{"platform_name_to_artifacts": {"Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://8532-15778896-gh.circle-artifacts.com/0/lmms-1.2.2.693-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/8532?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "Windows": [{"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://8531-15778896-gh.circle-artifacts.com/0/lmms-1.2.2.693-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/8531?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://8535-15778896-gh.circle-artifacts.com/0/lmms-1.2.2.693-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/8535?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/kar6d2ci9dhiso4a/artifacts/build/lmms-1.2.2-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/34922746"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/22xj1oha6ced97y0/artifacts/build/lmms-1.2.2-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/34922746"}], "macOS": [{"artifact": {"title": {"title": "", "platform_name": "macOS"}, "link": {"link": "https://8533-15778896-gh.circle-artifacts.com/0/lmms-1.2.2.693-mac10.13.dmg"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/8533?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}]}, "commit_sha": "be7fcaa185c32e15e981ee78835e5a8a99d1e712"}

@PhysSong
Copy link
Member

I recommend you looking at the Qt documentation to check the version compatibility of those functions.

@uthidata
Copy link
Contributor Author

I recommend you looking at the Qt documentation to check the version compatibility of those functions.

I am on it, got a bit sidetracked but I'm finishing up now.

@DomClark DomClark linked an issue Aug 11, 2020 that may be closed by this pull request
@uthidata
Copy link
Contributor Author

@DomClark The pragma warnings and style violations are gone. I think it's ready.

Copy link
Member

@DomClark DomClark left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@JohannesLorenz
Copy link
Contributor

@DomClark as you commented this as lgtm, what kind of review do you expect? At least, from testing, I'm satisfied, as this removed all the warnings mentioned in #5598 .

There are still open comments in this PR btw.

@DomClark
Copy link
Member

What kind of review do you expect?

Just after some confirmation that this fixed the warnings you were seeing, since you opened the issue. Sounds like it does.

There are still open comments in this PR btw.

Resolved.

Will merge tomorrow if there are no objections.

@PhysSong
Copy link
Member

Please wait, I have to check something about wheel events.

@PhysSong
Copy link
Member

Replace QWheelEvent::orientation with comparison of angleDelta.x and y

It does work for Qt 5, but I think it's not a good idea.

  • If it's possible to handle both vertical and horizontal scroll events without that check, why not?
  • Qt 5 generates two events(vertical one and horizontal one) for arbitrary scrolling to be compatible with Qt 4. That's not true in Qt 6 anymore.

SongEditor::wheelEvent looks somewhat tricky to get rid of the trick, so let me check first. AutomationEditor and PianoRoll look fine.

@PhysSong
Copy link
Member

To be clear, SongEditor handles horizontal scroll events and TrackContainerView::scrollArea handles vertical ones. This makes handling wheel events more complicated than other editors.

@Veratil
Copy link
Contributor

Veratil commented Aug 14, 2020

To be clear, SongEditor handles horizontal scroll events and TrackContainerView::scrollArea handles vertical ones. This makes handling wheel events more complicated than other editors.

It doesn't handle horizontal well, but I made this #5174 which still needs to handle Qt version differences.

@uthidata
Copy link
Contributor Author

  • If it's possible to handle both vertical and horizontal scroll events without that check, why not?

The check was there before. I merely translated it into non-deprecated form.

  • Qt 5 generates two events(vertical one and horizontal one) for arbitrary scrolling to be compatible with Qt 4. That's not true in Qt 6 anymore.

I'm not sure what you mean by this. Qt 6 will remove the orientation function, and the angleDelta with x and y will be there. Comparing their absolute values is the fastest way to determine the orientation. Unless you're saying the orientation is not important, but there should be a design document on how you expect it to work. Should the modifiers work regardless of orientation? Which orientation would be prefered?... I think it is not in the scope of this PR. I would gladly change them if you post an issue detailing the problem.


Now that I think of it, maybe we can put the desired behaviors in a unit test?

It doesn't handle horizontal well, but I made this #5174 which still needs to handle Qt version differences.

Unit tests could theoretically solve this across the board. No more manual testings.

@PhysSong
Copy link
Member

I mean, wheel events can have arbitrary orientation in Qt6(not restricted to horizontal or vertical).

@uthidata
Copy link
Contributor Author

What's the desired behavior of wheel scroll on those windows? So I can write tests.

@PhysSong
Copy link
Member

A note on QWheelEvent::position(): There's QWheelEvent::posF() with slightly different signature(the former returns a value whereas the latter returns a constant reference).

@PhysSong
Copy link
Member

Ideally, A wheel event with (dx, dy) should behave the same as the combination of (dx, 0) and (0, dy). If that's tricky for any reason, you should add a TODO comment for Qt 6.

@uthidata
Copy link
Contributor Author

Ideally, A wheel event with (dx, dy) should behave the same as the combination of (dx, 0) and (0, dy). If that's tricky for any reason, you should add a TODO comment for Qt 6.

The comparison is not there to differentiate between (dx, 0) and (0, dy), but to determine the right direction to scroll based on a single (dx, dy).

A note on QWheelEvent::position(): There's QWheelEvent::posF() with slightly different signature(the former returns a value whereas the latter returns a constant reference).

QWheelEvent::posF is deprecated.

@PhysSong
Copy link
Member

Ideally, A wheel event with (dx, dy) should behave the same as the combination of (dx, 0) and (0, dy). If that's tricky for any reason, you should add a TODO comment for Qt 6.

The comparison is not there to differentiate between (dx, 0) and (0, dy), but to determine the right direction to scroll based on a single (dx, dy).

IMHO, (dx, dy) should scroll (dx, dy), neither (dx, 0) nor (0, dy).

A note on QWheelEvent::position(): There's QWheelEvent::posF() with slightly different signature(the former returns a value whereas the latter returns a constant reference).

QWheelEvent::posF is deprecated.

I know, but I mentioned it for position().toPoint() vs. pos() vs. posF.toPoint().

@uthidata
Copy link
Contributor Author

IMHO, (dx, dy) should scroll (dx, dy), neither (dx, 0) nor (0, dy).

How can one scroll (dx, dy) while holding Ctrl + Shift? There is only one scrolling dimension, but two inputs. They will have to combine, or selected. My code currently selects dy.

@uthidata
Copy link
Contributor Author

Hi, what can I change to get this merged?

@PhysSong
Copy link
Member

I think the best way for now is reverting QWheelEvent::orientation() changes or adding a FIXME comment(for Qt 6).

- replace QWheelEvent::delta with angleDelta
- replace QWheelEvent::orientation with comparison of angleDelta.x and y
- use QFlag(0) instead of 0 when appropriate or prompted
- use explicit enum when specifying QStyle state in ComboBox's
  paintEvent
- Use QElapsedTimer instead of QTime where appropriate
- Use QAtomicPointer::loadRelaxed() instead of load()
- Use QSet<T>(list.begin(), list.end()) instead of list.toSet()
- Use Qt::endl in QTextStream
- Use QString::isEmpty() instead of comparing to QString::null
- Use QFontMetrics::horizontalAdvance instead of width
- Use QWheelEvent::position() instead of pos()
@uthidata
Copy link
Contributor Author

I just added FIXME comments where orientation was replaced.

@JohannesLorenz
Copy link
Contributor

Can anyone please summarize which points are still open in this PR?

@uthidata
Copy link
Contributor Author

uthidata commented Sep 5, 2020

All deprecation warnings are fixed. The point about horizontal/vertical scrolling distinction is dealt with as suggested. I don't think there's anything left to do.

@JohannesLorenz
Copy link
Contributor

@PhysSong Can you please check whether your suggestion was coded correctly, and if yes merge this PR?

@PhysSong
Copy link
Member

PhysSong commented Sep 5, 2020

I'll check this again tomorrow and merge if looks okay.

Copy link
Contributor

@JohannesLorenz JohannesLorenz left a comment

Choose a reason for hiding this comment

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

approved from my side - no compiler warnings anymore

@PhysSong
Copy link
Member

I'll merge it in a day unless there are any objections.

@PhysSong PhysSong merged commit 3d8b310 into LMMS:master Sep 13, 2020
IanCaio added a commit to IanCaio/lmms that referenced this pull request Sep 13, 2020
	Resolves the conflict on src/tracks/Pattern.cpp caused by LMMS#5619. On this PR the only change to the file was removing an unnecessary include of the header "StringPairDrag.h", which the PR LMMS#5619 also did. So the file was kept the same way as in the master branch.
Comment on lines +142 to +143
QRandomGenerator::global()->seed(time(0));
m_serialNo = 0xD0000000 + QRandomGenerator::global()->generate() % 0x0FFFFFFF;
Copy link
Member

Choose a reason for hiding this comment

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

Reported on Discord: an user got the following error on OGG export.

Attempted to overwrite a QRandomGenerator to system() or global().

The documentation says QRandomGenerator::global() is already seeded and can't be overwritten by seed().

Copy link
Contributor

Choose a reason for hiding this comment

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

Open a new issue with this information so it gets attention and a PR can reference it?

@Veratil Veratil mentioned this pull request Apr 23, 2022
sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
Qt6 TODO: Orientation check by comparing angleDelta().x() and y() won't make sense
because the direction is arbitrary in Qt 6.
@PhysSong PhysSong mentioned this pull request Jan 17, 2023
26 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.

Fix annoying Qt5 deprecated warnings
6 participants