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

Initial Qt6 support #1046

Merged
merged 2 commits into from
Mar 4, 2024
Merged

Initial Qt6 support #1046

merged 2 commits into from
Mar 4, 2024

Conversation

adamlamar
Copy link
Collaborator

@adamlamar adamlamar commented Feb 28, 2024

Fixes #1033
Fixes #365
Fixes #912

This PR implements compile support for Qt6. There are still some bugs and limitations, but the app compiles and runs. The changes mostly fall into these categories:

  • Disabling deprecated APIs in 6.0+ in the Qt5 build
  • Adding a few Q_OBJECT references per the clazy tool checks
  • Some minor changes to string handling that usually caused ambiguous method references, or because a constructor was removed
  • Handling of new methods or introduction of enum types (e.g. enums converted from int usually don't implement operator+)

A few more things to fix before this is ready to merge:

  • The "more" menu (the ... icon) needs to be built
  • The context menu for the webview no longer has access to createStandardContextMenu() - need to find the replacement
  • The print method no longer exists on a webview page - need to write up an approach to write a temporary PDF to disk, then print the PDF
  • Write up a README to document instructions for building with Qt6 on ubuntu 22.04
  • Test the new keybind sequences on a non-VM

@adamlamar adamlamar mentioned this pull request Feb 28, 2024
@kelson42
Copy link
Collaborator

@adamlamar Thank you very much for this draft.
@mgautierfr @mgautierfr Could younplease have already a quick look and give feedback about what has been done so far?

@adamlamar
Copy link
Collaborator Author

Some more updates on the context menu:

  • I couldn't find much on the Qt6 docs, but AFAICT the createStandardContextMenu method is simply not available anymore. I decided to implement a custom QMenu and make it more consistent with typical browser behaviors
  • When you right-click on the background, you get the standard Back/Forward actions. The new menu uses the same icons as the toolbar, instead of the previously used system icons
  • When you right-click on an internal link, you get Open in new tab. This is also what happens if you middle click on a link (and this is what browsers typically do)
  • When you right-click on an external link, you get Open in new browser window. This is what happened before
  • There are no longer menu actions to Copy link or Save link, since I believe these were not intended (see screenshot below)

Old:
Screenshot 2024-02-28 at 5 35 20 PM
Screenshot 2024-02-28 at 5 35 09 PM

Here's a video with the new approach:

new-context-menu.webm

@adamlamar
Copy link
Collaborator Author

@mgautierfr I've completed the tasks above and AFAICT everything is working on both Qt5 and Qt6. Should be ready for a full review. Let me know if you have any questions.

@adamlamar adamlamar marked this pull request as ready for review March 1, 2024 01:11
@kelson42
Copy link
Collaborator

kelson42 commented Mar 1, 2024

I had a brief look, here is a first set of remarks:

  • Compiles great with qt5
  • Instruction to move to qt6 are perfect and switch is smooth
  • Compilation works even if IMO a few warnings are new and should probably be fixed (if possible)
  • The library language filter seems broken for me with qt6 (after relaunching it seems the bug has disappeared):
    image

@kelson42
Copy link
Collaborator

kelson42 commented Mar 1, 2024

To me it fixes #365, #912 (with qt6.2 on Ubuntu), Could someone confirm?

Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

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

I only reviewed the code (didn't try to build and test kiwix-desktop with qt6).

src/mainwindow.cpp Outdated Show resolved Hide resolved
src/topwidget.cpp Outdated Show resolved Hide resolved
src/topwidget.cpp Outdated Show resolved Hide resolved
src/contentmanagerdelegate.cpp Outdated Show resolved Hide resolved
src/contentmanagerdelegate.cpp Outdated Show resolved Hide resolved
src/webview.cpp Show resolved Hide resolved
src/kiwixapp.cpp Outdated Show resolved Hide resolved
src/fullscreenwindow.cpp Outdated Show resolved Hide resolved
@adamlamar
Copy link
Collaborator Author

@kelson42 I noticed those same warnings, but I believe they were preexisting. I actually have a branch where I fixed all the warnings and enabled -Werror, but its based on this branch so might be easier to wait until this is merged. I also noticed that library selection issue on first start - let me see if I can reproduce and figure out what's going on.

@veloman-yunkan Thanks for the comments. I will work on improving the code portability in those places where there is some duplication. As for the commits, I typically squash before merge anyway. I can do that sooner so that the extra cruft isn't around.

@adamlamar adamlamar force-pushed the prepare-qt6 branch 2 times, most recently from fb7ec2c to 7237e7c Compare March 1, 2024 19:59
@adamlamar
Copy link
Collaborator Author

@kelson42 After looking into the Language filter issue I discovered that it was not constructing the QVariant correctly, even in Qt5. If I understand the intent, the default on first startup is to show you a filtered set of zim files that match your current system language+locale. For example mine is English|en. When printed to the console, the correct language list looks like this:

langList (QVariant(QString, "English|en"))

Two things:

  • In Qt5, the language list was always empty, despite the default being set, which made the filter always empty (maybe this feature was not working as intended)
  • In Qt6, every character became is its own item in an array of QChar:
langList QList(QVariant(QChar, 'E'), QVariant(QChar, 'n'), QVariant(QChar, 'g'), QVariant(QChar, 'l'), QVariant(QChar, 'i'), QVariant(QChar, 's'), QVariant(QChar, 'h'), QVariant(QChar, '|'), QVariant(QChar, 'e'), QVariant(QChar, 'n'))

After my fixes, the language filter is shown on first start in both:
Screenshot 2024-03-01 at 3 29 40 PM

@veloman-yunkan This should be ready for another review.

@adamlamar adamlamar changed the title Prepare codebase for qt6 Initial Qt6 support Mar 1, 2024
@adamlamar adamlamar requested a review from veloman-yunkan March 1, 2024 22:35
Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

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

Having all your changes squashed into a single commit hurts more than it helps. Seeing issues described and resolved one (or a few) at a time is useful.

Please address the new comments as fixup commits so that I don't have to look through the full list of changes during the next (hopefully, last) iteration.

src/kiwixapp.cpp Outdated Show resolved Hide resolved
src/settingsmanager.cpp Outdated Show resolved Hide resolved
subprojects/QtSingleApplication/src/qtlockedfile.h Outdated Show resolved Hide resolved
@adamlamar adamlamar requested a review from veloman-yunkan March 3, 2024 19:04
Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

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

LGTM

@kelson42
Copy link
Collaborator

kelson42 commented Mar 4, 2024

@adamlamar Thank you very much for this PR. This is a very nice step forward. We might a few adjustments to do post PR, and might then contact you then.

@kelson42 kelson42 merged commit 6c03254 into kiwix:main Mar 4, 2024
4 checks passed
@adamlamar adamlamar deleted the prepare-qt6 branch March 4, 2024 18:57
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.

Port to qt6 Tab graphic bug Fullscreen is broken on Wayland.
3 participants