Qt6: Let Krita build with PyQt6 and port plugins
Let Krita build with PyQt6 and port all built-in plugins to it. Plugins aren't thoroughly tested and may still have bugs, but should mostly work.
This still needs the PyQt6 dep (and related sip, pyqt-builder, pyqt6-sip deps) to be ported in the deps repo.
Notes on building:
-
PyQt5.QtCore.PYQT_CONFIGURATION
used by FindPyQt5.py is removed in PyQt6. Unsure where to get those variables from now or if they're needed. - Added a SIP Feature called
Krita_Qt5
in order to ifdef Qt version in SIP files, by disabling the feature on Qt6. (Checking forQT_5_15_0
orQT_6_8_0
doesn't work as only 5x or 6x timelines are defined in each version.) - Some code in
PythonPluginsModel::data
fails to build on Qt6, I'm not sure why:
Undefined symbols for architecture x86_64:
"KColorScheme::KColorScheme(QPalette::ColorGroup, KColorScheme::ColorSet, QExplicitlySharedDataPointer<KSharedConfig>)", referenced from:
PythonPluginsModel::data(QModelIndex const&, int) const in libpykrita.a[x86_64][6](PythonPluginsModel.cpp.o)
Notes on porting plugins:
- Used
try
/except
to support both PyQt versions. -
QAction
is moved fromQtWidgets
toQtGui
. - All of the following changes needed for PyQt6 also work on PyQt5:
-
-
PyQt5.Qt
is removed, usePyQtX.QtCore.Qt
(X being the appropriate version number).
-
-
-
qApp
is removed, useQApplication.instance()
.
-
-
- Using enum values now requires the enum name, for example ,
Qt.Horizontal
->Qt.Orientation.Horizontal
orQDialogButtonBox.Ok
->QDialogButtonBox.StandardButton.Ok
.
- Using enum values now requires the enum name, for example ,
-
-
exec_()
is nowexec()
, the conflictingexec
keyword was removed in Python3.
-
-
-
QRegExp
is replaced withQRegularExpression
which requires rewritten code.
-
-
-
QFontMetrics().width()
is replaced withQFontMetrics.horizontalAdvance()
.
-
Test Plan
- Install PyQt6 into Krita's Python, build and run Qt6 Krita, test all built-in Python plugins.
- Build and run Qt5 Krita, test all built-in Python plugins.
Formalities Checklist
-
I confirmed this builds. -
I confirmed Krita ran and the relevant functions work. -
I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!) -
I made sure my commits build individually and have good descriptions as per KDE guidelines. -
I made sure my code conforms to the standards set in the HACKING file. -
I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy. -
Does the patch add a user-visible feature? If yes, is there a documentation MR ready for it at Krita Documentation Repository?
Reminder: the reviewer is responsible for merging the patch, this is to ensure at the least two people can build the patch. In case a patch breaks the build, both the author and the reviewer should be contacted to fix the build. If this is not possible, the commits shall be reverted, and a notification with the reasoning and any relevant logs shall be sent to the mailing list, kimageshop@kde.org.