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

Build with Qt6 #532

Merged
merged 24 commits into from
Apr 19, 2024
Merged

Build with Qt6 #532

merged 24 commits into from
Apr 19, 2024

Conversation

doug1234
Copy link
Contributor

Builds and the example runs with qt 6.6.0 on rhel9 with no new warnings. Currently using the qt5 compatibility library as was suggested in other pull requests.

Issue: The cursor is drawn farther to the right then it should be. This was not an issue for me with qt5. Looing into.
Issue: Text is sized differently when selected. This makes an odd effect. This was not an issue for me with qt5.

TODO: Update documentation.

@doug1234
Copy link
Contributor Author

Not sure how to update the CI to use qt6, the qt6 build of lxqt-build-tools and the appropriate python tools for qt6.

@yan12125
Copy link
Member

Not sure how to update the CI to use qt6, the qt6 build of lxqt-build-tools and the appropriate python tools for qt6.

You can ignore it for now. It needs lxqt/lxqt-build-tools#77 to be merged first.

@stefonarch
Copy link
Member

Builds fine, just those warnings:


[ 82%] Building CXX object CMakeFiles/qtermwidget6.dir/lib/tools.cpp.o
/home/stef/git/doug1234/qtermwidget/lib/TerminalCharacterDecoder.cpp: In member function ‘virtual void Konsole::PlainTextDecoder::decodeLine(const Konsole::Character*, int, Konsole::LineProperty)’:
/home/stef/git/doug1234/qtermwidget/lib/TerminalCharacterDecoder.cpp:85:28: warning: comparing the result of pointer addition ‘(((const Konsole::Character*)characters) + ((sizetype)(((long unsigned int)i) * 16)))’ and NULL [-Waddress]
   85 |         if (characters + i == nullptr)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
[ 84%] Building CXX object CMakeFiles/qtermwidget6.dir/lib/Vt102Emulation.cpp.o
[ 85%] Building CXX object CMakeFiles/qtermwidget6.dir/lib/moc_Emulation.cpp.o
[ 86%] Building CXX object CMakeFiles/qtermwidget6.dir/lib/moc_Filter.cpp.o
/home/stef/git/doug1234/qtermwidget/lib/Vt102Emulation.cpp: In member function ‘virtual void Konsole::Vt102Emulation::sendMouseEvent(int, int, int, int)’:
/home/stef/git/doug1234/qtermwidget/lib/Vt102Emulation.cpp:949:56: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size between 7 and 26 [-Wformat-truncation=]
  949 |         snprintf(command, sizeof(command), "\033[%d;%d;%dM", cb + 0x20, cx, cy);
      |                                                        ^~
/home/stef/git/doug1234/qtermwidget/lib/Vt102Emulation.cpp:949:44: note: directive argument in the range [1, 2147483647]
  949 |         snprintf(command, sizeof(command), "\033[%d;%d;%dM", cb + 0x20, cx, cy);
      |                                            ^~~~~~~~~~~~~~~~
/home/stef/git/doug1234/qtermwidget/lib/Vt102Emulation.cpp:949:17: note: ‘snprintf’ output between 9 and 37 bytes into a destination of size 32
  949 |         snprintf(command, sizeof(command), "\033[%d;%d;%dM", cb + 0x20, cx, cy);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


@marcusbritanicus
Copy link
Contributor

Issue: The cursor is drawn farther to the right then it should be. This was not an issue for me with qt5. Looing into.

@doug1234 I took the strain to build konsole Qt6, and they seem to do this properly, I know not how. Since you're working on this, you might have a better idea. On first glance, I noticed that their TerminalDisplay class is much more sophisticated than the one we have here.

Would it help to port that code to QTermWidget?

@yan12125
Copy link
Member

Builds fine, just those warnings:

Those warnings have been there for a long tine. I have a fix at https://github.com/lxqt/qtermwidget/commits/eliminate-warnings/, but I forgot why I didn't push it.

Would it help to port that code to QTermWidget?

That may help but will likely take much more efforts than porting to Qt 6, and thus it's out of scope for this PR in my opinion. A better place for such discussions can be lxqt/qterminal#320

@marcusbritanicus
Copy link
Contributor

marcusbritanicus commented Feb 26, 2024

@yan12125 I did have a look at it before I posted here. That thread seems be sleeping since 2018, and was rather unwilling to wake it up - I seriously disliked the direction it was taking.

I do have a vested interest in QTermWidget - we have two projects based on it (CoreTerminal and DesQ Term) and would like to keep our projects free from KDE parts. So I am willing to spend some time to port TerminalDisplay if that is of any help at all.

Edit: I will see if I can port it without much efforts.

@marcusbritanicus
Copy link
Contributor

marcusbritanicus commented Feb 26, 2024

@doug1234 Fantastic work...!

Issue: The cursor is drawn farther to the right then it should be. This was not an issue for me with qt5. Looing into.

I think I fixed this issue. Following are the changes I made:

diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp
index 3018f65..0ccfb75 100644
--- a/lib/TerminalDisplay.cpp
+++ b/lib/TerminalDisplay.cpp
@@ -291,6 +291,15 @@ void TerminalDisplay::setVTFont(const QFont& f)
   // Disabling kerning saves some computation when rendering text.
   font.setKerning(false);
 
+  // QFont::ForceIntegerMetrics has been removed.
+  // Set full hinting instead to ensure the letters are aligned properly.
+  font.setHintingPreference(QFont::PreferFullHinting);
+
+  // "Draw intense colors in bold font" feature needs to use different font weights. StyleName
+  // property, when set, doesn't allow weight changes. Since all properties (weight, stretch,
+  // italic, etc) are stored in QFont independently, in almost all cases styleName is not needed.
+  font.setStyleName(QString());
+
   QWidget::setFont(font);
   fontChange(font);
 }

@yan12125 Looks like porting of TerminalDisplay is not required.

PS: @doug1234 I have opened a PR in your repo with these changes.

@doug1234
Copy link
Contributor Author

It looks great now thanks to help from @marcusbritanicus ! The only reason I can see not to merge is documentation since you don't want to update the ci here. I can tweak the documentation if you want but I am going to remove the draft tag now.

@doug1234 doug1234 changed the title Draft: Build with Qt6 Build with Qt6 Feb 26, 2024
@yan12125
Copy link
Member

yan12125 commented Mar 1, 2024

Thank you both for awesome efforts! I should be able to have a look in coming days.

The only reason I can see not to merge is documentation since you don't want to update the ci here.

Yes almost. Just need lxqt/lxqt-build-tools#77 and cleanup lxqt/qterminal#1067

I seriously disliked the direction it was taking.

That's just a discussion. If there is a need to port Konsole codes in the future, feel free to propose alternative approaches.

Copy link
Member

@yan12125 yan12125 left a comment

Choose a reason for hiding this comment

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

(Only first few files checked)

examples/cpp/main.cpp Show resolved Hide resolved
lib/ColorScheme.cpp Outdated Show resolved Hide resolved
Copy link
Member

@yan12125 yan12125 left a comment

Choose a reason for hiding this comment

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

Second batch. Codes related to KPty and TerminalDisplay are remaining.

lib/TerminalDisplay.cpp Outdated Show resolved Hide resolved
lib/qtermwidget.cpp Outdated Show resolved Hide resolved
lib/qtermwidget.h Outdated Show resolved Hide resolved
lib/qtermwidget_interface.h Outdated Show resolved Hide resolved
@yan12125
Copy link
Member

Not sure how to update the CI to use qt6, the qt6 build of lxqt-build-tools and the appropriate python tools for qt6.

I started testing Qt 6 CI in https://github.com/lxqt/qtermwidget/commits/qt6-ci/. The C++ part looks good, while the PyQt part may need some tricks.

Copy link
Member

@yan12125 yan12125 left a comment

Choose a reason for hiding this comment

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

The final batch of reviews! Sorry it takes long with many rounds.

lib/kptyprocess.h Outdated Show resolved Hide resolved
lib/kptyprocess.cpp Show resolved Hide resolved
lib/TerminalDisplay.cpp Show resolved Hide resolved
@yan12125
Copy link
Member

TODO: Update documentation.

What documentation needs updates?

Another question: is this an independent work or based on earlier pull requests in this repo? If the latter, it's better to give credits to authors of other pull requests.

@doug1234
Copy link
Contributor Author

I definitely looked at the original branch and used it as a starting point for some things. Let me know how you would like me to give credit to the original author. I am willing to do it however you want.

@doug1234
Copy link
Contributor Author

As far as documentation goes, I think we may need to change references to qt5 to qt6. Not sure if there is anything else or not. I can look into it if you want.

lib/kptyprocess.cpp Outdated Show resolved Hide resolved
lib/kptyprocess.cpp Show resolved Hide resolved
lib/TerminalDisplay.cpp Show resolved Hide resolved
@doug1234
Copy link
Contributor Author

doug1234 commented Apr 6, 2024

I bumped the version to 2.0.0. Please give a final review @yan12125 as I think this is looking pretty good now.

@yan12125
Copy link
Member

Thanks for the update. I tried non-BMP emoji, emoji flag sequence, and emoji variation selector, and there is no case working in Qt 5 but not in Qt 6. I think the implementation is good enough - will take a look this week.

@tsujan
Copy link
Member

tsujan commented Apr 10, 2024

.... there is no case working in Qt 5 but not in Qt 6.

That's a Qt6 problem/regression I encountered years ago. It's visible in all Qt6 apps.

@tsujan
Copy link
Member

tsujan commented Apr 10, 2024

Oh, sorry, I misread your comment! (Read "no case" as "one case".)

I meant that there are emojis which are shown correctly in Qt5 apps but not in Qt6 apps. Otherwise, I haven't tried the Qt6-based QTerminal yet.

@yan12125
Copy link
Member

Thank you very much for the efforts! I will merge this along with lxqt/qterminal#1067, after cleaning up remaining Qt 5 stuff in the latter.

That's a Qt6 problem/regression I encountered years ago. It's visible in all Qt6 apps.

Well, a case that breaks many Qt apos may be out of scope of this PR

@tsujan
Copy link
Member

tsujan commented Apr 11, 2024

Well, a case that breaks many Qt apos may be out of scope of this PR

And that was my point: If there are some emojis that aren't shown correctly in the Qt6 version, the problem might be in Qt6 itself, not in QTerminal.

@luis-pereira luis-pereira mentioned this pull request Apr 12, 2024
@yan12125
Copy link
Member

Found an issue: after 0f2cbfe, URLs are not underlined when hovered. I suspect changes in Filter.cpp break it, as that class is for filtering specific patterns (ex: URLs) from terminal contents.

Will the Qt6 port of QTerminal be ready before the next release, which will happen around Apr 15, 2024?

@tsujan It seems remaining work may not be trivial. I prefer to postpone Qt 6 port of qtermwidget to the next LXQt release.

@tsujan
Copy link
Member

tsujan commented Apr 13, 2024

It seems remaining work may not be trivial.

I understand. It could be released whenever it's ready and tested.

@doug1234
Copy link
Contributor Author

Found an issue: after 0f2cbfe, URLs are not underlined when hovered. I suspect changes in Filter.cpp break it, as that class is for filtering specific patterns (ex: URLs) from terminal contents.

Will the Qt6 port of QTerminal be ready before the next release, which will happen around Apr 15, 2024?

@tsujan It seems remaining work may not be trivial. I prefer to postpone Qt 6 port of qtermwidget to the next LXQt release.

I should be able to take a look early next week. I wouldn't expect the fix to be too difficult.

@yan12125
Copy link
Member

Thanks for the kind help. If the URL issue is resolved before LXQt 2.0, it's still good to postpone the Qt 6 version, as overall changes in this PR are non-trivial and require intensive testing.

@doug1234
Copy link
Contributor Author

Thanks for the kind help. If the URL issue is resolved before LXQt 2.0, it's still good to postpone the Qt 6 version, as overall changes in this PR are non-trivial and require intensive testing.

OK. I am pretty sure I already see the mistake that caused this. It should be a super quick fix. But schedule the release for whenever you think is best.

@tsujan
Copy link
Member

tsujan commented Apr 14, 2024

No need to worry about the release date. We could release the port whenever it's thoroughly tested. I added a note to the draft of the release announcement of LXQt 2.0.0:. Check if it's good enough:

"QTerminal is the only app whose Qt6 port will be released separately -- complications were encountered due to the removal of legacy encodings from Qt6. Until then, its Qt5 version 1.4.0 could be used."

Copy link
Member

@luis-pereira luis-pereira left a comment

Choose a reason for hiding this comment

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

GTM.
Should land on master ASAP.
Any issues can be address there,
@doug1234 Nice work.

@doug1234
Copy link
Contributor Author

Anchored pattern was not necessary for urls. Removing that got URLs working as they do in qt5.

@yan12125
Copy link
Member

Thanks! I will test again and finish cleaning up the qterminal PR these two days, and then both can be merged. If you wish, you can do a rebase and cleanup some commits (ex: previous attempts for Qt6 compatibility). It's also fine to skip further cleanups - I will merge all commits as-is.

@doug1234
Copy link
Contributor Author

Great! I think I am going to leave it as is unless you find something else.

@yan12125 yan12125 merged commit 48ca3dd into lxqt:master Apr 19, 2024
1 check passed
@yan12125
Copy link
Member

Here we go 🎉

@isf63
Copy link

isf63 commented Apr 20, 2024

I'm unsure on how to get the QTermWidget bindings from PyQt6 to build. With both python-pyqt5 and python-pyqt6 installed it selects PyQt5. Didn't see anything in the Arch PKGBUILD that changes that.

@marcusbritanicus
Copy link
Contributor

@isf63 have a look at this. We're using this command to generate the PyQt6 bindings.

@isf63
Copy link

isf63 commented Apr 24, 2024

@marcusbritanicus: Thanks, that got me further, but still no complete success:

Generating the QTermWidget bindings...
/usr/lib/python3.11/site-packages/PyQt6/bindings/QtCore/QtCoremod.sip: line 64: '%Plugin' is deprecated and will be removed in SIP v7.0.0
Generating the .pro file for the QTermWidget module...
Generating the top-level .pro file...
Generating the Makefiles...
/usr/bin/qmake6 -recursive QTermWidget.pro
Info: creating stash file /tmp/tmpx8qs774o/.qmake.stash
Reading /tmp/tmpx8qs774o/QTermWidget/QTermWidget.pro
Compiling the project...
make
cd QTermWidget/ && ( test -e Makefile || /usr/bin/qmake6 -o Makefile /tmp/tmpx8qs774o/QTermWidget/QTermWidget.pro ) && make -f Makefile 
make[1]: Entering directory '/tmp/tmpx8qs774o/QTermWidget'
g++ -c -pipe -I/tmp/makepkg/qtermwidget-git/src/qtermwidget/pyqt/../lib -I/tmp/makepkg/qtermwidget-git/src/qtermwidget/pyqt/../build/lib -fno-exceptions -Wall -Wextra -mno-direct-extern-access -D_REENTRANT -fPIC -DPy_LIMITED_API=0x03080000 -DSIP_PROTECTED_IS_PUBLIC -Dprotected=public -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I.. -I/usr/include/python3.11 -I/usr/include/qt6 -I/usr/include/qt6/QtWidgets -I/usr/include/qt6/QtGui -I/usr/include/qt6/QtCore -I. -I/usr/lib/qt6/mkspecs/linux-g++ -o sipQTermWidgetcmodule.o sipQTermWidgetcmodule.cpp
g++ -c -pipe -I/tmp/makepkg/qtermwidget-git/src/qtermwidget/pyqt/../lib -I/tmp/makepkg/qtermwidget-git/src/qtermwidget/pyqt/../build/lib -fno-exceptions -Wall -Wextra -mno-direct-extern-access -D_REENTRANT -fPIC -DPy_LIMITED_API=0x03080000 -DSIP_PROTECTED_IS_PUBLIC -Dprotected=public -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I.. -I/usr/include/python3.11 -I/usr/include/qt6 -I/usr/include/qt6/QtWidgets -I/usr/include/qt6/QtGui -I/usr/include/qt6/QtCore -I. -I/usr/lib/qt6/mkspecs/linux-g++ -o sipQTermWidgetQTermWidget.o sipQTermWidgetQTermWidget.cpp
In file included from /tmp/makepkg/qtermwidget-git/src/qtermwidget/pyqt/../lib/qtermwidget.h:25,
                 from /tmp/makepkg/qtermwidget-git/src/qtermwidget/pyqt/sip/qtermwidget.sip:14:
/tmp/makepkg/qtermwidget-git/src/qtermwidget/pyqt/../lib/Emulation.h:36:10: fatal error: qtermwidget_export.h: No such file or directory
   36 | #include "qtermwidget_export.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

@marcusbritanicus
Copy link
Contributor

@isf63 Right. I tried to compile on a fresh setup. I too hit this error. The simplest solution is to install the C++ library first. Then you can compile and install the pyqt bindings. How this works on the ci I am not sure.

@yan12125 yan12125 mentioned this pull request May 3, 2024
while( ((right.x()<_usedColumns-1) || (right.y()<_usedLines-1 && (_lineProperties[right.y()] & LINE_WRAPPED) ))
&& charClass(_image[i+1].character) == selClass )
&& charClass(QChar(static_cast<ushort>(_image[i-1].character))) == selClass )

This comment was marked as outdated.

This comment was marked as resolved.

setCodec(LocaleCodec);

delete _decoder;
_decoder = _codec->makeDecoder();

This comment was marked as resolved.

Copy link
Member

Choose a reason for hiding this comment

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

https://doc.qt.io/qt-6/qstringencoder.html → "The encoder remembers any state that is required between calls,..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

8 participants