Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Port Python plugins to PyQt6
Freya Lupendccefc69f092
diff --git a/plugins/extensions/pykrita/plugin/krita/__init__.py b/plugins/extensions/pykrita/plugin/krita/__init__.pyindex 79db5bb6c1..0f8c229c7a 100644--- a/plugins/extensions/pykrita/plugin/krita/__init__.py+++ b/plugins/extensions/pykrita/plugin/krita/__init__.py@@ -22,11 +22,14 @@ print("%s added to PYTHONPATH" % krita_path, file=sys.stderr)# Look for PyQttry:- from PyQt5 import QtCore-except ImportError:- print("Python cannot find the Qt5 bindings.", file=sys.stderr)- print("Please make sure, that the needed packages are installed.", file=sys.stderr)- raise+ from PyQt6 import QtCore+except:+ try:+ from PyQt5 import QtCore+ except ImportError:+ print("Python cannot find the Qt5 bindings.", file=sys.stderr)+ print("Please make sure, that the needed packages are installed.", file=sys.stderr)+ raise# Shows nice looking error dialog if an unhandled exception occurs.import excepthookdiff --git a/plugins/extensions/pykrita/plugin/krita/attic/mikro.py b/plugins/extensions/pykrita/plugin/krita/attic/mikro.pyindex 915239072c..5a6de19617 100644--- a/plugins/extensions/pykrita/plugin/krita/attic/mikro.py+++ b/plugins/extensions/pykrita/plugin/krita/attic/mikro.py@@ -15,13 +15,20 @@ you have to know about metaclasses in Python"""import sys+try:- from PyQt5 import sip # Private sip module, used by modern PyQt5-except ImportError:- import sip # For older PyQt5 versions-from PyQt5.QtCore import QVariant, QMetaObject, Q_RETURN_ARG, Q_ARG, QObject, Qt, QMetaMethod, pyqtSignal-from PyQt5.QtGui import QBrush, QFont, QImage, QPalette, QPixmap-from PyQt5.QtWidgets import qApp+ from PyQt6 import sip # Private sip module, used by modern PyQt6+ from PyQt6.QtCore import QVariant, QMetaObject, Q_RETURN_ARG, Q_ARG, QObject, Qt, QMetaMethod, pyqtSignal+ from PyQt6.QtGui import QBrush, QFont, QImage, QPalette, QPixmap+ #from PyQt6.QtWidgets import qApp+except:+ try:+ from PyQt5 import sip # Private sip module, used by modern PyQt5+ except ImportError:+ import sip # For older PyQt5 versions+ from PyQt5.QtCore import QVariant, QMetaObject, Q_RETURN_ARG, Q_ARG, QObject, Qt, QMetaMethod, pyqtSignal+ from PyQt5.QtGui import QBrush, QFont, QImage, QPalette, QPixmap+ from PyQt5.QtWidgets import qAppvariant_converter = {@@ -327,7 +334,7 @@ class PyQtMethod(object):def wrapper(obj, *args):qargs = [Q_ARG(t, v) for t, v in zip(self.args, args)]invoke_args = [obj._instance, self.name]- invoke_args.append(Qt.DirectConnection)+ invoke_args.append(Qt.ConnectionType.DirectConnection)rtype = self.returnTypeif rtype:invoke_args.append(Q_RETURN_ARG(rtype))@@ -367,7 +374,7 @@ def create_pyqt_class(metaobject):signals = attrs["__signals__"] = {}for i in range(metaobject.methodCount()):meta_method = metaobject.method(i)- if meta_method.methodType() != QMetaMethod.Signal:+ if meta_method.methodType() != QMetaMethod.MethodType.Signal:method = PyQtMethod(meta_method)method_name = method.nameif method_name in attrs:diff --git a/plugins/extensions/pykrita/plugin/krita/attic/scripter_hooks.py b/plugins/extensions/pykrita/plugin/krita/attic/scripter_hooks.pyindex e074c27863..82c7013c41 100644--- a/plugins/extensions/pykrita/plugin/krita/attic/scripter_hooks.py+++ b/plugins/extensions/pykrita/plugin/krita/attic/scripter_hooks.py@@ -11,7 +11,10 @@ Support for the toolbar, statusbar and dockarea have still to be implemented.I have to think about how to provide this stuff to QtQml."""-from PyQt5.QtWidgets import QApplication, QMenu+try:+ from PyQt6.QtWidgets import QApplication, QMenu+except:+ from PyQt5.QtWidgets import QApplication, QMenuimport mikrodiff --git a/plugins/extensions/pykrita/plugin/krita/decorators.py b/plugins/extensions/pykrita/plugin/krita/decorators.pyindex 3bcaa2a8e5..7dd37c842b 100644--- a/plugins/extensions/pykrita/plugin/krita/decorators.py+++ b/plugins/extensions/pykrita/plugin/krita/decorators.py@@ -13,7 +13,10 @@ import inspectimport sysimport traceback-from PyQt5 import QtCore, QtGui, QtWidgets+try:+ from PyQt6 import QtCore, QtGui, QtWidgets+except:+ from PyQt5 import QtCore, QtGui, QtWidgetsimport pykritadiff --git a/plugins/extensions/pykrita/plugin/krita/dockwidgetfactory.py b/plugins/extensions/pykrita/plugin/krita/dockwidgetfactory.pyindex 00f7b89c07..fdc71bbf91 100644--- a/plugins/extensions/pykrita/plugin/krita/dockwidgetfactory.py+++ b/plugins/extensions/pykrita/plugin/krita/dockwidgetfactory.py@@ -2,9 +2,14 @@# SPDX-License-Identifier: GPL-3.0-or-later#-from PyQt5.QtCore import *-from PyQt5.QtGui import *-from PyQt5.QtWidgets import *+try:+ from PyQt6.QtCore import *+ from PyQt6.QtGui import *+ from PyQt6.QtWidgets import *+except:+ from PyQt5.QtCore import *+ from PyQt5.QtGui import *+ from PyQt5.QtWidgets import *from PyKrita.krita import *diff --git a/plugins/extensions/pykrita/plugin/krita/excepthook.py b/plugins/extensions/pykrita/plugin/krita/excepthook.pyindex a6b7fafc4f..ec4c762a14 100644--- a/plugins/extensions/pykrita/plugin/krita/excepthook.py+++ b/plugins/extensions/pykrita/plugin/krita/excepthook.py@@ -14,8 +14,12 @@ import sysimport tracebackimport atexit-from PyQt5.QtCore import pyqtSlot, Qt-from PyQt5.QtWidgets import QApplication, QDialog+try:+ from PyQt6.QtCore import pyqtSlot, Qt+ from PyQt6.QtWidgets import QApplication, QDialog+except:+ from PyQt5.QtCore import pyqtSlot, Qt+ from PyQt5.QtWidgets import QApplication, QDialogfrom excepthook_ui import Ui_ExceptHookDialog@@ -26,7 +30,7 @@ def on_error(exc_type, exc_obj, exc_tb):"""dlg = ExceptHookDialog(exc_type, exc_obj, exc_tb)dlg.show()- dlg.exec_()+ dlg.exec()def show_current_error(title=None):@@ -36,7 +40,7 @@ def show_current_error(title=None):"""dlg = ExceptHookDialog(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], title)dlg.show()- dlg.exec_()+ dlg.exec()def install():diff --git a/plugins/extensions/pykrita/plugin/krita/excepthook_ui.py b/plugins/extensions/pykrita/plugin/krita/excepthook_ui.pyindex 4b68f5448f..0a16e86a7d 100644--- a/plugins/extensions/pykrita/plugin/krita/excepthook_ui.py+++ b/plugins/extensions/pykrita/plugin/krita/excepthook_ui.py@@ -6,7 +6,10 @@## WARNING! All changes made in this file will be lost!-from PyQt5 import QtCore, QtGui, QtWidgets+try:+ from PyQt6 import QtCore, QtGui, QtWidgets+except:+ from PyQt5 import QtCore, QtGui, QtWidgetsclass Ui_ExceptHookDialog(object):diff --git a/plugins/extensions/pykrita/plugin/krita/sceditor/assist.py b/plugins/extensions/pykrita/plugin/krita/sceditor/assist.pyindex b71c401261..d91d17e019 100644--- a/plugins/extensions/pykrita/plugin/krita/sceditor/assist.py+++ b/plugins/extensions/pykrita/plugin/krita/sceditor/assist.py@@ -2,17 +2,22 @@# SPDX-License-Identifier: GPL-3.0-or-later#-from PyQt5.QtCore import QTimer, Qt-from PyQt5.QtWidgets import (qApp, QListWidget, QListWidgetItem, QTextBrowser,- QVBoxLayout, QWidget)+try:+ from PyQt6.QtCore import QTimer, Qt+ from PyQt6.QtWidgets import (QApplication, QListWidget, QListWidgetItem, QTextBrowser,+ QVBoxLayout, QWidget)+except:+ from PyQt5.QtCore import QTimer, Qt+ from PyQt5.QtWidgets import (QApplication, QListWidget, QListWidgetItem, QTextBrowser,+ QVBoxLayout, QWidget)class PopupWidget(QWidget):def __init__(self, textedit):- flags = Qt.ToolTip- flags = Qt.Window | Qt.FramelessWindowHint | \- Qt.CustomizeWindowHint | Qt.X11BypassWindowManagerHint+ flags = Qt.WindowType.ToolTip+ flags = Qt.WindowType.Window | Qt.WindowType.FramelessWindowHint | \+ Qt.WindowType.CustomizeWindowHint | Qt.WindowType.X11BypassWindowManagerHintQWidget.__init__(self, None, flags)self.textedit = texteditself.vlayout = QVBoxLayout(self)@@ -24,7 +29,7 @@ class PopupWidget(QWidget):def show(self, timeout=0, above=False):self.cursor_start_col = self.textedit.textCursor().columnNumber()- desktop = qApp.desktop()+ desktop = QApplication.instance().desktop()screen = desktop.screen(desktop.screenNumber(self))screen_width = screen.width()screen_height = screen.height()@@ -112,7 +117,7 @@ class AutoComplete(PopupWidget):self.list.keyPressEvent(event)key = event.key()text = event.text()- if key in [Qt.Key_Right, Qt.Key_Enter, Qt.Key_Return]:+ if key in [Qt.Key.Key_Right, Qt.Key.Key_Enter, Qt.Key.Key_Return]:text = ""cursor = self.textedit.textCursor()line = unicode(cursor.block().text())@@ -131,9 +136,9 @@ class AutoComplete(PopupWidget):self.hide()return- if key in [Qt.Key_Up, Qt.Key_Down, Qt.Key_PageUp, Qt.Key_PageDown]:+ if key in [Qt.Key.Key_Up, Qt.Key.Key_Down, Qt.Key.Key_PageUp, Qt.Key.Key_PageDown]:return True- elif key in [Qt.Key_Tab, Qt.Key_Right, Qt.Key_Enter, Qt.Key_Return]:+ elif key in [Qt.Key.Key_Tab, Qt.Key.Key_Right, Qt.Key.Key_Enter, Qt.Key.Key_Return]:self.insert()return Trueelif not text:diff --git a/plugins/extensions/pykrita/plugin/krita/sceditor/console.py b/plugins/extensions/pykrita/plugin/krita/sceditor/console.pyindex 5a88b4605e..da1bb59eca 100644--- a/plugins/extensions/pykrita/plugin/krita/sceditor/console.py+++ b/plugins/extensions/pykrita/plugin/krita/sceditor/console.py@@ -8,16 +8,24 @@ import sysimport tracebackimport re-from PyQt5.QtCore import QObject, Qt-from PyQt5.QtGui import QTextCursor-from PyQt5.QtWidgets import qApp, QApplication, QPlainTextEdit+try:+ from PyQt6.QtCore import QObject, Qt+ from PyQt6.QtGui import QTextCursor+ from PyQt6.QtWidgets import QApplication, QPlainTextEdit+except:+ from PyQt5.QtCore import QObject, Qt+ from PyQt5.QtGui import QTextCursor+ from PyQt5.QtWidgets import QApplication, QPlainTextEditfrom highlighter import PythonHighlighter, QtQmlHighlighter--from PyQt5.QtQml import (- QScriptEngine, QScriptValue, QScriptValueIterator)+try:+ from PyQt6.QtQml import (+ QScriptEngine, QScriptValue, QScriptValueIterator)+except:+ from PyQt5.QtQml import (+ QScriptEngine, QScriptValue, QScriptValueIterator)class OutputWidget(QPlainTextEdit):@@ -45,12 +53,12 @@ class OutputWidget(QPlainTextEdit):doc = self.document()cursor = QTextCursor(doc)cursor.clearSelection()- cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)+ cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor)cursor.insertText(s)- cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)+ cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor)cursor.clearSelection()self.ensureCursorVisible()- qApp.processEvents()+ QApplication.instance().processEvents()def writelines(self, lines):self.write("\n".join(lines))@@ -81,7 +89,7 @@ class ConsoleWidget(OutputWidget):def keyPressEvent(self, event):def remove_line():cursor = self.textCursor()- cursor.select(QTextCursor.BlockUnderCursor)+ cursor.select(QTextCursor.SelectionType.BlockUnderCursor)cursor.removeSelectedText()key = event.key()modifiers = event.modifiers()@@ -89,23 +97,23 @@ class ConsoleWidget(OutputWidget):line = unicode(self.document().end().previous().text())ps1orps2, line = line[:l - 1], line[l:]- if not key in [Qt.Key_Tab, Qt.Key_Backtab] and \+ if not key in [Qt.Key.Key_Tab, Qt.Key.Key_Backtab] and \len(event.text()):self.tab_state = -1- if key == Qt.Key_Up:+ if key == Qt.Key.Key_Up:if self.history_index + 1 < len(self.history):self.history_index += 1remove_line()print()print(ps1orps2, self.history[self.history_index], end='')- elif key == Qt.Key_Down:+ elif key == Qt.Key.Key_Down:if self.history_index > 0:self.history_index -= 1remove_line()print()print(ps1orps2, self.history[self.history_index], end='')- elif key == Qt.Key_Tab:- if modifiers & Qt.ControlModifier:+ elif key == Qt.Key.Key_Tab:+ if modifiers & Qt.KeyboardModifier.ControlModifier:print(" " * 4, end='')else:self.tab_state += 1@@ -113,18 +121,18 @@ class ConsoleWidget(OutputWidget):print()print(ps1orps2, end='')print(self.completer.complete(line, self.tab_state) or line, end='')- elif key == Qt.Key_Backtab:+ elif key == Qt.Key.Key_Backtab:if self.tab_state >= 0:self.tab_state -= 1remove_line()print()print(ps1orps2, end='')print(self.completer.complete(line, self.tab_state) or line, end='')- elif key in [Qt.Key_Backspace, Qt.Key_Left]:+ elif key in [Qt.Key.Key_Backspace, Qt.Key.Key_Left]:if self.textCursor().columnNumber() > len(ps1orps2) + 1:return OutputWidget.keyPressEvent(self, event)- elif key == Qt.Key_Return:- self.moveCursor(QTextCursor.EndOfLine, QTextCursor.MoveAnchor)+ elif key == Qt.Key.Key_Return:+ self.moveCursor(QTextCursor.MoveOperation.EndOfLine, QTextCursor.MoveMode.MoveAnchor)print()if self.push(line):print(self.ps2, end='')@@ -457,7 +465,7 @@ class QtQmlConsole(ConsoleWidget):return QScriptValue(engine, repr(l))namespace["print"] = console_printnamespace["dir"] = dir_context- namespace["Application"] = qApp+ namespace["Application"] = QApplication.instance()try:namespace["Scripter"] = Scripter.qtexcept:@@ -476,4 +484,4 @@ if __name__ == "__main__":o.resize(640, 480)o.attach()o.show()- app.exec_()+ app.exec()diff --git a/plugins/extensions/pykrita/plugin/krita/sceditor/dockwidget.py b/plugins/extensions/pykrita/plugin/krita/sceditor/dockwidget.pyindex 9e0fa25138..cc5281349a 100644--- a/plugins/extensions/pykrita/plugin/krita/sceditor/dockwidget.py+++ b/plugins/extensions/pykrita/plugin/krita/sceditor/dockwidget.py@@ -4,12 +4,20 @@# SPDX-License-Identifier: GPL-2.0-or-laterimport os-from PyQt5.QtCore import QPoint, QSize, Qt, QRect, QTimer-from PyQt5.QtGui import (QIcon, QPainter)-from PyQt5.QtWidgets import (QAbstractButton, QApplication, QComboBox,- QDockWidget, QHBoxLayout, QLayout, QMainWindow,- QPushButton, QStyle, QStyleOptionDockWidget,- QStyleOptionToolButton, QStylePainter, QWidget)+try:+ from PyQt6.QtCore import QPoint, QSize, Qt, QRect, QTimer+ from PyQt6.QtGui import (QIcon, QPainter)+ from PyQt6.QtWidgets import (QAbstractButton, QApplication, QComboBox,+ QDockWidget, QHBoxLayout, QLayout, QMainWindow,+ QPushButton, QStyle, QStyleOptionDockWidget,+ QStyleOptionToolButton, QStylePainter, QWidget)+except:+ from PyQt5.QtCore import QPoint, QSize, Qt, QRect, QTimer+ from PyQt5.QtGui import (QIcon, QPainter)+ from PyQt5.QtWidgets import (QAbstractButton, QApplication, QComboBox,+ QDockWidget, QHBoxLayout, QLayout, QMainWindow,+ QPushButton, QStyle, QStyleOptionDockWidget,+ QStyleOptionToolButton, QStylePainter, QWidget)import dockwidget_icons@@ -23,14 +31,14 @@ class DockWidgetTitleBarButton(QAbstractButton):def __init__(self, titlebar):QAbstractButton.__init__(self, titlebar)- self.setFocusPolicy(Qt.NoFocus)+ self.setFocusPolicy(Qt.FocusPolicy.NoFocus)def sizeHint(self):self.ensurePolished()- margin = self.style().pixelMetric(QStyle.PM_DockWidgetTitleBarButtonMargin, None, self)+ margin = self.style().pixelMetric(QStyle.PixelMetric.PM_DockWidgetTitleBarButtonMargin, None, self)if self.icon().isNull():return QSize(margin, margin)- iconSize = self.style().pixelMetric(QStyle.PM_SmallIconSize, None, self)+ iconSize = self.style().pixelMetric(QStyle.PixelMetric.PM_SmallIconSize, None, self)pm = self.icon().pixmap(iconSize)return QSize(pm.width() + margin, pm.height() + margin)@@ -49,28 +57,28 @@ class DockWidgetTitleBarButton(QAbstractButton):r = self.rect()opt = QStyleOptionToolButton()opt.init(self)- opt.state |= QStyle.State_AutoRaise+ opt.state |= QStyle.StateFlag.State_AutoRaiseif self.isEnabled() and self.underMouse() and \not self.isChecked() and not self.isDown():- opt.state |= QStyle.State_Raised+ opt.state |= QStyle.StateFlag.State_Raisedif self.isChecked():- opt.state |= QStyle.State_On+ opt.state |= QStyle.StateFlag.State_Onif self.isDown():- opt.state |= QStyle.State_Sunken+ opt.state |= QStyle.StateFlag.State_Sunkenself.style().drawPrimitive(- QStyle.PE_PanelButtonTool, opt, p, self)+ QStyle.PrimitiveElement.PE_PanelButtonTool, opt, p, self)opt.icon = self.icon()opt.subControls = QStyle.SubControls()opt.activeSubControls = QStyle.SubControls()- opt.features = QStyleOptionToolButton.None- opt.arrowType = Qt.NoArrow- size = self.style().pixelMetric(QStyle.PM_SmallIconSize, None, self)+ opt.features = QStyleOptionToolButton.ToolButtonFeature.None_+ opt.arrowType = Qt.ArrowType.NoArrow+ size = self.style().pixelMetric(QStyle.PixelMetric.PM_SmallIconSize, None, self)opt.iconSize = QSize(size, size)- self.style().drawComplexControl(QStyle.CC_ToolButton, opt, p, self)+ self.style().drawComplexControl(QStyle.ComplexControl.CC_ToolButton, opt, p, self)class DockWidgetTitleBar(QWidget):- # XXX: support QDockWidget.DockWidgetVerticalTitleBar feature+ # XXX: support QDockWidget.DockWidgetFeature.DockWidgetVerticalTitleBar featuredef __init__(self, dockWidget):QWidget.__init__(self, dockWidget)@@ -80,12 +88,12 @@ class DockWidgetTitleBar(QWidget):q = dockWidgetself.floatButton = DockWidgetTitleBarButton(self)self.floatButton.setIcon(q.style().standardIcon(- QStyle.SP_TitleBarNormalButton, None, q))+ QStyle.StandardPixmap.SP_TitleBarNormalButton, None, q))self.floatButton.clicked.connect(self.toggleFloating)self.floatButton.setVisible(True)self.closeButton = DockWidgetTitleBarButton(self)self.closeButton.setIcon(q.style().standardIcon(- QStyle.SP_TitleBarCloseButton, None, q))+ QStyle.StandardPixmap.SP_TitleBarCloseButton, None, q))self.closeButton.clicked.connect(dockWidget.close)self.closeButton.setVisible(True)self.collapseButton = DockWidgetTitleBarButton(self)@@ -106,8 +114,8 @@ class DockWidgetTitleBar(QWidget):def sizeHint(self):q = self.parentWidget()- mw = q.style().pixelMetric(QStyle.PM_DockWidgetTitleMargin, None, q)- fw = q.style().pixelMetric(QStyle.PM_DockWidgetFrameWidth, None, q)+ mw = q.style().pixelMetric(QStyle.PixelMetric.PM_DockWidgetTitleMargin, None, q)+ fw = q.style().pixelMetric(QStyle.PixelMetric.PM_DockWidgetFrameWidth, None, q)closeSize = QSize(0, 0)if self.closeButton:closeSize = self.closeButton.sizeHint()@@ -127,14 +135,14 @@ class DockWidgetTitleBar(QWidget):fontHeight = titleFontMetrics.lineSpacing() + 2 * mwheight = max(buttonHeight, fontHeight)width = buttonWidth + height + 4 * mw + 2 * fw- if hasFeature(q, QDockWidget.DockWidgetVerticalTitleBar):+ if hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetVerticalTitleBar):width, height = height, widthreturn QSize(width, height)def paintEvent(self, event):p = QStylePainter(self)q = self.parentWidget()- if hasFeature(q, QDockWidget.DockWidgetVerticalTitleBar):+ if hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetVerticalTitleBar):fw = 1 or q.isFloating() and q.style().pixelMetric(QStyle.PM_DockWidgetFrameWidth, None, q) or 0mw = q.style().pixelMetric(QStyle.PM_DockWidgetTitleMargin, None, q)@@ -149,13 +157,13 @@ class DockWidgetTitleBar(QWidget):self.geometry().height() - (fw * 2) -mw - self.collapseButton.size().height() - self.pinButton.size().height()))titleOpt.title = q.windowTitle()- titleOpt.closable = hasFeature(q, QDockWidget.DockWidgetClosable)- titleOpt.floatable = hasFeature(q, QDockWidget.DockWidgetFloatable)+ titleOpt.closable = hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetClosable)+ titleOpt.floatable = hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetFloatable)p.drawControl(QStyle.CE_DockWidgetTitle, titleOpt)else:fw = q.isFloating() and q.style().pixelMetric(QStyle.PM_DockWidgetFrameWidth, None, q) or 0- mw = q.style().pixelMetric(QStyle.PM_DockWidgetTitleMargin, None, q)+ mw = q.style().pixelMetric(QStyle.PixelMetric.PM_DockWidgetTitleMargin, None, q)titleOpt = QStyleOptionDockWidget()titleOpt.initFrom(q)titleOpt.rect = QRect(@@ -166,15 +174,15 @@ class DockWidgetTitleBar(QWidget):mw - self.collapseButton.size().width() - self.pinButton.size().width(),self.geometry().height() - (fw * 2)))titleOpt.title = q.windowTitle()- titleOpt.closable = hasFeature(q, QDockWidget.DockWidgetClosable)- titleOpt.floatable = hasFeature(q, QDockWidget.DockWidgetFloatable)- p.drawControl(QStyle.CE_DockWidgetTitle, titleOpt)+ titleOpt.closable = hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetClosable)+ titleOpt.floatable = hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetFloatable)+ p.drawControl(QStyle.ControlElement.CE_DockWidgetTitle, titleOpt)def resizeEvent(self, event):q = self.parentWidget()- if hasFeature(q, QDockWidget.DockWidgetVerticalTitleBar):+ if hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetVerticalTitleBar):fh = q.isFloating() and q.style().pixelMetric(- QStyle.PM_DockWidgetFrameWidth, None, q) or 0+ QStyle.PixelMetric.PM_DockWidgetFrameWidth, None, q) or 0opt = QStyleOptionDockWidget()opt.initFrom(q)opt.verticalTitleBar = True@@ -184,14 +192,14 @@ class DockWidgetTitleBar(QWidget):self.geometry().width() - (fh * 2),fh * 2))opt.title = q.windowTitle()- opt.closable = hasFeature(q, QDockWidget.DockWidgetClosable)- opt.floatable = hasFeature(q, QDockWidget.DockWidgetFloatable)+ opt.closable = hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetClosable)+ opt.floatable = hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetFloatable)floatRect = q.style().subElementRect(- QStyle.SE_DockWidgetFloatButton, opt, q)+ QStyle.SubElement.SubElement.SE_DockWidgetFloatButton, opt, q)if not floatRect.isNull():self.floatButton.setGeometry(floatRect)closeRect = q.style().subElementRect(- QStyle.SE_DockWidgetCloseButton, opt, q)+ QStyle.SubElement.SubElement.SE_DockWidgetCloseButton, opt, q)if not closeRect.isNull():self.closeButton.setGeometry(closeRect)top = fh@@ -210,7 +218,7 @@ class DockWidgetTitleBar(QWidget):self.pinButton.setGeometry(pinRect)else:fw = q.isFloating() and q.style().pixelMetric(- QStyle.PM_DockWidgetFrameWidth, None, q) or 0+ QStyle.PixelMetric.PixelMetric.PM_DockWidgetFrameWidth, None, q) or 0opt = QStyleOptionDockWidget()opt.initFrom(q)opt.rect = QRect(@@ -219,14 +227,14 @@ class DockWidgetTitleBar(QWidget):self.geometry().width() - (fw * 2),self.geometry().height() - (fw * 2)))opt.title = q.windowTitle()- opt.closable = hasFeature(q, QDockWidget.DockWidgetClosable)- opt.floatable = hasFeature(q, QDockWidget.DockWidgetFloatable)+ opt.closable = hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetFeature.DockWidgetClosable)+ opt.floatable = hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetFeature.DockWidgetFloatable)floatRect = q.style().subElementRect(- QStyle.SE_DockWidgetFloatButton, opt, q)+ QStyle.SubElement.SE_DockWidgetFloatButton, opt, q)if not floatRect.isNull():self.floatButton.setGeometry(floatRect)closeRect = q.style().subElementRect(- QStyle.SE_DockWidgetCloseButton, opt, q)+ QStyle.SubElement.SE_DockWidgetCloseButton, opt, q)if not closeRect.isNull():self.closeButton.setGeometry(closeRect)top = fw@@ -268,8 +276,8 @@ class DockWidgetTitleBar(QWidget):def featuresChanged(self, features):q = self.parentWidget()- self.closeButton.setVisible(hasFeature(q, QDockWidget.DockWidgetClosable))- self.floatButton.setVisible(hasFeature(q, QDockWidget.DockWidgetFloatable))+ self.closeButton.setVisible(hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetClosable))+ self.floatButton.setVisible(hasFeature(q, QDockWidget.DockWidgetFeature.DockWidgetFloatable))# self.resizeEvent(None)@@ -296,7 +304,7 @@ class DockMainWidgetWrapper(QWidget):self.old_size = self.size()self.layout().removeWidget(self.widget)self.widget.hide()- if hasFeature(self.parent(), QDockWidget.DockWidgetVerticalTitleBar):+ if hasFeature(self.parent(), QDockWidget.DockWidgetFeature.DockWidgetVerticalTitleBar):self.parent().setMaximumWidth(self.parent().width() - self.width())else:self.parent().setMaximumHeight(self.parent().height() - self.height())@@ -374,17 +382,17 @@ if __name__ == "__main__":app.setStyle("qtcurve")win = QMainWindow()dock1 = DockWidget("1st dockwidget", win)- dock1.setFeatures(dock1.features() | QDockWidget.DockWidgetVerticalTitleBar)+ dock1.setFeatures(dock1.features() | QDockWidget.DockWidgetFeature.DockWidgetVerticalTitleBar)combo = QComboBox(dock1)dock1.setWidget(combo)- win.addDockWidget(Qt.LeftDockWidgetArea, dock1)+ win.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, dock1)dock2 = DockWidget("2nd dockwidget")- dock2.setFeatures(dock1.features() | QDockWidget.DockWidgetVerticalTitleBar)+ dock2.setFeatures(dock1.features() | QDockWidget.DockWidgetFeature.DockWidgetVerticalTitleBar)button = QPushButton("Hello, world!", dock2)dock2.setWidget(button)- win.addDockWidget(Qt.RightDockWidgetArea, dock2)+ win.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, dock2)edit = QTextEdit(win)win.setCentralWidget(edit)win.resize(640, 480)win.show()- app.exec_()+ app.exec()diff --git a/plugins/extensions/pykrita/plugin/krita/sceditor/dockwidget_icons.py b/plugins/extensions/pykrita/plugin/krita/sceditor/dockwidget_icons.pyindex 9da7eb289a..b48adf1e21 100644--- a/plugins/extensions/pykrita/plugin/krita/sceditor/dockwidget_icons.py+++ b/plugins/extensions/pykrita/plugin/krita/sceditor/dockwidget_icons.py@@ -7,7 +7,10 @@## WARNING! All changes made in this file will be lost!-from PyQt5 import QtCore+try:+ from PyQt6 import QtCore+except:+ from PyQt5 import QtCoreqt_resource_data = "\\x00\x00\x02\x0d\diff --git a/plugins/extensions/pykrita/plugin/krita/sceditor/highlighter.py b/plugins/extensions/pykrita/plugin/krita/sceditor/highlighter.pyindex 0af9693889..38ee25f202 100644--- a/plugins/extensions/pykrita/plugin/krita/sceditor/highlighter.py+++ b/plugins/extensions/pykrita/plugin/krita/sceditor/highlighter.py@@ -9,7 +9,10 @@ SPDX-FileCopyrightText: 2005-2006 Trolltech ASA. All rights reserved.SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5 import QtCore, QtGui+try:+ from PyQt6 import QtCore, QtGui+except:+ from PyQt5 import QtCore, QtGuiclass PythonHighlighter(QtGui.QSyntaxHighlighter):@@ -87,46 +90,46 @@ class PythonHighlighter(QtGui.QSyntaxHighlighter):# self.empty_format.setFontPointSize(font.pointSize()/4.0)self.keywordFormat = QtGui.QTextCharFormat(self.base_format)- self.keywordFormat.setForeground(QtCore.Qt.darkBlue)- self.keywordFormat.setFontWeight(QtGui.QFont.Bold)+ self.keywordFormat.setForeground(QtCore.Qt.GlobalColor.darkBlue)+ self.keywordFormat.setFontWeight(QtGui.QFont.Weight.Bold)self.callableFormat = QtGui.QTextCharFormat(self.base_format)- self.callableFormat.setForeground(QtCore.Qt.darkBlue)+ self.callableFormat.setForeground(QtCore.Qt.GlobalColor.darkBlue)self.magicFormat = QtGui.QTextCharFormat(self.base_format)self.magicFormat.setForeground(QtGui.QColor(224, 128, 0))self.qtFormat = QtGui.QTextCharFormat(self.base_format)- self.qtFormat.setForeground(QtCore.Qt.blue)- self.qtFormat.setFontWeight(QtGui.QFont.Bold)+ self.qtFormat.setForeground(QtCore.Qt.GlobalColor.blue)+ self.qtFormat.setFontWeight(QtGui.QFont.Weight.Bold)self.selfFormat = QtGui.QTextCharFormat(self.base_format)- self.selfFormat.setForeground(QtCore.Qt.red)+ self.selfFormat.setForeground(QtCore.Qt.GlobalColor.red)# self.selfFormat.setFontItalic(True)self.singleLineCommentFormat = QtGui.QTextCharFormat(self.base_format)- self.singleLineCommentFormat.setForeground(QtCore.Qt.darkGreen)+ self.singleLineCommentFormat.setForeground(QtCore.Qt.GlobalColor.darkGreen)self.multiLineStringFormat = QtGui.QTextCharFormat(self.base_format)self.multiLineStringFormat.setBackground(QtGui.QBrush(QtGui.QColor(127, 127, 255)))self.quotationFormat1 = QtGui.QTextCharFormat(self.base_format)- self.quotationFormat1.setForeground(QtCore.Qt.blue)+ self.quotationFormat1.setForeground(QtCore.Qt.GlobalColor.blue)self.quotationFormat2 = QtGui.QTextCharFormat(self.base_format)- self.quotationFormat2.setForeground(QtCore.Qt.blue)+ self.quotationFormat2.setForeground(QtCore.Qt.GlobalColor.blue)def updateRules(self):self.rules = []- self.rules += map(lambda s: (QtCore.QRegExp(r"\b" + s + r"\b"),+ self.rules += map(lambda s: (QtCore.QRegularExpression(r"\b" + s + r"\b"),self.keywordFormat), self.keywords)- self.rules.append((QtCore.QRegExp(r"\b[A-Za-z_]+\(.*\)"), self.callableFormat))- self.rules.append((QtCore.QRegExp(r"\b__[a-z]+__\b"), self.magicFormat))- self.rules.append((QtCore.QRegExp(r"\bself\b"), self.selfFormat))- self.rules.append((QtCore.QRegExp(r"\bQ([A-Z][a-z]*)+\b"), self.qtFormat))+ self.rules.append((QtCore.QRegularExpression(r"\b[A-Za-z_]+\(.*\)"), self.callableFormat))+ self.rules.append((QtCore.QRegularExpression(r"\b__[a-z]+__\b"), self.magicFormat))+ self.rules.append((QtCore.QRegularExpression(r"\bself\b"), self.selfFormat))+ self.rules.append((QtCore.QRegularExpression(r"\bQ([A-Z][a-z]*)+\b"), self.qtFormat))- self.rules.append((QtCore.QRegExp(r"#[^\n]*"), self.singleLineCommentFormat))+ self.rules.append((QtCore.QRegularExpression(r"#[^\n]*"), self.singleLineCommentFormat))- self.multiLineStringBegin = QtCore.QRegExp(r'\"\"\"')- self.multiLineStringEnd = QtCore.QRegExp(r'\"\"\"')+ self.multiLineStringBegin = QtCore.QRegularExpression(r'\"\"\"')+ self.multiLineStringEnd = QtCore.QRegularExpression(r'\"\"\"')- self.rules.append((QtCore.QRegExp(r'\"[^\n]*\"'), self.quotationFormat1))- self.rules.append((QtCore.QRegExp(r"'[^\n]*'"), self.quotationFormat2))+ self.rules.append((QtCore.QRegularExpression(r'\"[^\n]*\"'), self.quotationFormat1))+ self.rules.append((QtCore.QRegularExpression(r"'[^\n]*'"), self.quotationFormat2))def updateHighlighter(self, font):@@ -147,7 +150,7 @@ class QtQmlHighlighter(PythonHighlighter):'decodeURIComponent', 'encodeURI', 'encodeURIComponent','escape', 'unescape', 'version', 'gc', 'Object','Function', 'Number', 'Boolean', 'String', 'Date', 'Array',- 'RegExp', 'Error', 'EvalError', 'RangeError', 'ReferenceError',+ 'RegularExpression', 'Error', 'EvalError', 'RangeError', 'ReferenceError','SyntaxError', 'TypeError', 'URIError', 'eval', 'Math','Enumeration', 'Variant', 'QObject', 'QMetaObject']@@ -157,19 +160,19 @@ class QtQmlHighlighter(PythonHighlighter):def updateRules(self):self.rules = []- self.rules += map(lambda s: (QtCore.QRegExp(r"\b" + s + r"\b"),+ self.rules += map(lambda s: (QtCore.QRegularExpression(r"\b" + s + r"\b"),self.keywordFormat), self.keywords)- self.rules.append((QtCore.QRegExp(r"\b[A-Za-z_]+\(.*\)"), self.callableFormat))- # self.rules.append((QtCore.QRegExp(r"\b__[a-z]+__\b"), self.magicFormat))- self.rules.append((QtCore.QRegExp(r"\bthis\b"), self.selfFormat))- self.rules.append((QtCore.QRegExp(r"\bQ([A-Z][a-z]*)+\b"), self.qtFormat))+ self.rules.append((QtCore.QRegularExpression(r"\b[A-Za-z_]+\(.*\)"), self.callableFormat))+ # self.rules.append((QtCore.QRegularExpression(r"\b__[a-z]+__\b"), self.magicFormat))+ self.rules.append((QtCore.QRegularExpression(r"\bthis\b"), self.selfFormat))+ self.rules.append((QtCore.QRegularExpression(r"\bQ([A-Z][a-z]*)+\b"), self.qtFormat))- self.rules.append((QtCore.QRegExp(r"//[^\n]*"), self.singleLineCommentFormat))+ self.rules.append((QtCore.QRegularExpression(r"//[^\n]*"), self.singleLineCommentFormat))# XXX quick hack to support QtQml syntax- self.multiLineStringBegin = QtCore.QRegExp(r'/\*')- self.multiLineStringEnd = QtCore.QRegExp(r'\*/')+ self.multiLineStringBegin = QtCore.QRegularExpression(r'/\*')+ self.multiLineStringEnd = QtCore.QRegularExpression(r'\*/')self.multiLineStringFormat = self.singleLineCommentFormat- self.rules.append((QtCore.QRegExp(r'\"[^\n]*\"'), self.quotationFormat1))- self.rules.append((QtCore.QRegExp(r"'[^\n]*'"), self.quotationFormat2))+ self.rules.append((QtCore.QRegularExpression(r'\"[^\n]*\"'), self.quotationFormat1))+ self.rules.append((QtCore.QRegularExpression(r"'[^\n]*'"), self.quotationFormat2))diff --git a/plugins/extensions/pykrita/plugin/krita/sceditor/mainwindow.py b/plugins/extensions/pykrita/plugin/krita/sceditor/mainwindow.pyindex 4a16f5e24a..f4de8f053a 100644--- a/plugins/extensions/pykrita/plugin/krita/sceditor/mainwindow.py+++ b/plugins/extensions/pykrita/plugin/krita/sceditor/mainwindow.py@@ -2,10 +2,16 @@# SPDX-License-Identifier: GPL-3.0-or-later#-from PyQt5.QtCore import pyqtSlot, Qt-from PyQt5.QtGui import QCloseEvent-from PyQt5.QtWidgets import (QApplication, QFileDialog, QMainWindow,- QMessageBox, QSplitter, QTabWidget)+try:+ from PyQt6.QtCore import pyqtSlot, Qt+ from PyQt6.QtGui import QCloseEvent+ from PyQt6.QtWidgets import (QApplication, QFileDialog, QMainWindow,+ QMessageBox, QSplitter, QTabWidget)+except:+ from PyQt5.QtCore import pyqtSlot, Qt+ from PyQt5.QtGui import QCloseEvent+ from PyQt5.QtWidgets import (QApplication, QFileDialog, QMainWindow,+ QMessageBox, QSplitter, QTabWidget)from widget import PythonEditorWidget, QtQmlEditorWidget, SaveDialogfrom console import PythonConsole, QtQmlConsole@@ -29,7 +35,7 @@ class EditorMainWindow(QMainWindow):self.ui = Ui_ScriptEditor()self.ui.setupUi(self)# self.ui.actionExit.triggered.connect(self.exit)- self.splitter = QSplitter(Qt.Vertical, self)+ self.splitter = QSplitter(Qt.Orientation.Vertical, self)self.setCentralWidget(self.splitter)self.edit_tab = QTabWidget(self.splitter)self.console_tab = QTabWidget(self.splitter)@@ -47,14 +53,14 @@ class EditorMainWindow(QMainWindow):if edit:if(edit.isModified()):saveBox = SaveDialog("You have unsaved script. Save it now?")- prompt = saveBox.exec_()- if(prompt == QMessageBox.Save):+ prompt = saveBox.exec()+ if(prompt == QMessageBox.StandardButton.Save):event.ignore()self.save(True)- elif(prompt == QMessageBox.Cancel):+ elif(prompt == QMessageBox.StandardButton.Cancel):event.ignore()return- elif(prompt == QMessageBox.Discard):+ elif(prompt == QMessageBox.StandardButton.Discard):event.accept()i = self.edit_tab.indexOf(edit)self.edit_tab.removeTab(i)@@ -68,12 +74,12 @@ class EditorMainWindow(QMainWindow):if edit:if(edit.isModified()):saveBox = SaveDialog("You have unsaved script. Save it now?")- prompt = saveBox.exec_()- if(prompt == QMessageBox.Save):+ prompt = saveBox.exec()+ if(prompt == QMessageBox.StandardButton.Save):self.save(True)- elif(prompt == QMessageBox.Cancel):+ elif(prompt == QMessageBox.StandardButton.Cancel):return- elif(prompt == QMessageBox.Discard):+ elif(prompt == QMessageBox.StandardButton.Discard):passi = self.edit_tab.indexOf(edit)self.edit_tab.removeTab(i)@@ -107,12 +113,12 @@ class EditorMainWindow(QMainWindow):if edit:if(edit.isModified()):saveBox = SaveDialog("Do you want to save this Script?")- prompt = saveBox.exec_()- if(prompt == QMessageBox.Save):+ prompt = saveBox.exec()+ if(prompt == QMessageBox.StandardButton.Save):self.save(True)- elif(prompt == QMessageBox.Cancel):+ elif(prompt == QMessageBox.StandardButton.Cancel):return- elif(prompt == QMessageBox.Discard):+ elif(prompt == QMessageBox.StandardButton.Discard):passi = self.edit_tab.indexOf(edit)self.edit_tab.removeTab(i)@@ -208,4 +214,4 @@ if __name__ == "__main__":win = EditorMainWindow()win.resize(640, 480)win.show()- app.exec_()+ app.exec()diff --git a/plugins/extensions/pykrita/plugin/krita/sceditor/mainwindow_ui.py b/plugins/extensions/pykrita/plugin/krita/sceditor/mainwindow_ui.pyindex 1fff05218a..665aab14d4 100644--- a/plugins/extensions/pykrita/plugin/krita/sceditor/mainwindow_ui.py+++ b/plugins/extensions/pykrita/plugin/krita/sceditor/mainwindow_ui.py@@ -7,7 +7,10 @@## WARNING! All changes made in this file will be lost!-from PyQt5 import QtCore, QtGui, QtWidgets+try:+ from PyQt6 import QtCore, QtGui, QtWidgets+except:+ from PyQt5 import QtCore, QtGui, QtWidgetsclass Ui_ScriptEditor(object):diff --git a/plugins/extensions/pykrita/plugin/krita/sceditor/widget.py b/plugins/extensions/pykrita/plugin/krita/sceditor/widget.pyindex c68b7d49a0..a34a8cc723 100644--- a/plugins/extensions/pykrita/plugin/krita/sceditor/widget.py+++ b/plugins/extensions/pykrita/plugin/krita/sceditor/widget.py@@ -16,11 +16,18 @@ sys.path.insert(0, os.path.join(path, "rope.zip"))from rope.base.project import get_no_projectfrom rope.contrib.codeassist import code_assist-from PyQt5.QtCore import QCoreApplication, QLine, Qt-from PyQt5.QtGui import (QBrush, QColor, QFont, QKeyEvent, QTextBlockUserData,- QTextCursor, QPainter, QPalette, QPen)-from PyQt5.QtWidgets import (QApplication, QFrame, QHBoxLayout, QMessageBox,- QPlainTextEdit, QVBoxLayout, QWidget)+try:+ from PyQt6.QtCore import QCoreApplication, QLine, Qt+ from PyQt6.QtGui import (QBrush, QColor, QFont, QKeyEvent, QTextBlockUserData,+ QTextCursor, QPainter, QPalette, QPen)+ from PyQt6.QtWidgets import (QApplication, QFrame, QHBoxLayout, QMessageBox,+ QPlainTextEdit, QVBoxLayout, QWidget)+except:+ from PyQt5.QtCore import QCoreApplication, QLine, Qt+ from PyQt5.QtGui import (QBrush, QColor, QFont, QKeyEvent, QTextBlockUserData,+ QTextCursor, QPainter, QPalette, QPen)+ from PyQt5.QtWidgets import (QApplication, QFrame, QHBoxLayout, QMessageBox,+ QPlainTextEdit, QVBoxLayout, QWidget)from indenter import PythonCodeIndenterfrom assist import AutoComplete, CallTip@@ -66,7 +73,7 @@ class RopeEditorWrapper(object):block = self._get_block(line_no)cursor = QTextCursor(block)cursor.joinPreviousEditBlock()- cursor.movePosition(QTextCursor.StartOfBlock, QTextCursor.MoveAnchor)+ cursor.movePosition(QTextCursor.MoveOperation.StartOfBlock, QTextCursor.MoveMode.MoveAnchor)if indent_length < 0:for i in range(-indent_length):cursor.deleteChar()@@ -74,11 +81,11 @@ class RopeEditorWrapper(object):cursor.insertText(" " * indent_length)if indent_length:cursor.movePosition(- QTextCursor.StartOfBlock, QTextCursor.MoveAnchor)+ QTextCursor.MoveOperation.StartOfBlock, QTextCursor.MoveMode.MoveAnchor)line = unicode(cursor.block().text())if len(line) and line[0] == " ":cursor.movePosition(- QTextCursor.NextWord, QTextCursor.MoveAnchor)+ QTextCursor.MoveOperation.NextWord, QTextCursor.MoveMode.MoveAnchor)self.editview.setTextCursor(cursor)cursor.endEditBlock()@@ -89,9 +96,9 @@ class EditorView(QPlainTextEdit):EditorHighlighterClass=PythonHighlighter,indenter=PythonCodeIndenter):QPlainTextEdit.__init__(self, parent)- self.setFrameStyle(QFrame.NoFrame)+ self.setFrameStyle(QFrame.Shape.NoFrame)self.setTabStopWidth(4)- self.setLineWrapMode(QPlainTextEdit.NoWrap)+ self.setLineWrapMode(QPlainTextEdit.LineWrapMode.NoWrap)font = QFont()font.setFamily("lucidasanstypewriter")font.setFixedPitch(True)@@ -102,7 +109,7 @@ class EditorView(QPlainTextEdit):self.setPlainText(text)self.frame_style = self.frameStyle()self.draw_line = True- self.print_width = self.fontMetrics().width("x" * 78)+ self.print_width = self.fontMetrics().horizontalAdvance("x" * 78)self.line_pen = QPen(QColor("lightgrey"))self.last_row = self.last_col = -1self.last_block = None@@ -158,19 +165,19 @@ class EditorView(QPlainTextEdit):block = block.next()cursor.setPosition(last_block.position())cursor.movePosition(- QTextCursor.EndOfBlock, QTextCursor.MoveAnchor)+ QTextCursor.MoveOperation.EndOfBlock, QTextCursor.MoveMode.MoveAnchor)self.setTextCursor(cursor)def move_start_of_row(self):cursor = self.textCursor()cursor.movePosition(- QTextCursor.StartOfBlock, QTextCursor.MoveAnchor)+ QTextCursor.MoveOperation.StartOfBlock, QTextCursor.MoveMode.MoveAnchor)self.setTextCursor(cursor)def move_end_of_row(self):cursor = self.textCursor()cursor.movePosition(- QTextCursor.EndOfBlock, QTextCursor.MoveAnchor)+ QTextCursor.MoveOperation.EndOfBlock, QTextCursor.MoveMode.MoveAnchor)self.setTextCursor(cursor)def highline(self, cursor):@@ -260,41 +267,41 @@ class EditorView(QPlainTextEdit):t = event.text()# Disable some shortcutsif self.disable_shortcuts and \- m & Qt.ControlModifier and k in [Qt.Key_A, Qt.Key_R,- Qt.Key_C, Qt.Key_K,- Qt.Key_X, Qt.Key_V,- Qt.Key_Y, Qt.Key_Z]:+ m & Qt.KeyboardModifier.ControlModifier and k in [Qt.Key.Key_A, Qt.Key.Key_R,+ Qt.Key.Key_C, Qt.Key.Key_K,+ Qt.Key.Key_X, Qt.Key.Key_V,+ Qt.Key.Key_Y, Qt.Key.Key_Z]:new_ev = QKeyEvent(event.type(), k, m, t)event.ignore()QCoreApplication.postEvent(self.parent(), new_ev)return- elif k == Qt.Key_Tab:+ elif k == Qt.Key.Key_Tab:if self.tab_pressed():return- elif k == Qt.Key_Backtab:+ elif k == Qt.Key.Key_Backtab:if self.backtab_pressed():return- elif k == Qt.Key_Backspace:+ elif k == Qt.Key.Key_Backspace:if self.backspace_pressed():return- elif k == Qt.Key_Period or \- (k == Qt.Key_Space and event.modifiers() == Qt.ControlModifier):+ elif k == Qt.Key.Key_Period or \+ (k == Qt.Key.Key_Space and event.modifiers() == Qt.KeyboardModifier.ControlModifier):QPlainTextEdit.keyPressEvent(self, event)self.autocomplete_pressed()return- elif k in [Qt.Key_ParenLeft, Qt.Key_BraceLeft, Qt.Key_BracketLeft]:+ elif k in [Qt.Key.Key_ParenLeft, Qt.Key.Key_BraceLeft, Qt.Key.Key_BracketLeft]:QPlainTextEdit.keyPressEvent(self, event)self.paren_opened(k)returnQPlainTextEdit.keyPressEvent(self, event)- if k == Qt.Key_Return or k == Qt.Key_Enter:+ if k == Qt.Key.Key_Return or k == Qt.Key.Key_Enter:self.after_return_pressed()def paren_opened(self, key):close_char = {- Qt.Key_ParenLeft: ")",- Qt.Key_BraceLeft: " }",- Qt.Key_BracketLeft: "]"+ Qt.Key.Key_ParenLeft: ")",+ Qt.Key.Key_BraceLeft: " }",+ Qt.Key.Key_BracketLeft: "]"}cursor = self.textCursor()cursor.insertText(close_char[key])@@ -317,7 +324,7 @@ class EditorSidebar(QWidget):# pal = QPalette()# pal.setColor(self.backgroundRole(), bg)# self.setPalette(pal)- self.setBackgroundRole(QPalette.Base)+ self.setBackgroundRole(QPalette.ColorRole.Base)self.doc().documentLayout().update.connect(self.update)self.view.verticalScrollBar().valueChanged.connect(self.update)@@ -361,7 +368,7 @@ class EditorWidget(QFrame):QFrame.__init__(self, parent)self.view = EditorViewClass(self, text)self.sidebar = EditorSidebarClass(self)- self.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)+ self.setFrameStyle(QFrame.Shape.StyledPanel | QFrame.Shadow.Sunken)self.setLineWidth(2)self.vlayout = QVBoxLayout()self.vlayout.setSpacing(0)@@ -403,8 +410,8 @@ class SaveDialog(QMessageBox):QMessageBox.__init__(self)self.setWindowTitle("Save")self.setText(msg)- self.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)- self.setDefaultButton(QMessageBox.Save)+ self.setStandardButtons(QMessageBox.StandardButton.Save | QMessageBox.StandardButton.Discard | QMessageBox.StandardButton.Cancel)+ self.setDefaultButton(QMessageBox.StandardButton.Save)if __name__ == "__main__":@@ -416,4 +423,4 @@ if __name__ == "__main__":edit = EditorWidget(text=src)edit.resize(640, 480)edit.show()- app.exec_()+ app.exec()diff --git a/plugins/python/assignprofiledialog/assignprofiledialog.py b/plugins/python/assignprofiledialog/assignprofiledialog.pyindex 194ff181af..7998cccfb6 100644--- a/plugins/python/assignprofiledialog/assignprofiledialog.py+++ b/plugins/python/assignprofiledialog/assignprofiledialog.py@@ -1,8 +1,13 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtCore import Qt-from PyQt5.QtWidgets import (QDialogButtonBox, QDialog,- QMessageBox, QComboBox, QVBoxLayout)+try:+ from PyQt6.QtCore import Qt+ from PyQt6.QtWidgets import (QDialogButtonBox, QDialog,+ QMessageBox, QComboBox, QVBoxLayout)+except:+ from PyQt5.QtCore import Qt+ from PyQt5.QtWidgets import (QDialogButtonBox, QDialog,+ QMessageBox, QComboBox, QVBoxLayout)from krita import Extension@@ -30,16 +35,16 @@ class AssignProfileDialog(Extension):vbox = QVBoxLayout(self.dialog)vbox.addWidget(self.cmbProfile)self.buttonBox = QDialogButtonBox(self.dialog)- self.buttonBox.setOrientation(Qt.Horizontal)+ self.buttonBox.setOrientation(Qt.Orientation.Horizontal)self.buttonBox.setStandardButtons(- QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)self.buttonBox.accepted.connect(self.dialog.accept)self.buttonBox.accepted.connect(self.accept)self.buttonBox.rejected.connect(self.dialog.reject)vbox.addWidget(self.buttonBox)self.dialog.show()self.dialog.activateWindow()- self.dialog.exec_()+ self.dialog.exec()def accept(self):doc = Application.activeDocument()diff --git a/plugins/python/batch_exporter/Infrastructure.py b/plugins/python/batch_exporter/Infrastructure.pyindex 73968fb5d9..9ac6a91805 100644--- a/plugins/python/batch_exporter/Infrastructure.py+++ b/plugins/python/batch_exporter/Infrastructure.py@@ -9,8 +9,12 @@ from itertools import groupby, product, starmap, teefrom pathlib import Pathfrom krita import Krita-from PyQt5.QtCore import QSize, Qt-from PyQt5.QtGui import QColor, QImage, QPainter+try:+ from PyQt6.QtCore import QSize, Qt+ from PyQt6.QtGui import QColor, QImage, QPainter+except:+ from PyQt5.QtCore import QSize, Qt+ from PyQt5.QtGui import QColor, QImage, QPainterfrom .Utils import flip, kickstartfrom .Utils.Export import exportPath, sanitize@@ -40,7 +44,7 @@ def nodeToImage(wnode):temp_node.setColorSpace("RGBA", "U8", SRGB_PROFILE)pixel_data = temp_node.projectionPixelData(x, y, w, h).data()- return QImage(pixel_data, w, h, QImage.Format_ARGB32)+ return QImage(pixel_data, w, h, QImage.Format.Format_ARGB32)def expandAndFormat(img, margin=0, is_jpg=False):@@ -53,7 +57,7 @@ def expandAndFormat(img, margin=0, is_jpg=False):corner = QSize(margin, margin)white = QColor(255, 255, 255) if is_jpg else QColor(255, 255, 255, 0)canvas = QImage(- img.size() + corner * 2, QImage.Format_RGB32 if is_jpg else QImage.Format_ARGB32+ img.size() + corner * 2, QImage.Format.Format_RGB32 if is_jpg else QImage.Format.Format_ARGB32)canvas.fill(white)p = QPainter(canvas)@@ -326,7 +330,7 @@ class WNode:lambda scale, margin, extension, path: ([int(1e-2 * wh * scale) for wh in self.size],100 - scale != 0,- Qt.SmoothTransformation if bilinear else Qt.FastTransformation,+ Qt.TransformationMode.SmoothTransformation if bilinear else Qt.TransformationMode.FastTransformation,margin,extension,path,@@ -385,7 +389,7 @@ class WNode:image_width, image_height = self.size # Target frame sizesheet_width, sheet_height = (image_width, image_height * tiles_y) # Sheet dimensions- sheet = QImage(sheet_width, sheet_height, QImage.Format_ARGB32)+ sheet = QImage(sheet_width, sheet_height, QImage.Format.Format_ARGB32)sheet.fill(QColor(255, 255, 255, 0))painter = QPainter(sheet)diff --git a/plugins/python/batch_exporter/batch_exporter.py b/plugins/python/batch_exporter/batch_exporter.pyindex 24cf59110d..5d3f02d54d 100644--- a/plugins/python/batch_exporter/batch_exporter.py+++ b/plugins/python/batch_exporter/batch_exporter.py@@ -9,16 +9,28 @@ SPDX-License-Identifier: GPL-3.0-onlyfrom functools import partialfrom krita import DockWidget, DockWidgetFactory, DockWidgetFactoryBase, Krita-from PyQt5.QtWidgets import (- QPushButton,- QStatusBar,- QLabel,- QLineEdit,- QHBoxLayout,- QVBoxLayout,- QGroupBox,- QWidget,-)+try:+ from PyQt6.QtWidgets import (+ QPushButton,+ QStatusBar,+ QLabel,+ QLineEdit,+ QHBoxLayout,+ QVBoxLayout,+ QGroupBox,+ QWidget,+ )+except:+ from PyQt5.QtWidgets import (+ QPushButton,+ QStatusBar,+ QLabel,+ QLineEdit,+ QHBoxLayout,+ QVBoxLayout,+ QGroupBox,+ QWidget,+ )import osfrom .Config import CONFIGfrom .Infrastructure import WNode@@ -190,6 +202,6 @@ class GameArtTools(DockWidget):def registerDocker():docker = DockWidgetFactory(- "pykrita_gdquest_art_tools", DockWidgetFactoryBase.DockRight, GameArtTools+ "pykrita_gdquest_art_tools", DockWidgetFactoryBase.DockPosition.DockRight, GameArtTools)KI.addDockWidgetFactory(docker)diff --git a/plugins/python/channels2layers/channels2layers.py b/plugins/python/channels2layers/channels2layers.pyindex 95bf3d9ac2..a4f68bd2ed 100644--- a/plugins/python/channels2layers/channels2layers.py+++ b/plugins/python/channels2layers/channels2layers.py@@ -20,36 +20,68 @@ from krita import (Node,Selection)-from PyQt5.Qt import *-from PyQt5 import QtCore-from PyQt5.QtCore import (- pyqtSlot,- QBuffer,- QByteArray,- QIODevice- )-from PyQt5.QtGui import (- QColor,- QImage,- QPixmap,- )-from PyQt5.QtWidgets import (- QApplication,- QCheckBox,- QComboBox,- QDialog,- QDialogButtonBox,- QFormLayout,- QGroupBox,- QHBoxLayout,- QLabel,- QLineEdit,- QMessageBox,- QProgressBar,- QProgressDialog,- QVBoxLayout,- QWidget- )+try:+ from PyQt6.QtCore import (+ pyqtSlot,+ QBuffer,+ QByteArray,+ QIODevice,+ Qt,+ QRect+ )+ from PyQt6.QtGui import (+ QColor,+ QImage,+ QPixmap,+ )+ from PyQt6.QtWidgets import (+ QApplication,+ QCheckBox,+ QComboBox,+ QDialog,+ QDialogButtonBox,+ QFormLayout,+ QGroupBox,+ QHBoxLayout,+ QLabel,+ QLineEdit,+ QMessageBox,+ QProgressBar,+ QProgressDialog,+ QVBoxLayout,+ QWidget+ )+except:+ from PyQt5.QtCore import (+ pyqtSlot,+ QBuffer,+ QByteArray,+ QIODevice,+ Qt,+ QRect+ )+ from PyQt5.QtGui import (+ QColor,+ QImage,+ QPixmap,+ )+ from PyQt5.QtWidgets import (+ QApplication,+ QCheckBox,+ QComboBox,+ QDialog,+ QDialogButtonBox,+ QFormLayout,+ QGroupBox,+ QHBoxLayout,+ QLabel,+ QLineEdit,+ QMessageBox,+ QProgressBar,+ QProgressDialog,+ QVBoxLayout,+ QWidget+ )PLUGIN_VERSION = '1.1.0'@@ -101,7 +133,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.blue)+ 'color' : QColor(Qt.GlobalColor.blue)}},{@@ -129,7 +161,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.green)+ 'color' : QColor(Qt.GlobalColor.green)}},{@@ -157,7 +189,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.red)+ 'color' : QColor(Qt.GlobalColor.red)}},{@@ -191,7 +223,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.yellow)+ 'color' : QColor(Qt.GlobalColor.yellow)}},{@@ -219,7 +251,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.magenta)+ 'color' : QColor(Qt.GlobalColor.magenta)}},{@@ -247,7 +279,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.cyan)+ 'color' : QColor(Qt.GlobalColor.cyan)}},{@@ -294,7 +326,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.yellow)+ 'color' : QColor(Qt.GlobalColor.yellow)}},{@@ -334,7 +366,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.magenta)+ 'color' : QColor(Qt.GlobalColor.magenta)}},{@@ -374,7 +406,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.cyan)+ 'color' : QColor(Qt.GlobalColor.cyan)}},{@@ -420,7 +452,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.blue)+ 'color' : QColor(Qt.GlobalColor.blue)}},{@@ -452,7 +484,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.green)+ 'color' : QColor(Qt.GlobalColor.green)}},{@@ -484,7 +516,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.red)+ 'color' : QColor(Qt.GlobalColor.red)}},{@@ -522,7 +554,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.yellow)+ 'color' : QColor(Qt.GlobalColor.yellow)}},{@@ -554,7 +586,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.magenta)+ 'color' : QColor(Qt.GlobalColor.magenta)}},{@@ -586,7 +618,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.cyan)+ 'color' : QColor(Qt.GlobalColor.cyan)}},{@@ -637,7 +669,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.yellow)+ 'color' : QColor(Qt.GlobalColor.yellow)}},{@@ -681,7 +713,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.magenta)+ 'color' : QColor(Qt.GlobalColor.magenta)}},{@@ -725,7 +757,7 @@ OUTPUT_MODE_NFO = {'action' : 'new','value' : {'type' : 'filllayer',- 'color' : QColor(Qt.cyan)+ 'color' : QColor(Qt.GlobalColor.cyan)}},{@@ -908,11 +940,11 @@ class ChannelsToLayers(Extension):projectionMode = Trueif projectionMode == True:- img = QImage(layerNode.projectionPixelData(srcRect.left(), srcRect.top(), srcRect.width(), srcRect.height()), srcRect.width(), srcRect.height(), QImage.Format_ARGB32)+ img = QImage(layerNode.projectionPixelData(srcRect.left(), srcRect.top(), srcRect.width(), srcRect.height()), srcRect.width(), srcRect.height(), QImage.Format.Format_ARGB32)else:- img = QImage(layerNode.pixelData(srcRect.left(), srcRect.top(), srcRect.width(), srcRect.height()), srcRect.width(), srcRect.height(), QImage.Format_ARGB32)+ img = QImage(layerNode.pixelData(srcRect.left(), srcRect.top(), srcRect.width(), srcRect.height()), srcRect.width(), srcRect.height(), QImage.Format.Format_ARGB32)- return img.scaled(rect.width(), rect.height(), Qt.IgnoreAspectRatio, Qt.SmoothTransformation)+ return img.scaled(rect.width(), rect.height(), Qt.AspectRatioMode.IgnoreAspectRatio, Qt.TransformationMode.SmoothTransformation)def openDialogOptions(self):@@ -1025,8 +1057,8 @@ class ChannelsToLayers(Extension):# main dialog box, OK/Cancel buttonsdbbxOkCancel = QDialogButtonBox(dlgMain)- dbbxOkCancel.setOrientation(QtCore.Qt.Horizontal)- dbbxOkCancel.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ dbbxOkCancel.setOrientation(Qt.Orientation.Horizontal)+ dbbxOkCancel.setStandardButtons(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)dbbxOkCancel.accepted.connect(dlgMain.accept)dbbxOkCancel.rejected.connect(dlgMain.reject)vbxMainContainer.addWidget(dbbxOkCancel)@@ -1174,7 +1206,7 @@ class ChannelsToLayers(Extension):buildPreview()- returned = dlgMain.exec_()+ returned = dlgMain.exec()return returneddiff --git a/plugins/python/colorspace/colorspacedialog.py b/plugins/python/colorspace/colorspacedialog.pyindex fda3483790..e0c1fcfb33 100644--- a/plugins/python/colorspace/colorspacedialog.py+++ b/plugins/python/colorspace/colorspacedialog.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QDialog+try:+ from PyQt6.QtWidgets import QDialog+except:+ from PyQt5.QtWidgets import QDialogclass ColorSpaceDialog(QDialog):diff --git a/plugins/python/colorspace/components/colordepthcombobox.py b/plugins/python/colorspace/components/colordepthcombobox.pyindex b80de45290..995122f08e 100644--- a/plugins/python/colorspace/components/colordepthcombobox.py+++ b/plugins/python/colorspace/components/colordepthcombobox.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QComboBox+try:+ from PyQt6.QtWidgets import QComboBox+except:+ from PyQt5.QtWidgets import QComboBoxclass ColorDepthComboBox(QComboBox):diff --git a/plugins/python/colorspace/components/colormodelcombobox.py b/plugins/python/colorspace/components/colormodelcombobox.pyindex dfe660db01..201159abea 100644--- a/plugins/python/colorspace/components/colormodelcombobox.py+++ b/plugins/python/colorspace/components/colormodelcombobox.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QComboBox+try:+ from PyQt6.QtWidgets import QComboBox+except:+ from PyQt5.QtWidgets import QComboBoxclass ColorModelComboBox(QComboBox):diff --git a/plugins/python/colorspace/components/colorprofilecombobox.py b/plugins/python/colorspace/components/colorprofilecombobox.pyindex 1eca418fe7..28a0509a17 100644--- a/plugins/python/colorspace/components/colorprofilecombobox.py+++ b/plugins/python/colorspace/components/colorprofilecombobox.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QComboBox+try:+ from PyQt6.QtWidgets import QComboBox+except:+ from PyQt5.QtWidgets import QComboBoxclass ColorProfileComboBox(QComboBox):@@ -9,4 +12,4 @@ class ColorProfileComboBox(QComboBox):super(ColorProfileComboBox, self).__init__(parent)self.uiColorSpace = uiColorSpace- self.setSizeAdjustPolicy(self.AdjustToContents)+ self.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)diff --git a/plugins/python/colorspace/resources_rc.py b/plugins/python/colorspace/resources_rc.pyindex 9c74527c16..d94f4b43c7 100644--- a/plugins/python/colorspace/resources_rc.py+++ b/plugins/python/colorspace/resources_rc.py@@ -6,7 +6,10 @@## WARNING! All changes made in this file will be lost!-from PyQt5 import QtCore+try:+ from PyQt6 import QtCore+except:+ from PyQt5 import QtCoreqt_resource_data = b"\\x00\x00\x02\x24\diff --git a/plugins/python/colorspace/uicolorspace.py b/plugins/python/colorspace/uicolorspace.pyindex 98505b0613..f16793cdb2 100644--- a/plugins/python/colorspace/uicolorspace.py+++ b/plugins/python/colorspace/uicolorspace.py@@ -6,12 +6,20 @@ from .components import (colormodelcombobox,colorprofilecombobox,)-from PyQt5.QtCore import Qt-from PyQt5.QtWidgets import (QFormLayout, QListWidget,- QAbstractItemView, QDialogButtonBox,- QVBoxLayout, QFrame, QMessageBox, QPushButton,- QAbstractScrollArea)-from PyQt5.QtGui import QIcon+try:+ from PyQt6.QtCore import Qt+ from PyQt6.QtWidgets import (QFormLayout, QListWidget,+ QAbstractItemView, QDialogButtonBox,+ QVBoxLayout, QFrame, QMessageBox, QPushButton,+ QAbstractScrollArea)+ from PyQt6.QtGui import QIcon+except:+ from PyQt5.QtCore import Qt+ from PyQt5.QtWidgets import (QFormLayout, QListWidget,+ QAbstractItemView, QDialogButtonBox,+ QVBoxLayout, QFrame, QMessageBox, QPushButton,+ QAbstractScrollArea)+ from PyQt5.QtGui import QIconimport krita@@ -30,7 +38,7 @@ class UIColorSpace(object):self.colorProfileComboBox = \colorprofilecombobox.ColorProfileComboBox(self)self.buttonBox = QDialogButtonBox(- QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)self.kritaInstance = krita.Krita.instance()self.documentsList = []@@ -42,10 +50,10 @@ class UIColorSpace(object):self.buttonBox.accepted.connect(self.confirmButton)self.buttonBox.rejected.connect(self.mainDialog.close)- self.mainDialog.setWindowModality(Qt.NonModal)- self.widgetDocuments.setSelectionMode(QAbstractItemView.MultiSelection)+ self.mainDialog.setWindowModality(Qt.WindowModality.NonModal)+ self.widgetDocuments.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection)self.widgetDocuments.setSizeAdjustPolicy(- QAbstractScrollArea.AdjustToContents)+ QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents)def initialize(self):self.loadDocuments()@@ -63,8 +71,8 @@ class UIColorSpace(object):self.colorProfileComboBox)self.line = QFrame()- self.line.setFrameShape(QFrame.HLine)- self.line.setFrameShadow(QFrame.Sunken)+ self.line.setFrameShape(QFrame.Shape.HLine)+ self.line.setFrameShadow(QFrame.Shadow.Sunken)self.mainLayout.addLayout(self.formLayout)self.mainLayout.addWidget(self.line)@@ -129,7 +137,7 @@ class UIColorSpace(object):i18n("The selected documents have been converted."))else:self.msgBox.setText(i18n("Select at least one document."))- self.msgBox.exec_()+ self.msgBox.exec()def convertColorSpace(self, documents):for document in documents:diff --git a/plugins/python/comics_project_management_tools/comics_export_dialog.py b/plugins/python/comics_project_management_tools/comics_export_dialog.pyindex 3ade96971d..7a629f7195 100644--- a/plugins/python/comics_project_management_tools/comics_export_dialog.py+++ b/plugins/python/comics_project_management_tools/comics_export_dialog.py@@ -11,9 +11,14 @@ A dialog for editing the exporter settings."""from enum import IntEnum-from PyQt5.QtGui import QStandardItem, QStandardItemModel, QColor, QFont, QIcon, QPixmap-from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QGroupBox, QFormLayout, QCheckBox, QComboBox, QSpinBox, QWidget, QVBoxLayout, QHBoxLayout, QTabWidget, QPushButton, QLineEdit, QLabel, QListView, QTableView, QFontComboBox, QSpacerItem, QColorDialog, QStyledItemDelegate-from PyQt5.QtCore import Qt, QUuid+try:+ from PyQt6.QtGui import QStandardItem, QStandardItemModel, QColor, QFont, QIcon, QPixmap+ from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QGroupBox, QFormLayout, QCheckBox, QComboBox, QSpinBox, QWidget, QVBoxLayout, QHBoxLayout, QTabWidget, QPushButton, QLineEdit, QLabel, QListView, QTableView, QFontComboBox, QSpacerItem, QColorDialog, QStyledItemDelegate+ from PyQt6.QtCore import Qt, QUuid+except:+ from PyQt5.QtGui import QStandardItem, QStandardItemModel, QColor, QFont, QIcon, QPixmap+ from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QGroupBox, QFormLayout, QCheckBox, QComboBox, QSpinBox, QWidget, QVBoxLayout, QHBoxLayout, QTabWidget, QPushButton, QLineEdit, QLabel, QListView, QTableView, QFontComboBox, QSpacerItem, QColorDialog, QStyledItemDelegate+ from PyQt5.QtCore import Qt, QUuidfrom krita import *"""@@ -142,10 +147,10 @@ class labelSelector(QComboBox):self.itemModel = QStandardItemModel()for color in lisOfColors:item = QStandardItem()- item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)- item.setCheckState(Qt.Unchecked)+ item.setFlags(Qt.ItemFlag.ItemIsUserCheckable | Qt.ItemFlag.ItemIsEnabled)+ item.setCheckState(Qt.CheckState.Unchecked)item.setText(" ")- item.setData(color, Qt.BackgroundColorRole)+ item.setData(color, Qt.ItemDataRole.BackgroundColorRole)self.itemModel.appendRow(item)self.setModel(self.itemModel)@@ -168,11 +173,11 @@ class labelSelector(QComboBox):Little Enum to keep track of where in the item we add styles."""class styleEnum(IntEnum):- FONT = Qt.UserRole + 1- FONTLIST = Qt.UserRole + 2- FONTGENERIC = Qt.UserRole + 3- BOLD = Qt.UserRole + 4- ITALIC = Qt.UserRole + 5+ FONT = Qt.ItemDataRole.UserRole + 1+ FONTLIST = Qt.ItemDataRole.UserRole + 2+ FONTGENERIC = Qt.ItemDataRole.UserRole + 3+ BOLD = Qt.ItemDataRole.UserRole + 4+ ITALIC = Qt.ItemDataRole.UserRole + 5"""A simple delegate to allows editing fonts with a QFontComboBox"""@@ -207,7 +212,7 @@ class comic_export_setting_dialog(QDialog):super().__init__()self.setLayout(QVBoxLayout())self.setWindowTitle(i18n("Export Settings"))- buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)buttons.accepted.connect(self.accept)buttons.rejected.connect(self.reject)@@ -525,7 +530,7 @@ class comic_export_setting_dialog(QDialog):"""def slot_change_regular_color(self):- if (self.regularColor.exec_() == QDialog.Accepted):+ if (self.regularColor.exec() == QDialog.DialogCode.Accepted):square = QPixmap(32, 32)square.fill(self.regularColor.currentColor())self.btn_acbfRegColor.setIcon(QIcon(square))@@ -534,7 +539,7 @@ class comic_export_setting_dialog(QDialog):"""def slot_change_inverted_color(self):- if (self.invertedColor.exec_() == QDialog.Accepted):+ if (self.invertedColor.exec() == QDialog.DialogCode.Accepted):square = QPixmap(32, 32)square.fill(self.invertedColor.currentColor())self.btn_acbfInvColor.setIcon(QIcon(square))@@ -634,9 +639,9 @@ class comic_export_setting_dialog(QDialog):style = QStandardItem(key.title())style.setCheckable(True)if key in styleDict.keys():- style.setCheckState(Qt.Checked)+ style.setCheckState(Qt.CheckState.Checked)else:- style.setCheckState(Qt.Unchecked)+ style.setCheckState(Qt.CheckState.Unchecked)fontOn = Falseif "font" in keyDict.keys() or "genericfont" in keyDict.keys():fontOn = True@@ -667,7 +672,7 @@ class comic_export_setting_dialog(QDialog):for key in self.acbfStylesList:style = QStandardItem(key.title())style.setCheckable(True)- style.setCheckState(Qt.Unchecked)+ style.setCheckState(Qt.CheckState.Unchecked)style.setData(False, role=styleEnum.FONT)style.setData(QFont().family(), role=styleEnum.FONTLIST)style.setData("sans-serif", role=styleEnum.FONTGENERIC)@@ -717,13 +722,13 @@ class comic_export_setting_dialog(QDialog):versionList = []for r in range(self.ACBFhistoryModel.rowCount()):index = self.ACBFhistoryModel.index(r, 0)- versionList.append(self.ACBFhistoryModel.data(index, Qt.DisplayRole))+ versionList.append(self.ACBFhistoryModel.data(index, Qt.ItemDisplayrole.DisplayRole))config["acbfHistory"] = versionListacbfStylesDict = {}for row in range(0, self.ACBFStylesModel.rowCount()):entry = self.ACBFStylesModel.item(row)- if entry.checkState() == Qt.Checked:+ if entry.checkState() == Qt.CheckState.Checked:key = entry.text().lower()style = {}if entry.data(role=styleEnum.FONT):diff --git a/plugins/python/comics_project_management_tools/comics_exporter.py b/plugins/python/comics_project_management_tools/comics_exporter.pyindex 6cb3f2a095..76ec4a5f90 100644--- a/plugins/python/comics_project_management_tools/comics_exporter.py+++ b/plugins/python/comics_project_management_tools/comics_exporter.py@@ -16,9 +16,14 @@ from xml.dom import minidomfrom xml.etree import ElementTree as ETimport typesimport re-from PyQt5.QtWidgets import QLabel, QProgressDialog, QMessageBox, qApp # For the progress dialog.-from PyQt5.QtCore import QElapsedTimer, QLocale, Qt, QRectF, QPointF-from PyQt5.QtGui import QImage, QTransform, QPainterPath, QFontMetrics, QFont+try:+ from PyQt6.QtWidgets import QLabel, QProgressDialog, QMessageBox, QApplication # For the progress dialog.+ from PyQt6.QtCore import QElapsedTimer, QLocale, Qt, QRectF, QPointF+ from PyQt6.QtGui import QImage, QTransform, QPainterPath, QFontMetrics, QFont+except:+ from PyQt5.QtWidgets import QLabel, QProgressDialog, QMessageBox, QApplication # For the progress dialog.+ from PyQt5.QtCore import QElapsedTimer, QLocale, Qt, QRectF, QPointF+ from PyQt5.QtGui import QImage, QTransform, QPainterPath, QFontMetrics, QFontfrom krita import *from . import exporters@@ -141,7 +146,7 @@ class comicsExporter():self.timer = QElapsedTimer()self.timer.start()self.progress.show()- qApp.processEvents()+ QApplication.instance().processEvents()export_success = self.save_out_pngs(sizesList)# Export acbf metadata.@@ -170,7 +175,7 @@ class comicsExporter():export_success = exporters.EPUB.export(self.configDictionary, self.projectURL, self.pagesLocationList["EPUB"], self.acbfPageData)print("CPMT: Exported to EPUB", export_success)else:- QMessageBox.warning(None, i18n("Export not Possible"), i18n("Nothing to export, URL not set."), QMessageBox.Ok)+ QMessageBox.warning(None, i18n("Export not Possible"), i18n("Nothing to export, URL not set."), QMessageBox.StandardButton.Ok)print("CPMT: Nothing to export, url not set.")return export_success@@ -204,7 +209,7 @@ class comicsExporter():# Check if there's export methods, and if so make sure the appropriate dictionaries are initialised.if len(sizesList.keys()) < 1:- QMessageBox.warning(None, i18n("Export not Possible"), i18n("Export failed because there's no export settings configured."), QMessageBox.Ok)+ QMessageBox.warning(None, i18n("Export not Possible"), i18n("Export failed because there's no export settings configured."), QMessageBox.StandardButton.Ok)print("CPMT: Export failed because there's no export methods set.")return Falseelse:@@ -236,7 +241,7 @@ class comicsExporter():estimatedString = str(u"\u221E")passedString = self.parseTime(timePassed)self.progress.setLabelText("\n".join([pagesDone, timeString(passedString, estimatedString), i18n("Opening next page")]))- qApp.processEvents()+ QApplication.instance().processEvents()# Get the appropriate url and open the page.url = str(Path(self.projectURL) / pagesList[p])page = Application.openDocument(url)@@ -310,7 +315,7 @@ class comicsExporter():croph = page.height() - self.configDictionary["cropBottom"] - cropyprojection.crop(int(cropx), int(cropy), int(cropw), int(croph))projection.waitForDone()- qApp.processEvents()+ QApplication.instance().processEvents()# resize appropriatelyelse:cropx = 0@@ -322,7 +327,7 @@ class comicsExporter():listScales = sizesCalc.get_scale_from_resize_config(config=w, listSizes=listScales)projection.scaleImage(listScales[0], listScales[1], listScales[2], listScales[3], "bicubic")projection.waitForDone()- qApp.processEvents()+ QApplication.instance().processEvents()# png, gif and other webformats should probably be in 8bit srgb at maximum.if key != "TIFF":if (projection.colorModel() != "RGBA" and projection.colorModel() != "GRAYA") or projection.colorDepth() != "U8":@@ -344,7 +349,7 @@ class comicsExporter():# find the pages and store them.projection.exportImage(fn, InfoObject())projection.waitForDone()- qApp.processEvents()+ QApplication.instance().processEvents()if key == "CBZ" or key == "EPUB":transform = {}transform["offsetX"] = cropx@@ -363,7 +368,7 @@ class comicsExporter():print("CPMT: Export has finished. If there are memory leaks, they are caused by file layers.")return Trueprint("CPMT: Export not happening because there aren't any pages.")- QMessageBox.warning(None, i18n("Export not Possible"), i18n("Export not happening because there are no pages."), QMessageBox.Ok)+ QMessageBox.warning(None, i18n("Export not Possible"), i18n("Export not happening because there are no pages."), QMessageBox.StandardButton.Ok)return False"""@@ -479,7 +484,7 @@ class comicsExporter():path.cubicTo(coordinates[0], coordinates[1], coordinates[2], coordinates[3], x, y)else:path.lineTo(QPointF(x, y) + offset)- path.setFillRule(Qt.WindingFill)+ path.setFillRule(Qt.FillRule.WindingFill)for polygon in path.simplified().toSubpathPolygons(adjust):for point in polygon:listOfPoints.append(point)@@ -541,7 +546,7 @@ class comicsExporter():string = el.toxml()string = re.sub(r"\<.*?\>", " ", string)string = string.replace(" ", " ")- width = min(QFontMetrics(font).width(string.strip()), rect.width())+ width = min(QFontMetrics(font).horizontalAdvance(string.strip()), rect.width())height = QFontMetrics(font).height()anchor = "start"if docElem.hasAttribute("text-anchor"):diff --git a/plugins/python/comics_project_management_tools/comics_metadata_dialog.py b/plugins/python/comics_project_management_tools/comics_metadata_dialog.pyindex 2d896386a7..6fe9b2b8cc 100644--- a/plugins/python/comics_project_management_tools/comics_metadata_dialog.py+++ b/plugins/python/comics_project_management_tools/comics_metadata_dialog.py@@ -15,9 +15,14 @@ import csvimport reimport typesfrom pathlib import Path # For reading all the files in a directory.-from PyQt5.QtGui import QStandardItem, QStandardItemModel, QImage, QIcon, QPixmap, QPainter, QPalette, QFontDatabase-from PyQt5.QtWidgets import QComboBox, QCompleter, QStyledItemDelegate, QLineEdit, QDialog, QDialogButtonBox, QVBoxLayout, QFormLayout, QTabWidget, QWidget, QPlainTextEdit, QHBoxLayout, QSpinBox, QDateEdit, QPushButton, QLabel, QTableView-from PyQt5.QtCore import QDir, QLocale, QStringListModel, Qt, QDate, QSize, QUuid+try:+ from PyQt6.QtGui import QStandardItem, QStandardItemModel, QImage, QIcon, QPixmap, QPainter, QPalette, QFontDatabase+ from PyQt6.QtWidgets import QComboBox, QCompleter, QStyledItemDelegate, QLineEdit, QDialog, QDialogButtonBox, QVBoxLayout, QFormLayout, QTabWidget, QWidget, QPlainTextEdit, QHBoxLayout, QSpinBox, QDateEdit, QPushButton, QLabel, QTableView+ from PyQt6.QtCore import QDir, QLocale, QStringListModel, Qt, QDate, QSize, QUuid+except:+ from PyQt5.QtGui import QStandardItem, QStandardItemModel, QImage, QIcon, QPixmap, QPainter, QPalette, QFontDatabase+ from PyQt5.QtWidgets import QComboBox, QCompleter, QStyledItemDelegate, QLineEdit, QDialog, QDialogButtonBox, QVBoxLayout, QFormLayout, QTabWidget, QWidget, QPlainTextEdit, QHBoxLayout, QSpinBox, QDateEdit, QPushButton, QLabel, QTableView+ from PyQt5.QtCore import QDir, QLocale, QStringListModel, Qt, QDate, QSize, QUuid"""multi entry completer cobbled together from the two examples on stackoverflow:3779720@@ -60,8 +65,8 @@ class language_combo_box(QComboBox):def __init__(self, parent=None):super(QComboBox, self).__init__(parent)- for locale in QLocale.matchingLocales(QLocale.AnyLanguage, QLocale.AnyScript, QLocale.AnyCountry):- if locale.language() == QLocale.C:+ for locale in QLocale.matchingLocales(QLocale.Language.AnyLanguage, QLocale.Script.AnyScript, QLocale.Country.AnyCountry):+ if locale.language() == QLocale.Language.C:continuecodeName = locale.name().split("_")[0]if codeName not in self.codesToDisplayNames:@@ -80,14 +85,14 @@ class language_combo_box(QComboBox):self.languageList.append(languageName)self.setIconSize(QSize(32, 22))- codeIcon = QImage(self.iconSize(), QImage.Format_ARGB32)+ codeIcon = QImage(self.iconSize(), QImage.Format.Format_ARGB32)painter = QPainter(codeIcon)- painter.setBrush(Qt.transparent)+ painter.setBrush(Qt.GlobalColor.transparent)codeIcon.fill(Qt.transparent)- font = QFontDatabase().systemFont(QFontDatabase.FixedFont)+ font = QFontDatabase().systemFont(QFontDatabase.SystemFont.FixedFont)painter.setFont(font)- painter.setPen(self.palette().color(QPalette.Text))- painter.drawText(codeIcon.rect(), Qt.AlignCenter,lang)+ painter.setPen(self.palette().color(QPalette.ColorRole.Text))+ painter.drawText(codeIcon.rect(), Qt.AlignmentFlag.AlignCenter,lang)painter.end()self.addItem(QIcon(QPixmap.fromImage(codeIcon)), languageName)@@ -112,7 +117,7 @@ class country_combo_box(QComboBox):self.clear()self.codesList = []self.countryList = []- for locale in QLocale.matchingLocales(languageLocale.language(), QLocale.AnyScript, QLocale.AnyCountry):+ for locale in QLocale.matchingLocales(languageLocale.language(), QLocale.Script.AnyScript, QLocale.Country.AnyCountry):codeName = locale.name().split("_")[-1]if codeName not in self.codesList:self.codesList.append(codeName)@@ -129,14 +134,14 @@ class country_combo_box(QComboBox):countryName = locale.nativeCountryName()self.countryList.append(countryName.title())self.setIconSize(QSize(32, 22))- codeIcon = QImage(self.iconSize(), QImage.Format_ARGB32)+ codeIcon = QImage(self.iconSize(), QImage.Format.Format_ARGB32)painter = QPainter(codeIcon)painter.setBrush(Qt.transparent)codeIcon.fill(Qt.transparent)- font = QFontDatabase().systemFont(QFontDatabase.FixedFont)+ font = QFontDatabase().systemFont(QFontDatabase.SystemFont.FixedFont)painter.setFont(font)- painter.setPen(self.palette().color(QPalette.Text))- painter.drawText(codeIcon.rect(), Qt.AlignCenter,country)+ painter.setPen(self.palette().color(QPalette.ColorRole.Text))+ painter.drawText(codeIcon.rect(), Qt.AlignmentFlag.AlignCenter,country)painter.end()self.addItem(QIcon(QPixmap.fromImage(codeIcon)), countryName.title())@@ -203,8 +208,8 @@ class author_delegate(QStyledItemDelegate):editor = QComboBox(parent)editor.addItem("")for i in range(2, 356):- if QLocale(i, QLocale.AnyScript, QLocale.AnyCountry) is not None:- languagecode = QLocale(i, QLocale.AnyScript, QLocale.AnyCountry).name().split("_")[0]+ if QLocale(i, QLocale.Script.AnyScript, QLocale.Country.AnyCountry) is not None:+ languagecode = QLocale(i, QLocale.Script.AnyScript, QLocale.Country.AnyCountry).name().split("_")[0]if languagecode != "C":editor.addItem(languagecode)editor.model().sort(0)@@ -253,7 +258,7 @@ class comic_meta_data_editor(QDialog):mainWidget = QTabWidget()self.layout().addWidget(mainWidget)self.setWindowTitle(i18n("Comic Metadata"))- buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)self.layout().addWidget(buttons)buttons.accepted.connect(self.accept)buttons.rejected.connect(self.reject)@@ -280,7 +285,7 @@ class comic_meta_data_editor(QDialog):characterCompletion = multi_entry_completer()characterCompletion.setModel(QStringListModel(self.characterKeysList))characterCompletion.setCaseSensitivity(False)- characterCompletion.setFilterMode(Qt.MatchContains) # So that if there is a list of names with last names, people can type in a last name.+ characterCompletion.setFilterMode(Qt.MatchFlag.MatchContains) # So that if there is a list of names with last names, people can type in a last name.self.lnCharacters.setCompleter(characterCompletion)self.lnCharacters.setToolTip(i18n("The names of the characters that this comic revolves around. Comma-separated."))@@ -314,7 +319,7 @@ class comic_meta_data_editor(QDialog):otherCompletion = multi_entry_completer()otherCompletion.setModel(QStringListModel(self.otherKeysList))otherCompletion.setCaseSensitivity(False)- otherCompletion.setFilterMode(Qt.MatchContains)+ otherCompletion.setFilterMode(Qt.MatchFlag.MatchContains)self.lnOtherKeywords = QLineEdit()self.lnOtherKeywords.setCompleter(otherCompletion)self.lnOtherKeywords.setToolTip(i18n("Other keywords that do not fit in the previously mentioned sets. As always, comma-separated."))@@ -394,7 +399,7 @@ class comic_meta_data_editor(QDialog):self.isbn = QLineEdit()self.license = license_combo_box() # Maybe ought to make this a QLineEdit...self.license.setEditable(True)- self.license.completer().setCompletionMode(QCompleter.PopupCompletion)+ self.license.completer().setCompletionMode(QCompleter.CompletionMode.PopupCompletion)dataBaseReference = QVBoxLayout()self.ln_database_name = QLineEdit()self.ln_database_name.setToolTip(i18n("If there is an entry in a comics data base, that should be added here. It is unlikely to be a factor for comics from scratch, but useful when doing a conversion."))@@ -619,9 +624,9 @@ class comic_meta_data_editor(QDialog):self.cmbLanguage.setEntryToCode(code)if "readingDirection" in config.keys():if config["readingDirection"] == "leftToRight":- self.cmbReadingMode.setCurrentIndex(int(Qt.LeftToRight))+ self.cmbReadingMode.setCurrentIndex(int(Qt.LayoutDirection.LeftToRight))else:- self.cmbReadingMode.setCurrentIndex(int(Qt.RightToLeft))+ self.cmbReadingMode.setCurrentIndex(int(Qt.LayoutDirection.RightToLeft))else:self.cmbReadingMode.setCurrentIndex(QLocale(self.cmbLanguage.codeForCurrentEntry()).textDirection())if "publisherName" in config.keys():@@ -629,7 +634,7 @@ class comic_meta_data_editor(QDialog):if "publisherCity" in config.keys():self.publishCity.setText(config["publisherCity"])if "publishingDate" in config.keys():- self.publishDate.setDate(QDate.fromString(config["publishingDate"], Qt.ISODate))+ self.publishDate.setDate(QDate.fromString(config["publishingDate"], Qt.DateFormat.ISODate))if "isbn-number" in config.keys():self.isbn.setText(config["isbn-number"])if "source" in config.keys():@@ -749,7 +754,7 @@ class comic_meta_data_editor(QDialog):if self.spnSeriesVol.value() > 0:config["seriesVolume"] = self.spnSeriesVol.value()config["language"] = str(self.cmbLanguage.codeForCurrentEntry()+"-"+self.cmbCountry.codeForCurrentEntry())- if self.cmbReadingMode.currentIndex() is int(Qt.LeftToRight):+ if self.cmbReadingMode.currentIndex() is int(Qt.LayoutDirection.LeftToRight):config["readingDirection"] = "leftToRight"else:config["readingDirection"] = "rightToLeft"@@ -774,7 +779,7 @@ class comic_meta_data_editor(QDialog):config["authorList"] = authorListconfig["publisherName"] = self.publisherName.text()config["publisherCity"] = self.publishCity.text()- config["publishingDate"] = self.publishDate.date().toString(Qt.ISODate)+ config["publishingDate"] = self.publishDate.date().toString(Qt.DateFormat.ISODate)config["isbn-number"] = self.isbn.text()config["source"] = self.ln_source.text()config["license"] = self.license.currentText()diff --git a/plugins/python/comics_project_management_tools/comics_project_manager_docker.py b/plugins/python/comics_project_management_tools/comics_project_manager_docker.pyindex 890ad737de..21244f09d0 100644--- a/plugins/python/comics_project_management_tools/comics_project_manager_docker.py+++ b/plugins/python/comics_project_management_tools/comics_project_manager_docker.py@@ -17,9 +17,15 @@ import shutilimport enumfrom math import floorimport xml.etree.ElementTree as ET-from PyQt5.QtCore import QElapsedTimer, QSize, Qt, QRect, QFileSystemWatcher, QTimer-from PyQt5.QtGui import QStandardItem, QStandardItemModel, QImage, QIcon, QPixmap, QFontMetrics, QPainter, QPalette, QFont-from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QListView, QToolButton, QMenu, QAction, QPushButton, QSpacerItem, QSizePolicy, QWidget, QAbstractItemView, QProgressDialog, QDialog, QFileDialog, QDialogButtonBox, qApp, QSplitter, QSlider, QLabel, QStyledItemDelegate, QStyle, QMessageBox+try:+ from PyQt6.QtCore import QElapsedTimer, QSize, Qt, QRect, QFileSystemWatcher, QTimer+ from PyQt6.QtGui import QStandardItem, QStandardItemModel, QImage, QIcon, QPixmap, QFontMetrics, QPainter, QPalette, QFont, QAction+ from PyQt6.QtWidgets import QHBoxLayout, QVBoxLayout, QListView, QToolButton, QMenu, QPushButton, QSpacerItem, QSizePolicy, QWidget, QAbstractItemView, QProgressDialog, QDialog, QFileDialog, QDialogButtonBox, QApplication, QSplitter, QSlider, QLabel, QStyledItemDelegate, QStyle, QMessageBox++except:+ from PyQt5.QtCore import QElapsedTimer, QSize, Qt, QRect, QFileSystemWatcher, QTimer+ from PyQt5.QtGui import QStandardItem, QStandardItemModel, QImage, QIcon, QPixmap, QFontMetrics, QPainter, QPalette, QFont+ from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QListView, QToolButton, QMenu, QAction, QPushButton, QSpacerItem, QSizePolicy, QWidget, QAbstractItemView, QProgressDialog, QDialog, QFileDialog, QDialogButtonBox, QApplication, QSplitter, QSlider, QLabel, QStyledItemDelegate, QStyle, QMessageBoximport mathfrom krita import *from . import comics_metadata_dialog, comics_exporter, comics_export_dialog, comics_project_setup_wizard, comics_template_dialog, comics_project_settings_dialog, comics_project_page_viewer, comics_project_translation_scraper@@ -36,27 +42,27 @@ class Elided_Text_Label(QLabel):def __init__(self, parent=None):super(QLabel, self).__init__(parent)- self.setMinimumWidth(self.fontMetrics().width("..."))- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)+ self.setMinimumWidth(self.fontMetrics().horizontalAdvance("..."))+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)def setMainText(self, text=str()):self.mainText = textself.elideText()def elideText(self):- self.setText(self.fontMetrics().elidedText(self.mainText, Qt.ElideRight, self.width()))+ self.setText(self.fontMetrics().elidedText(self.mainText, Qt.TextElideMode.ElideRight, self.width()))def resizeEvent(self, event):self.elideText()class CPE(enum.IntEnum):- TITLE = Qt.DisplayRole- URL = Qt.UserRole + 1- KEYWORDS = Qt.UserRole+2- DESCRIPTION = Qt.UserRole+3- LASTEDIT = Qt.UserRole+4- EDITOR = Qt.UserRole+5- IMAGE = Qt.DecorationRole+ TITLE = Qt.ItemDataRole.DisplayRole+ URL = Qt.ItemDataRole.UserRole + 1+ KEYWORDS = Qt.ItemDataRole.UserRole+2+ DESCRIPTION = Qt.ItemDataRole.UserRole+3+ LASTEDIT = Qt.ItemDataRole.UserRole+4+ EDITOR = Qt.ItemDataRole.UserRole+5+ IMAGE = Qt.ItemDataRole.DecorationRoleclass comic_page_delegate(QStyledItemDelegate):@@ -70,9 +76,9 @@ class comic_page_delegate(QStyledItemDelegate):returnpainter.save()painter.setOpacity(0.6)- if(option.state & QStyle.State_Selected):+ if(option.state & QStyle.StateFlag.State_Selected):painter.fillRect(option.rect, option.palette.highlight())- if (option.state & QStyle.State_MouseOver):+ if (option.state & QStyle.StateFlag.State_MouseOver):painter.setOpacity(0.25)painter.fillRect(option.rect, option.palette.highlight())painter.setOpacity(1.0)@@ -100,8 +106,8 @@ class comic_page_delegate(QStyledItemDelegate):if (decoratonSize.width()+(margin*2)< rect.width()):textRect = QRect(decoratonSize.width()+margin, margin+rect.top(), labelWidth, metrics.height())- textTitle = metrics.elidedText(str(index.row()+1)+". "+index.data(CPE.TITLE), Qt.ElideRight, labelWidth)- painter.drawText(textRect, Qt.TextWordWrap, textTitle)+ textTitle = metrics.elidedText(str(index.row()+1)+". "+index.data(CPE.TITLE), Qt.TextElideMode.ElideRight, labelWidth)+ painter.drawText(textRect, Qt.TextFlag.TextWordWrap, textTitle)if rect.height()/(metrics.lineSpacing()+margin) > 5 or index.data(CPE.KEYWORDS) is not None:painter.setOpacity(0.6)@@ -112,8 +118,8 @@ class comic_page_delegate(QStyledItemDelegate):textKeyWords = i18n("No keywords")painter.setOpacity(0.3)painter.setFont(italics)- textKeyWords = metrics.elidedText(textKeyWords, Qt.ElideRight, labelWidth)- painter.drawText(textRect, Qt.TextWordWrap, textKeyWords)+ textKeyWords = metrics.elidedText(textKeyWords, Qt.TextElideMode.ElideRight, labelWidth)+ painter.drawText(textRect, Qt.TextFlag.TextWordWrap, textKeyWords)painter.setFont(regular)@@ -129,8 +135,8 @@ class comic_page_delegate(QStyledItemDelegate):if (index.data(CPE.LASTEDIT) is None) and (index.data(CPE.EDITOR) is None):painter.setOpacity(0.3)painter.setFont(italics)- textLastEdit = metrics.elidedText(textLastEdit, Qt.ElideRight, labelWidth)- painter.drawText(textRect, Qt.TextWordWrap, textLastEdit)+ textLastEdit = metrics.elidedText(textLastEdit, Qt.TextElideFlag.ElideRight, labelWidth)+ painter.drawText(textRect, Qt.TextFlag.TextWordWrap, textLastEdit)painter.setFont(regular)@@ -148,26 +154,26 @@ class comic_page_delegate(QStyledItemDelegate):painter.setFont(italics)linesTotal = floor(descRect.height()/metrics.lineSpacing())if linesTotal == 1:- textDescription = metrics.elidedText(textDescription, Qt.ElideRight, labelWidth)- painter.drawText(descRect, Qt.TextWordWrap, textDescription)+ textDescription = metrics.elidedText(textDescription, Qt.TextElideFlag.ElideRight, labelWidth)+ painter.drawText(descRect, Qt.TextFlag.TextWordWrap, textDescription)else:descRect.setHeight(linesTotal*metrics.lineSpacing())- totalDescHeight = metrics.boundingRect(descRect, Qt.TextWordWrap, textDescription).height()+ totalDescHeight = metrics.boundingRect(descRect, Qt.TextFlag.TextWordWrap, textDescription).height()if totalDescHeight>descRect.height():if totalDescHeight-metrics.lineSpacing()>descRect.height():painter.setOpacity(0.5)- painter.drawText(descRect, Qt.TextWordWrap, textDescription)+ painter.drawText(descRect, Qt.TextFlag.TextWordWrap, textDescription)descRect.setHeight((linesTotal-1)*metrics.lineSpacing())- painter.drawText(descRect, Qt.TextWordWrap, textDescription)+ painter.drawText(descRect, Qt.TextFlag.TextWordWrap, textDescription)descRect.setHeight((linesTotal-2)*metrics.lineSpacing())- painter.drawText(descRect, Qt.TextWordWrap, textDescription)+ painter.drawText(descRect, Qt.TextFlag.TextWordWrap, textDescription)else:painter.setOpacity(0.75)- painter.drawText(descRect, Qt.TextWordWrap, textDescription)+ painter.drawText(descRect, Qt.TextFlag.TextWordWrap, textDescription)descRect.setHeight((linesTotal-1)*metrics.lineSpacing())- painter.drawText(descRect, Qt.TextWordWrap, textDescription)+ painter.drawText(descRect, Qt.TextFlag.TextWordWrap, textDescription)else:- painter.drawText(descRect, Qt.TextWordWrap, textDescription)+ painter.drawText(descRect, Qt.TextFlag.TextWordWrap, textDescription)painter.setFont(regular)@@ -212,10 +218,10 @@ class comics_project_manager_docker(DockWidget):# Comic page list and pages modelself.comicPageList = QListView()- self.comicPageList.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)+ self.comicPageList.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)self.comicPageList.setDragEnabled(True)- self.comicPageList.setDragDropMode(QAbstractItemView.InternalMove)- self.comicPageList.setDefaultDropAction(Qt.MoveAction)+ self.comicPageList.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)+ self.comicPageList.setDefaultDropAction(Qt.DropAction.MoveAction)self.comicPageList.setAcceptDrops(True)self.comicPageList.setItemDelegate(comic_page_delegate(self.devicePixelRatioF()))self.pagesModel = QStandardItemModel()@@ -229,7 +235,7 @@ class comics_project_manager_docker(DockWidget):self.comicPageList.setModel(self.pagesModel)pageBox = QWidget()pageBox.setLayout(QVBoxLayout())- zoomSlider = QSlider(Qt.Horizontal, None)+ zoomSlider = QSlider(Qt.Orientation.Horizontal, None)zoomSlider.setRange(1, 8)zoomSlider.setValue(4)zoomSlider.setTickInterval(1)@@ -242,8 +248,8 @@ class comics_project_manager_docker(DockWidget):baseLayout.addWidget(pageBox)self.btn_project = QToolButton()- self.btn_project.setPopupMode(QToolButton.MenuButtonPopup)- self.btn_project.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)+ self.btn_project.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup)+ self.btn_project.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum)menu_project = QMenu()self.action_new_project = QAction(i18n("New Project"), self)self.action_new_project.triggered.connect(self.slot_new_project)@@ -257,8 +263,8 @@ class comics_project_manager_docker(DockWidget):# Settings dropdown with actions for the different settings menus.self.btn_settings = QToolButton()- self.btn_settings.setPopupMode(QToolButton.MenuButtonPopup)- self.btn_settings.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)+ self.btn_settings.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup)+ self.btn_settings.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum)self.action_edit_project_settings = QAction(i18n("Project Settings"), self)self.action_edit_project_settings.triggered.connect(self.slot_edit_project_settings)self.action_edit_meta_data = QAction(i18n("Meta Data"), self)@@ -276,8 +282,8 @@ class comics_project_manager_docker(DockWidget):# Add page drop down with different page actions.self.btn_add_page = QToolButton()- self.btn_add_page.setPopupMode(QToolButton.MenuButtonPopup)- self.btn_add_page.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)+ self.btn_add_page.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup)+ self.btn_add_page.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum)self.action_add_page = QAction(i18n("Add Page"), self)self.action_add_page.triggered.connect(self.slot_add_new_page_single)@@ -312,7 +318,7 @@ class comics_project_manager_docker(DockWidget):buttonLayout.addWidget(self.btn_add_page)self.btn_add_page.setDisabled(True)- self.comicPageList.setContextMenuPolicy(Qt.ActionsContextMenu)+ self.comicPageList.setContextMenuPolicy(Qt.ContextMenuPolicy.ActionsContextMenu)self.comicPageList.addActions(actionList)# Export button that... exports.@@ -332,7 +338,7 @@ class comics_project_manager_docker(DockWidget):self.pagesWatcher = QFileSystemWatcher()self.pagesWatcher.fileChanged.connect(self.slot_start_delayed_check_page_update)- buttonLayout.addItem(QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.MinimumExpanding))+ buttonLayout.addItem(QSpacerItem(0, 0, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.MinimumExpanding))"""Open the config file and load the json file into a dictionary.@@ -342,7 +348,7 @@ class comics_project_manager_docker(DockWidget):self.path_to_config = QFileDialog.getOpenFileName(caption=i18n("Please select the JSON comic config file."), filter=str(i18n("JSON files") + "(*.json)"))[0]if os.path.exists(self.path_to_config) is True:if os.access(self.path_to_config, os.W_OK) is False:- QMessageBox.warning(None, i18n("Config cannot be used"), i18n("Krita doesn't have write access to this folder, so new files cannot be made. Please configure the folder access or move the project to a folder that can be written to."), QMessageBox.Ok)+ QMessageBox.warning(None, i18n("Config cannot be used"), i18n("Krita doesn't have write access to this folder, so new files cannot be made. Please configure the folder access or move the project to a folder that can be written to."), QMessageBox.StandardButton.Ok)returnconfigFile = open(self.path_to_config, "r", newline="", encoding="utf-16")self.setupDictionary = json.load(configFile)@@ -518,7 +524,7 @@ class comics_project_manager_docker(DockWidget):dialog = comics_project_settings_dialog.comics_project_details_editor(self.projecturl)dialog.setConfig(self.setupDictionary, self.projecturl)- if dialog.exec_() == QDialog.Accepted:+ if dialog.exec() == QDialog.DialogCode.Accepted:self.setupDictionary = dialog.getConfig(self.setupDictionary)self.slot_write_config()self.projectName.setMainText(str(self.setupDictionary["projectName"]))@@ -589,12 +595,12 @@ class comics_project_manager_docker(DockWidget):if templateExists is False:if "templateLocation" not in self.setupDictionary.keys():- self.setupDictionary["templateLocation"] = os.path.relpath(QFileDialog.getExistingDirectory(caption=i18n("Where are the templates located?"), options=QFileDialog.ShowDirsOnly), self.projecturl)+ self.setupDictionary["templateLocation"] = os.path.relpath(QFileDialog.getExistingDirectory(caption=i18n("Where are the templates located?"), options=QFileDialog.Option.ShowDirsOnly), self.projecturl)templateDir = os.path.join(self.projecturl, self.setupDictionary["templateLocation"])template = comics_template_dialog.comics_template_dialog(templateDir)- if template.exec_() == QDialog.Accepted:+ if template.exec() == QDialog.DialogCode.Accepted:templateUrl = os.path.relpath(template.url(), self.projecturl)self.setupDictionary["singlePageTemplate"] = templateUrlif os.path.exists(os.path.join(self.projecturl, templateUrl)):@@ -608,12 +614,12 @@ class comics_project_manager_docker(DockWidget):def slot_add_new_page_from_template(self):if "templateLocation" not in self.setupDictionary.keys():- self.setupDictionary["templateLocation"] = os.path.relpath(QFileDialog.getExistingDirectory(caption=i18n("Where are the templates located?"), options=QFileDialog.ShowDirsOnly), self.projecturl)+ self.setupDictionary["templateLocation"] = os.path.relpath(QFileDialog.getExistingDirectory(caption=i18n("Where are the templates located?"), options=QFileDialog.Option.ShowDirsOnly), self.projecturl)templateDir = os.path.join(self.projecturl, self.setupDictionary["templateLocation"])template = comics_template_dialog.comics_template_dialog(templateDir)- if template.exec_() == QDialog.Accepted:+ if template.exec() == QDialog.DialogCode.Accepted:templateUrl = os.path.relpath(template.url(), self.projecturl)self.add_new_page(templateUrl)@@ -632,7 +638,7 @@ class comics_project_manager_docker(DockWidget):self.setupDictionary['pageNumber'] = 0if (str(self.setupDictionary["pagesLocation"]).isspace()):- self.setupDictionary["pagesLocation"] = os.path.relpath(QFileDialog.getExistingDirectory(caption=i18n("Where should the pages go?"), options=QFileDialog.ShowDirsOnly), self.projecturl)+ self.setupDictionary["pagesLocation"] = os.path.relpath(QFileDialog.getExistingDirectory(caption=i18n("Where should the pages go?"), options=QFileDialog.Option.ShowDirsOnly), self.projecturl)# Search for the possible name.extraUnderscore = str()@@ -673,7 +679,7 @@ class comics_project_manager_docker(DockWidget):# close page document.while os.path.exists(absoluteUrl) is False:- qApp.processEvents()+ QApplication.instance().processEvents()self.pagesWatcher.addPath(absoluteUrl)newPage.close()@@ -722,7 +728,7 @@ class comics_project_manager_docker(DockWidget):# Set the title to the filename if it was empty. It looks a bit neater.if page.name().isspace or len(page.name()) < 1:- page.setName(str(self.pagesModel.data(index, role=Qt.DisplayRole)).replace("_", " "))+ page.setName(str(self.pagesModel.data(index, role=Qt.ItemDataRole.DisplayRole)).replace("_", " "))# Add views for the document so the user can use it.Application.activeWindow().addView(page)@@ -738,7 +744,7 @@ class comics_project_manager_docker(DockWidget):dialog = comics_metadata_dialog.comic_meta_data_editor()dialog.setConfig(self.setupDictionary)- if (dialog.exec_() == QDialog.Accepted):+ if (dialog.exec() == QDialog.DialogCode.Accepted):self.setupDictionary = dialog.getConfig(self.setupDictionary)self.slot_write_config()@@ -764,7 +770,7 @@ class comics_project_manager_docker(DockWidget):aboutelem = xmlroot.find(calligra + 'about')if ET.iselement(aboutelem.find(calligra + 'subject')):desc = aboutelem.find(calligra + 'subject')- desc.text = self.pagesModel.data(index, role=Qt.EditRole)+ desc.text = self.pagesModel.data(index, role=Qt.ItemDataRole.EditRole)xmlstring = ET.tostring(xmlroot, encoding='unicode', method='xml', short_empty_elements=False)page.writestr(zinfo_or_arcname="documentinfo.xml", data=xmlstring)for document in Application.documents():@@ -780,7 +786,7 @@ class comics_project_manager_docker(DockWidget):dialog = comics_export_dialog.comic_export_setting_dialog()dialog.setConfig(self.setupDictionary)- if (dialog.exec_() == QDialog.Accepted):+ if (dialog.exec() == QDialog.DialogCode.Accepted):self.setupDictionary = dialog.getConfig(self.setupDictionary)self.slot_write_config()@@ -804,7 +810,7 @@ class comics_project_manager_docker(DockWidget):exportSuccess = exporter.export()if exportSuccess:print("CPMT: Export success! The files have been written to the export folder!")- QMessageBox.information(self, i18n("Export success"), i18n("The files have been written to the export folder."), QMessageBox.Ok)+ QMessageBox.information(self, i18n("Export success"), i18n("The files have been written to the export folder."), QMessageBox.StandardButton.Ok)"""Calls up the comics project setup wizard so users can create a new json file with the basic information.@@ -882,7 +888,7 @@ class comics_project_manager_docker(DockWidget):def slot_batch_resize(self):dialog = QDialog()dialog.setWindowTitle(i18n("Resize all Pages"))- buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)buttons.accepted.connect(dialog.accept)buttons.rejected.connect(dialog.reject)sizesBox = comics_export_dialog.comic_export_resize_widget("Scale", batch=True, fileType=False)@@ -891,7 +897,7 @@ class comics_project_manager_docker(DockWidget):dialog.layout().addWidget(sizesBox)dialog.layout().addWidget(buttons)- if dialog.exec_() == QDialog.Accepted:+ if dialog.exec() == QDialog.Accepted:progress = QProgressDialog(i18n("Resizing pages..."), str(), 0, len(self.setupDictionary["pages"]))progress.setWindowTitle(i18n("Resizing Pages"))progress.setCancelButton(None)@@ -908,7 +914,7 @@ class comics_project_manager_docker(DockWidget):passedString = str(int(timePassed / 60000)) + ":" + format(int(timePassed / 1000), "02d") + ":" + format(timePassed % 1000, "03d")estimatedString = str(int(timeEstimated / 60000)) + ":" + format(int(timeEstimated / 1000), "02d") + ":" + format(int(timeEstimated % 1000), "03d")progress.setLabelText(str(i18n("{pages} of {pagesTotal} done. \nTime passed: {passedString}:\n Estimated:{estimated}")).format(pages=p, pagesTotal=len(self.setupDictionary["pages"]), passedString=passedString, estimated=estimatedString))- qApp.processEvents()+ QApplication.instance().processEvents()if os.path.exists(absoluteUrl):doc = Application.openDocument(absoluteUrl)listScales = exporterSizes.get_scale_from_resize_config(config["Scale"], [doc.width(), doc.height(), doc.resolution(), doc.resolution()])@@ -932,7 +938,7 @@ class comics_project_manager_docker(DockWidget):def slot_copy_project_url(self):if self.projecturl is not None:- clipboard = qApp.clipboard()+ clipboard = QApplication.instance().clipboard()clipboard.setText(str(self.projecturl))"""@@ -955,7 +961,7 @@ class comics_project_manager_docker(DockWidget):metadata["keywords"] = ", ".join(self.setupDictionary.get("otherKeywords", [""]))metadata["transnotes"] = self.setupDictionary.get("translatorHeader", "Translator's Notes")scraper.start(self.setupDictionary["pages"], language, metadata)- QMessageBox.information(self, i18n("Scraping success"), str(i18n("POT file has been written to: {file}")).format(file=fullTranslationPath), QMessageBox.Ok)+ QMessageBox.information(self, i18n("Scraping success"), str(i18n("POT file has been written to: {file}")).format(file=fullTranslationPath), QMessageBox.StandardButton.Ok)"""This is required by the dockwidget class, otherwise unused."""@@ -967,4 +973,4 @@ class comics_project_manager_docker(DockWidget):"""Add docker to program"""-Application.addDockWidgetFactory(DockWidgetFactory("comics_project_manager_docker", DockWidgetFactoryBase.DockRight, comics_project_manager_docker))+Application.addDockWidgetFactory(DockWidgetFactory("comics_project_manager_docker", DockWidgetFactoryBase.DockPosition.DockRight, comics_project_manager_docker))diff --git a/plugins/python/comics_project_management_tools/comics_project_page_viewer.py b/plugins/python/comics_project_management_tools/comics_project_page_viewer.pyindex efddcc9c92..ee788dd569 100644--- a/plugins/python/comics_project_management_tools/comics_project_page_viewer.py+++ b/plugins/python/comics_project_management_tools/comics_project_page_viewer.py@@ -15,12 +15,20 @@ import osimport sysimport jsonimport zipfile-from PyQt5.QtGui import QImage, QPainter-from PyQt5.QtWidgets import QDialog, QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QSizePolicy, QDialogButtonBox, QShortcut, QLabel-from PyQt5.QtCore import QSize, Qt+try:+ from PyQt6.QtGui import QImage, QPainter, QShortcut+ from PyQt6.QtWidgets import QDialog, QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QSizePolicy, QDialogButtonBox, QLabel+ from PyQt6.QtCore import QSize, Qt-# To run standalon-from PyQt5.QtWidgets import QApplication+ # To run standalone+ from PyQt6.QtWidgets import QApplication+except:+ from PyQt5.QtGui import QImage, QPainter+ from PyQt5.QtWidgets import QDialog, QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QSizePolicy, QDialogButtonBox, QShortcut, QLabel+ from PyQt5.QtCore import QSize, Qt++ # To run standalone+ from PyQt5.QtWidgets import QApplicationclass page_viewer(QPushButton):@@ -29,7 +37,7 @@ class page_viewer(QPushButton):super(page_viewer, self).__init__(parent)self.alignment = 'left'self.image = QImage()- self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)+ self.setSizePolicy(QSizePolicy.Policy.MinimumExpanding, QSizePolicy.Policy.MinimumExpanding)def align_left(self):self.alignment = 'left'@@ -51,9 +59,9 @@ class page_viewer(QPushButton):if self.image.width() <= previewSize.width() or self.image.height() <= previewSize.height():# pixel art- image = self.image.scaled(previewSize, Qt.KeepAspectRatio, Qt.FastTransformation)+ image = self.image.scaled(previewSize, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.FastTransformation)else:- image = self.image.scaled(previewSize, Qt.KeepAspectRatio, Qt.SmoothTransformation)+ image = self.image.scaled(previewSize, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)image.setDevicePixelRatio(self.devicePixelRatioF())if self.alignment == 'right':x_offset = int(self.width() - image.width()/self.devicePixelRatioF())@@ -77,10 +85,10 @@ class comics_project_page_viewer(QDialog):self.setModal(False)self.setWindowTitle('Untitled')self.setWindowFlags(- Qt.WindowTitleHint |- Qt.WindowMinimizeButtonHint |- Qt.WindowMaximizeButtonHint |- Qt.WindowCloseButtonHint+ Qt.WindowType.WindowTitleHint |+ Qt.WindowType.WindowMinimizeButtonHint |+ Qt.WindowType.WindowMaximizeButtonHint |+ Qt.WindowType.WindowCloseButtonHint)self.resize(1024, 768)self.setLayout(QVBoxLayout())@@ -140,7 +148,7 @@ class comics_project_page_viewer(QDialog):self.projecturl = os.path.dirname(str(self.path_to_config))if 'readingDirection' in self.setupDictionary:if self.setupDictionary['readingDirection'] == "leftToRight":- self.setLayoutDirection(Qt.LeftToRight)+ self.setLayoutDirection(Qt.LayoutDirection.LeftToRight)self.left_shortcut.disconnect()self.right_shortcut.disconnect()self.left_shortcut.activated.connect(self.prev_page)@@ -148,13 +156,13 @@ class comics_project_page_viewer(QDialog):else:self.left_shortcut.disconnect()self.right_shortcut.disconnect()- self.setLayoutDirection(Qt.RightToLeft)+ self.setLayoutDirection(Qt.LayoutDirection.RightToLeft)self.left_shortcut.activated.connect(self.next_page)self.right_shortcut.activated.connect(self.prev_page)else:self.left_shortcut.disconnect()self.right_shortcut.disconnect()- self.setLayoutDirection(Qt.LeftToRight)+ self.setLayoutDirection(Qt.LayoutDirection.LeftToRight)self.left_shortcut.activated.connect(self.prev_page)self.right_shortcut.activated.connect(self.next_page)configFile.close()@@ -263,8 +271,8 @@ class comics_project_page_viewer(QDialog):image = QImage.fromData(page.read("mergedimage.png"))page.close()return image- image = QImage(QSize(10, 10), QImage.Format_ARGB32)- image.fill(Qt.GlobalColor(19))+ image = QImage(QSize(10, 10), QImage.Format.Format_ARGB32)+ image.fill(Qt.GlobalColor.transparent)return imageif __name__ == '__main__':@@ -284,7 +292,7 @@ if __name__ == '__main__':else:print('Pass the path to a Krita comicConfig.json file to this script, to view the comic.')- sys.exit(app.exec_())+ sys.exit(app.exec())diff --git a/plugins/python/comics_project_management_tools/comics_project_settings_dialog.py b/plugins/python/comics_project_management_tools/comics_project_settings_dialog.pyindex 7e9a8f716a..76181a69fd 100644--- a/plugins/python/comics_project_management_tools/comics_project_settings_dialog.py+++ b/plugins/python/comics_project_management_tools/comics_project_settings_dialog.py@@ -10,8 +10,13 @@ SPDX-License-Identifier: GPL-3.0-or-laterA dialog for editing the general project settings."""import os-from PyQt5.QtWidgets import QWidget, QDialog, QDialogButtonBox, QHBoxLayout, QFormLayout, QPushButton, QLabel, QLineEdit, QToolButton, QFrame, QAction, QFileDialog, QComboBox, QSizePolicy-from PyQt5.QtCore import QDir, Qt, pyqtSignal+try:+ from PyQt6.QtWidgets import QWidget, QDialog, QDialogButtonBox, QHBoxLayout, QFormLayout, QPushButton, QLabel, QLineEdit, QToolButton, QFrame, QFileDialog, QComboBox, QSizePolicy+ from PyQt6.QtCore import QDir, Qt, pyqtSignal+ from PyQt6.QtGui import QAction+except:+ from PyQt5.QtWidgets import QWidget, QDialog, QDialogButtonBox, QHBoxLayout, QFormLayout, QPushButton, QLabel, QLineEdit, QToolButton, QFrame, QAction, QFileDialog, QComboBox, QSizePolicy+ from PyQt5.QtCore import QDir, Qt, pyqtSignalfrom krita import *"""@@ -41,11 +46,11 @@ class path_select(QWidget):self.layout().addWidget(self.location)self.layout().addWidget(self.button)self.layout().setContentsMargins(0, 0, 0, 0)- self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)- self.location.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)- self.button.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)- self.location.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)- self.location.setAlignment(Qt.AlignRight)+ self.setSizePolicy(QSizePolicy.Policy.MinimumExpanding, QSizePolicy.Policy.Minimum)+ self.location.setFrameStyle(QFrame.Shape.StyledPanel | QFrame.Shadow.Sunken)+ self.button.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum)+ self.location.setSizePolicy(QSizePolicy.Policy.MinimumExpanding, QSizePolicy.Policy.Minimum)+ self.location.setAlignment(Qt.AlignmentFlag.AlignRight)self.location.setLineWidth(1)if projectUrl is None:self.projectUrl = QDir.homePath()@@ -102,7 +107,7 @@ class comics_project_details_editor(QDialog):layout = QFormLayout()self.setLayout(layout)self.setWindowTitle(i18n("Comic Project Settings"))- buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)buttons.accepted.connect(self.accept)buttons.rejected.connect(self.reject)diff --git a/plugins/python/comics_project_management_tools/comics_project_setup_wizard.py b/plugins/python/comics_project_management_tools/comics_project_setup_wizard.pyindex bd3aafd5aa..912456c2b3 100644--- a/plugins/python/comics_project_management_tools/comics_project_setup_wizard.py+++ b/plugins/python/comics_project_management_tools/comics_project_setup_wizard.py@@ -14,8 +14,12 @@ import json # For writing to json.import os # For finding the script location.from pathlib import Path # For reading all the files in a directory.import random # For selecting two random words from a list.-from PyQt5.QtWidgets import QWidget, QWizard, QWizardPage, QHBoxLayout, QFormLayout, QFileDialog, QLineEdit, QPushButton, QCheckBox, QLabel, QDialog-from PyQt5.QtCore import QDate, QLocale, QUuid+try:+ from PyQt6.QtWidgets import QWidget, QWizard, QWizardPage, QHBoxLayout, QFormLayout, QFileDialog, QLineEdit, QPushButton, QCheckBox, QLabel, QDialog+ from PyQt6.QtCore import QDate, QLocale, QUuid+except:+ from PyQt5.QtWidgets import QWidget, QWizard, QWizardPage, QHBoxLayout, QFormLayout, QFileDialog, QLineEdit, QPushButton, QCheckBox, QLabel, QDialog+ from PyQt5.QtCore import QDate, QLocale, QUuidfrom krita import *from . import comics_metadata_dialog@@ -51,19 +55,19 @@ class ComicsProjectSetupWizard():self.projectDirectory = Nonewhile self.projectDirectory == None:- self.projectDirectory = QFileDialog.getExistingDirectory(caption=i18n("Where should the comic project go?"), options=QFileDialog.ShowDirsOnly)+ self.projectDirectory = QFileDialog.getExistingDirectory(caption=i18n("Where should the comic project go?"), options=QFileDialog.Option.ShowDirsOnly)if os.path.exists(self.projectDirectory) is False:returnif os.access(self.projectDirectory, os.W_OK) is False:- QMessageBox.warning(None, i18n("Folder cannot be used"), i18n("Krita doesn't have write access to this folder, so files cannot be made. Please choose a different folder."), QMessageBox.Ok)+ QMessageBox.warning(None, i18n("Folder cannot be used"), i18n("Krita doesn't have write access to this folder, so files cannot be made. Please choose a different folder."), QMessageBox.StandardButton.Ok)self.projectDirectory = Noneself.pagesDirectory = os.path.relpath(self.projectDirectory, self.projectDirectory)self.exportDirectory = os.path.relpath(self.projectDirectory, self.projectDirectory)wizard = QWizard()wizard.setWindowTitle(i18n("Comic Project Setup"))- wizard.setOption(QWizard.IndependentPages, True)- wizard.setWizardStyle(QWizard.ClassicStyle)+ wizard.setOption(QWizard.WizardOption.IndependentPages, True)+ wizard.setWizardStyle(QWizard.WizardStyle.ClassicStyle)# Set up the UI for the wizardbasicsPage = QWizardPage()@@ -139,7 +143,7 @@ class ComicsProjectSetupWizard():wizard.addPage(foldersPage)# Execute the wizard, and after wards...- if (wizard.exec_()):+ if (wizard.exec()):# First get the directories, check if the directories exist, and otherwise make them.self.pagesDirectory = self.lnPagesDirectory.text()@@ -186,7 +190,7 @@ class ComicsProjectSetupWizard():self.setupDictionary["language"] = str(self.cmbLanguage.codeForCurrentEntry())dialog.setConfig(self.setupDictionary)dialog.setConfig(self.setupDictionary)- if (dialog.exec_() == QDialog.Accepted):+ if (dialog.exec() == QDialog.DialogCode.Accepted):self.setupDictionary = dialog.getConfig(self.setupDictionary)self.cmbLanguage.setEntryToCode(self.setupDictionary["language"])diff --git a/plugins/python/comics_project_management_tools/comics_project_translation_scraper.py b/plugins/python/comics_project_management_tools/comics_project_translation_scraper.pyindex c2e733e90d..8dd85a08ff 100644--- a/plugins/python/comics_project_management_tools/comics_project_translation_scraper.py+++ b/plugins/python/comics_project_management_tools/comics_project_translation_scraper.py@@ -22,7 +22,10 @@ import csvimport zipfileimport typesfrom xml.dom import minidom-from PyQt5.QtCore import QDateTime, Qt+try:+ from PyQt6.QtCore import QDateTime, Qt+except:+ from PyQt5.QtCore import QDateTime, Qtclass translation_scraper():@@ -204,7 +207,7 @@ class translation_scraper():file.write("msgid " + quote + quote + newLine)file.write("msgstr " + quote + quote + newLine)- date = QDateTime.currentDateTimeUtc().toString(Qt.ISODate)+ date = QDateTime.currentDateTimeUtc().toString(Qt.DateFormat.ISODate)file.write(quote + "POT-Creation-Date:" + date + "\\n" + quote + newLine)file.write(quote + "Content-Type: text/plain; charset=UTF-8\\n" + quote + newLine)file.write(quote + "Content-Transfer-Encoding: 8bit\\n" + quote + newLine)diff --git a/plugins/python/comics_project_management_tools/comics_template_dialog.py b/plugins/python/comics_project_management_tools/comics_template_dialog.pyindex f84a617b3b..d64ff80bba 100644--- a/plugins/python/comics_project_management_tools/comics_template_dialog.py+++ b/plugins/python/comics_project_management_tools/comics_template_dialog.py@@ -12,9 +12,14 @@ Template dialogimport osimport shutil#from PyQt5.QtGui import *-from PyQt5.QtWidgets import QDialog, QComboBox, QDialogButtonBox, QVBoxLayout, QFormLayout, QGridLayout, QWidget, QPushButton, QHBoxLayout, QLabel, QSpinBox, QDoubleSpinBox, QLineEdit, QTabWidget, QColorDialog, QProgressDialog-from PyQt5.QtCore import QLocale, Qt, QByteArray, QRectF-from PyQt5.QtGui import QImage, QPainter, QPixmap+try:+ from PyQt6.QtWidgets import QDialog, QComboBox, QDialogButtonBox, QVBoxLayout, QFormLayout, QGridLayout, QWidget, QPushButton, QHBoxLayout, QLabel, QSpinBox, QDoubleSpinBox, QLineEdit, QTabWidget, QColorDialog, QProgressDialog+ from PyQt6.QtCore import QLocale, Qt, QByteArray, QRectF+ from PyQt6.QtGui import QImage, QPainter, QPixmap+except:+ from PyQt5.QtWidgets import QDialog, QComboBox, QDialogButtonBox, QVBoxLayout, QFormLayout, QGridLayout, QWidget, QPushButton, QHBoxLayout, QLabel, QSpinBox, QDoubleSpinBox, QLineEdit, QTabWidget, QColorDialog, QProgressDialog+ from PyQt5.QtCore import QLocale, Qt, QByteArray, QRectF+ from PyQt5.QtGui import QImage, QPainter, QPixmapfrom krita import *"""Quick and dirty QComboBox subclassing that handles unitconversion for us.@@ -34,7 +39,7 @@ class simpleUnitBox(QComboBox):self.addItem(self.centimeter)self.addItem(self.millimeter)- if QLocale().system().measurementSystem() is QLocale.MetricSystem:+ if QLocale().system().measurementSystem() is QLocale.MeasurementSystem.MetricSystem:self.setCurrentIndex(2) # set to centimeter if metric system.else:self.setCurrentIndex(1)@@ -68,7 +73,7 @@ class simpleUnitBox(QComboBox):class comics_template_dialog(QDialog):templateDirectory = str()templates = QComboBox()- buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)def __init__(self, templateDirectory):super().__init__()@@ -79,10 +84,10 @@ class comics_template_dialog(QDialog):self.templates = QComboBox()self.templates.setEnabled(False)- self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ self.buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)self.buttons.accepted.connect(self.accept)self.buttons.rejected.connect(self.reject)- self.buttons.button(QDialogButtonBox.Ok).setEnabled(False)+ self.buttons.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)mainWidget = QWidget()self.layout().addWidget(mainWidget)self.layout().addWidget(self.buttons)@@ -105,12 +110,12 @@ class comics_template_dialog(QDialog):self.templates.addItem(name)if self.templates.model().rowCount() > 0:self.templates.setEnabled(True)- self.buttons.button(QDialogButtonBox.Ok).setEnabled(True)+ self.buttons.button(QDialogButtonBox.StandardButton.Ok).setEnabled(True)def slot_create_template(self):create = comics_template_create(self.templateDirectory)- if create.exec_() == QDialog.Accepted:+ if create.exec() == QDialog.DialogCode.Accepted:if (create.prepare_krita_file()):self.fill_templates()@@ -127,14 +132,14 @@ class comics_template_dialog(QDialog):class comics_template_create(QDialog):urlSavedTemplate = str()templateDirectory = str()- currentColor = QColor(Qt.white)+ currentColor = QColor(Qt.GlobalColor.white)def __init__(self, templateDirectory):super().__init__()self.templateDirectory = templateDirectoryself.setWindowTitle(i18n("Create new Template"))self.setLayout(QVBoxLayout())- buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)buttons.accepted.connect(self.accept)buttons.rejected.connect(self.reject)mainWidget = QWidget()@@ -204,16 +209,16 @@ class comics_template_create(QDialog):self.marginBottom = QDoubleSpinBox()self.marginBottom.setMaximum(1000)self.marginBottomUnit = simpleUnitBox()- marginForm.addWidget(QLabel(i18n("Left:")), 0, 0, Qt.AlignRight)+ marginForm.addWidget(QLabel(i18n("Left:")), 0, 0, Qt.AlignmentFlag.AlignRight)marginForm.addWidget(self.marginLeft, 0, 1)marginForm.addWidget(self.marginLeftUnit, 0, 2)- marginForm.addWidget(QLabel(i18n("Top:")), 1, 0, Qt.AlignRight)+ marginForm.addWidget(QLabel(i18n("Top:")), 1, 0, Qt.AlignmentFlag.AlignRight)marginForm.addWidget(self.marginTop, 1, 1)marginForm.addWidget(self.marginTopUnit, 1, 2)- marginForm.addWidget(QLabel(i18n("Right:")), 2, 0, Qt.AlignRight)+ marginForm.addWidget(QLabel(i18n("Right:")), 2, 0, Qt.AlignmentFlag.AlignRight)marginForm.addWidget(self.marginRight, 2, 1)marginForm.addWidget(self.marginRightUnit, 2, 2)- marginForm.addWidget(QLabel(i18n("Bottom:")), 3, 0, Qt.AlignRight)+ marginForm.addWidget(QLabel(i18n("Bottom:")), 3, 0, Qt.AlignmentFlag.AlignRight)marginForm.addWidget(self.marginBottom, 3, 1)marginForm.addWidget(self.marginBottomUnit, 3, 2)marginAndBleed.addTab(margins, i18n("Margins"))@@ -233,22 +238,22 @@ class comics_template_create(QDialog):self.bleedBottom = QDoubleSpinBox()self.bleedBottom.setMaximum(1000)self.bleedBottomUnit = simpleUnitBox()- bleedsForm.addWidget(QLabel(i18n("Left:")), 0, 0, Qt.AlignRight)+ bleedsForm.addWidget(QLabel(i18n("Left:")), 0, 0, Qt.AlignmentFlag.AlignRight)bleedsForm.addWidget(self.bleedLeft, 0, 1)bleedsForm.addWidget(self.bleedLeftUnit, 0, 2)- bleedsForm.addWidget(QLabel(i18n("Top:")), 1, 0, Qt.AlignRight)+ bleedsForm.addWidget(QLabel(i18n("Top:")), 1, 0, Qt.AlignmentFlag.AlignRight)bleedsForm.addWidget(self.bleedTop, 1, 1)bleedsForm.addWidget(self.bleedTopUnit, 1, 2)- bleedsForm.addWidget(QLabel(i18n("Right:")), 2, 0, Qt.AlignRight)+ bleedsForm.addWidget(QLabel(i18n("Right:")), 2, 0, Qt.AlignmentFlag.AlignRight)bleedsForm.addWidget(self.bleedRight, 2, 1)bleedsForm.addWidget(self.bleedRightUnit, 2, 2)- bleedsForm.addWidget(QLabel(i18n("Bottom:")), 3, 0, Qt.AlignRight)+ bleedsForm.addWidget(QLabel(i18n("Bottom:")), 3, 0, Qt.AlignmentFlag.AlignRight)bleedsForm.addWidget(self.bleedBottom, 3, 1)bleedsForm.addWidget(self.bleedBottomUnit, 3, 2)marginAndBleed.addTab(bleeds, i18n("Bleeds"))- if QLocale().system().measurementSystem() is QLocale.MetricSystem:+ if QLocale().system().measurementSystem() is QLocale.MeasurementSystem.MetricSystem:self.setDefaults("European")else:self.setDefaults("American")@@ -280,7 +285,7 @@ class comics_template_create(QDialog):dialog = QColorDialog(self)dialog.setCurrentColor(self.currentColor)- if dialog.exec_() == QDialog.Accepted:+ if dialog.exec() == QDialog.DialogCode.Accepted:self.currentColor = dialog.currentColor()self.updateImagePreview()@@ -308,7 +313,7 @@ class comics_template_create(QDialog):template.rootNode().addChildNode(backgroundNode, None)pixelByteArray = QByteArray()- if self.currentColor == Qt.white:+ if self.currentColor == Qt.GlobalColor.white:pixelByteArray = backgroundNode.pixelData(0, 0, template.width(), template.height())pixelByteArray.fill(int(255).to_bytes(1, byteorder='little'))else:@@ -320,7 +325,7 @@ class comics_template_create(QDialog):progress = QProgressDialog(i18n("Creating template"), str(), 0, template.width()*template.height())progress.setCancelButton(None)progress.show()- qApp.processEvents()+ QApplication.instance().processEvents()for byteNumber in range(template.width()*template.height()):pixelByteArray.append( blue)pixelByteArray.append(green)@@ -383,8 +388,8 @@ class comics_template_create(QDialog):height = (hBase + bT + bB) * scaleRatiotopLeft = [max((maxSize - width) / 2, 0), max((maxSize - height) / 2, 0)]- image = QImage(maxSize, maxSize, QImage.Format_ARGB32)- image.fill(Qt.transparent)+ image = QImage(maxSize, maxSize, QImage.Format.Format_ARGB32)+ image.fill(Qt.GlobalColor.transparent)p = QPainter(image)@@ -400,8 +405,8 @@ class comics_template_create(QDialog):PageSize.setX(PageSize.x() + (bL * scaleRatio))PageSize.setY(PageSize.y() + (bT * scaleRatio))- p.setPen(Qt.blue)- p.setBrush(Qt.transparent)+ p.setPen(Qt.GlobalColor.blue)+ p.setBrush(Qt.GlobalColor.transparent)p.drawRect(PageSize.toRect())# Draw liveArea@@ -411,7 +416,7 @@ class comics_template_create(QDialog):LiveArea.setX(LiveArea.x() + (mL * scaleRatio))LiveArea.setY(LiveArea.y() + (mT * scaleRatio))- p.setPen(Qt.blue)+ p.setPen(Qt.GlobalColor.blue)p.drawRect(LiveArea.toRect())p.end()diff --git a/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py b/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.pyindex 386f39bd38..149fcca409 100644--- a/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py+++ b/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py@@ -15,9 +15,14 @@ http://acbf.wikia.com/wiki/ACBF_Specificationsimport osimport re-from PyQt5.QtCore import QDate, Qt, QPointF, QByteArray, QBuffer-from PyQt5.QtGui import QImage, QColor, QFont, QRawFont-from PyQt5.QtXml import QDomDocument, QDomElement, QDomText, QDomNodeList+try:+ from PyQt6.QtCore import QDate, Qt, QPointF, QByteArray, QBuffer+ from PyQt6.QtGui import QImage, QColor, QFont, QRawFont+ from PyQt6.QtXml import QDomDocument, QDomElement, QDomText, QDomNodeList+except:+ from PyQt5.QtCore import QDate, Qt, QPointF, QByteArray, QBuffer+ from PyQt5.QtGui import QImage, QColor, QFont, QRawFont+ from PyQt5.QtXml import QDomDocument, QDomElement, QDomText, QDomNodeListfrom . import CPMT_po_parser as po_parserdef write_xml(configDictionary = {}, pageData = [], pagesLocationList = [], locationBasic = str(), locationStandAlone = str(), projectUrl = str()):@@ -277,7 +282,7 @@ def write_xml(configDictionary = {}, pageData = [], pagesLocationList = [], locif "publishingDate" in configDictionary.keys():publishingDate = document.createElement("publish-date")publishingDate.setAttribute("value", configDictionary["publishingDate"])- publishingDate.appendChild(document.createTextNode(QDate.fromString(configDictionary["publishingDate"], Qt.ISODate).toString(Qt.SystemLocaleLongDate)))+ publishingDate.appendChild(document.createTextNode(QDate.fromString(configDictionary["publishingDate"], Qt.DateFormat.ISODate).toString(Qt.DateFormat.SystemLocaleLongDate)))publisherInfo.appendChild(publishingDate)if "publisherCity" in configDictionary.keys():publishCity = document.createElement("city")@@ -345,8 +350,8 @@ def write_xml(configDictionary = {}, pageData = [], pagesLocationList = [], locacbfDate = document.createElement("creation-date")now = QDate.currentDate()- acbfDate.setAttribute("value", now.toString(Qt.ISODate))- acbfDate.appendChild(document.createTextNode(str(now.toString(Qt.SystemLocaleLongDate))))+ acbfDate.setAttribute("value", now.toString(Qt.DateFormat.ISODate))+ acbfDate.appendChild(document.createTextNode(str(now.toString(Qt.DateFormat.SystemLocaleLongDate))))documentInfo.appendChild(acbfDate)if "acbfSource" in configDictionary.keys():diff --git a/plugins/python/comics_project_management_tools/exporters/CPMT_Comic_Book_Info_Exporter.py b/plugins/python/comics_project_management_tools/exporters/CPMT_Comic_Book_Info_Exporter.pyindex 8cb3e082e5..9d9683cf2d 100644--- a/plugins/python/comics_project_management_tools/exporters/CPMT_Comic_Book_Info_Exporter.py+++ b/plugins/python/comics_project_management_tools/exporters/CPMT_Comic_Book_Info_Exporter.py@@ -23,7 +23,10 @@ country"""import json-from PyQt5.QtCore import QDateTime, QDate, Qt, QLocale+try:+ from PyQt6.QtCore import QDateTime, QDate, Qt, QLocale+except:+ from PyQt5.QtCore import QDateTime, QDate, Qt, QLocaledef writeJson(configDictionary = {}):basedata = {}@@ -74,7 +77,7 @@ def writeJson(configDictionary = {}):if "publisherName" in configDictionary.keys():metadata["publisher"] = configDictionary["publisherName"]if "publishingDate" in configDictionary.keys():- date = QDate.fromString(configDictionary["publishingDate"], Qt.ISODate)+ date = QDate.fromString(configDictionary["publishingDate"], Qt.DateFormat.ISODate)metadata["publicationMonth"] = date.month()metadata["publicationYear"] = date.year()if "seriesNumber" in configDictionary.keys():@@ -103,7 +106,7 @@ def writeJson(configDictionary = {}):#basedata["appID"] = "Krita"- basedata["lastModified"] = QDateTime.currentDateTimeUtc().toString(Qt.ISODate)+ basedata["lastModified"] = QDateTime.currentDateTimeUtc().toString(Qt.DateFormat.ISODate)basedata["ComicBookInfo/1.0"] = metadatadiff --git a/plugins/python/comics_project_management_tools/exporters/CPMT_Comic_Rack_XML_Exporter.py b/plugins/python/comics_project_management_tools/exporters/CPMT_Comic_Rack_XML_Exporter.pyindex 91229d75f4..c40aee55dd 100644--- a/plugins/python/comics_project_management_tools/exporters/CPMT_Comic_Rack_XML_Exporter.py+++ b/plugins/python/comics_project_management_tools/exporters/CPMT_Comic_Rack_XML_Exporter.py@@ -35,7 +35,10 @@ Web"""from xml.dom import minidom-from PyQt5.QtCore import QDate, Qt+try:+ from PyQt6.QtCore import QDate, Qt+except:+ from PyQt5.QtCore import QDate, Qtdef write_xml(configDictionary = {}, pagesLocationList = [], location = str()):document = minidom.Document()@@ -66,7 +69,7 @@ def write_xml(configDictionary = {}, pagesLocationList = [], location = str()):root.appendChild(seriesname)if "publishingDate" in configDictionary.keys():- date = QDate.fromString(configDictionary["publishingDate"], Qt.ISODate)+ date = QDate.fromString(configDictionary["publishingDate"], Qt.DateFormat.ISODate)publishYear = document.createElement("Year")publishYear.appendChild(document.createTextNode(str(date.year())))publishMonth = document.createElement("Month")diff --git a/plugins/python/comics_project_management_tools/exporters/CPMT_EPUB_exporter.py b/plugins/python/comics_project_management_tools/exporters/CPMT_EPUB_exporter.pyindex 70e0bcc635..55bc951176 100644--- a/plugins/python/comics_project_management_tools/exporters/CPMT_EPUB_exporter.py+++ b/plugins/python/comics_project_management_tools/exporters/CPMT_EPUB_exporter.py@@ -14,9 +14,14 @@ import shutilimport osfrom pathlib import Pathimport zipfile-from PyQt5.QtXml import QDomDocument, QDomElement, QDomText, QDomNodeList-from PyQt5.QtCore import Qt, QDateTime, QPointF-from PyQt5.QtGui import QImage, QPolygonF, QColor+try:+ from PyQt6.QtXml import QDomDocument, QDomElement, QDomText, QDomNodeList+ from PyQt6.QtCore import Qt, QDateTime, QPointF+ from PyQt6.QtGui import QImage, QPolygonF, QColor+except:+ from PyQt5.QtXml import QDomDocument, QDomElement, QDomText, QDomNodeList+ from PyQt5.QtCore import Qt, QDateTime, QPointF+ from PyQt5.QtGui import QImage, QPolygonF, QColordef export(configDictionary = {}, projectURL = str(), pagesLocationList = [], pageData = []):path = Path(os.path.join(projectURL, configDictionary["exportLocation"]))@@ -355,7 +360,7 @@ def write_opf_file(path, configDictionary, htmlFiles, pagesList, coverpageurl, c#Creation datemodified = opfFile.createElement("meta")modified.setAttribute("property", "dcterms:modified")- modified.appendChild(opfFile.createTextNode(QDateTime.currentDateTimeUtc().toString(Qt.ISODate)))+ modified.appendChild(opfFile.createTextNode(QDateTime.currentDateTimeUtc().toString(Qt.DateFormat.ISODate)))opfMeta.appendChild(modified)if "source" in configDictionary.keys():diff --git a/plugins/python/documenttools/documenttoolsdialog.py b/plugins/python/documenttools/documenttoolsdialog.pyindex c4606e7ad9..d3428c0ae1 100644--- a/plugins/python/documenttools/documenttoolsdialog.py+++ b/plugins/python/documenttools/documenttoolsdialog.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QDialog+try:+ from PyQt6.QtWidgets import QDialog+except:+ from PyQt5.QtWidgets import QDialogclass DocumentToolsDialog(QDialog):diff --git a/plugins/python/documenttools/tools/canvassizetool/canvassizetool.py b/plugins/python/documenttools/tools/canvassizetool/canvassizetool.pyindex c3354281c6..0ca40b0444 100644--- a/plugins/python/documenttools/tools/canvassizetool/canvassizetool.py+++ b/plugins/python/documenttools/tools/canvassizetool/canvassizetool.py@@ -1,7 +1,11 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import (QWidget, QSpinBox,- QVBoxLayout, QFormLayout)+try:+ from PyQt6.QtWidgets import (QWidget, QSpinBox,+ QVBoxLayout, QFormLayout)+except:+ from PyQt5.QtWidgets import (QWidget, QSpinBox,+ QVBoxLayout, QFormLayout)class CanvasSizeTool(QWidget):diff --git a/plugins/python/documenttools/tools/rotatetool/rotatetool.py b/plugins/python/documenttools/tools/rotatetool/rotatetool.pyindex c99f896fbc..8995db9937 100644--- a/plugins/python/documenttools/tools/rotatetool/rotatetool.py+++ b/plugins/python/documenttools/tools/rotatetool/rotatetool.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QWidget, QSpinBox, QFormLayout+try:+ from PyQt6.QtWidgets import QWidget, QSpinBox, QFormLayout+except:+ from PyQt5.QtWidgets import QWidget, QSpinBox, QFormLayoutimport mathdiff --git a/plugins/python/documenttools/tools/scaletool/scaletool.py b/plugins/python/documenttools/tools/scaletool/scaletool.pyindex 4d3dac6388..e4404d2e1d 100644--- a/plugins/python/documenttools/tools/scaletool/scaletool.py+++ b/plugins/python/documenttools/tools/scaletool/scaletool.py@@ -1,7 +1,11 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import (QWidget, QSpinBox,- QVBoxLayout, QFormLayout, QComboBox)+try:+ from PyQt6.QtWidgets import (QWidget, QSpinBox,+ QVBoxLayout, QFormLayout, QComboBox)+except:+ from PyQt5.QtWidgets import (QWidget, QSpinBox,+ QVBoxLayout, QFormLayout, QComboBox)class ScaleTool(QWidget):@@ -19,7 +23,7 @@ class ScaleTool(QWidget):self.yResSpinBox = QSpinBox()self.strategyComboBox = QComboBox()- self.strategyComboBox.setSizeAdjustPolicy(QComboBox.AdjustToContents)+ self.strategyComboBox.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)self.setLayout(self.layout)self.initialize()diff --git a/plugins/python/documenttools/uidocumenttools.py b/plugins/python/documenttools/uidocumenttools.pyindex 8dcdaaab4c..869813e727 100644--- a/plugins/python/documenttools/uidocumenttools.py+++ b/plugins/python/documenttools/uidocumenttools.py@@ -1,10 +1,16 @@# SPDX-License-Identifier: CC0-1.0from . import documenttoolsdialog-from PyQt5.QtCore import Qt-from PyQt5.QtWidgets import (QFormLayout, QListWidget, QAbstractItemView,- QDialogButtonBox, QVBoxLayout, QFrame, QTabWidget,- QPushButton, QAbstractScrollArea, QMessageBox)+try:+ from PyQt6.QtCore import Qt+ from PyQt6.QtWidgets import (QFormLayout, QListWidget, QAbstractItemView,+ QDialogButtonBox, QVBoxLayout, QFrame, QTabWidget,+ QPushButton, QAbstractScrollArea, QMessageBox)+except:+ from PyQt5.QtCore import Qt+ from PyQt5.QtWidgets import (QFormLayout, QListWidget, QAbstractItemView,+ QDialogButtonBox, QVBoxLayout, QFrame, QTabWidget,+ QPushButton, QAbstractScrollArea, QMessageBox)import kritaimport importlib@@ -20,7 +26,7 @@ class UIDocumentTools(object):self.widgetDocuments = QListWidget()self.tabTools = QTabWidget()self.buttonBox = QDialogButtonBox(- QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)self.kritaInstance = krita.Krita.instance()self.documentsList = []@@ -29,10 +35,10 @@ class UIDocumentTools(object):self.buttonBox.accepted.connect(self.confirmButton)self.buttonBox.rejected.connect(self.mainDialog.close)- self.mainDialog.setWindowModality(Qt.NonModal)- self.widgetDocuments.setSelectionMode(QAbstractItemView.MultiSelection)+ self.mainDialog.setWindowModality(Qt.WindowModality.NonModal)+ self.widgetDocuments.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection)self.widgetDocuments.setSizeAdjustPolicy(- QAbstractScrollArea.AdjustToContents)+ QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents)def initialize(self):self.loadDocuments()@@ -45,8 +51,8 @@ class UIDocumentTools(object):self.formLayout.addRow(self.tabTools)self.line = QFrame()- self.line.setFrameShape(QFrame.HLine)- self.line.setFrameShadow(QFrame.Sunken)+ self.line.setFrameShape(QFrame.Shape.HLine)+ self.line.setFrameShadow(QFrame.Shadow.Sunken)self.mainLayout.addLayout(self.formLayout)self.mainLayout.addWidget(self.line)@@ -104,4 +110,4 @@ class UIDocumentTools(object):i18n("The selected documents has been modified."))else:self.msgBox.setText(i18n("Select at least one document."))- self.msgBox.exec_()+ self.msgBox.exec()diff --git a/plugins/python/example_scripts/resize_to_all_layers.py b/plugins/python/example_scripts/resize_to_all_layers.pyindex 1ca527eea5..6d72eba1e6 100644--- a/plugins/python/example_scripts/resize_to_all_layers.py+++ b/plugins/python/example_scripts/resize_to_all_layers.py@@ -7,7 +7,10 @@ the image to the unity of all boundaries."""from krita import Krita-from PyQt5.QtCore import QRect+try:+ from PyQt6.QtCore import QRect+except:+ from PyQt5.QtCore import QRectd = Krita.instance().activeDocument()w = d.width()diff --git a/plugins/python/exportlayers/exportlayersdialog.py b/plugins/python/exportlayers/exportlayersdialog.pyindex dcc0981dc7..8eccf03bc4 100644--- a/plugins/python/exportlayers/exportlayersdialog.py+++ b/plugins/python/exportlayers/exportlayersdialog.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QDialog+try:+ from PyQt6.QtWidgets import QDialog+except:+ from PyQt5.QtWidgets import QDialogclass ExportLayersDialog(QDialog):diff --git a/plugins/python/exportlayers/uiexportlayers.py b/plugins/python/exportlayers/uiexportlayers.pyindex 6852cf4c26..1a469019dc 100644--- a/plugins/python/exportlayers/uiexportlayers.py+++ b/plugins/python/exportlayers/uiexportlayers.py@@ -1,12 +1,20 @@# SPDX-License-Identifier: CC0-1.0from . import exportlayersdialog-from PyQt5.QtCore import (Qt, QRect)-from PyQt5.QtWidgets import (QFormLayout, QListWidget, QHBoxLayout,- QDialogButtonBox, QVBoxLayout, QFrame,- QPushButton, QAbstractScrollArea, QLineEdit,- QMessageBox, QFileDialog, QCheckBox, QSpinBox,- QComboBox, QListWidgetItem)+try:+ from PyQt6.QtCore import (Qt, QRect)+ from PyQt6.QtWidgets import (QFormLayout, QListWidget, QHBoxLayout,+ QDialogButtonBox, QVBoxLayout, QFrame,+ QPushButton, QAbstractScrollArea, QLineEdit,+ QMessageBox, QFileDialog, QCheckBox, QSpinBox,+ QComboBox, QListWidgetItem)+except:+ from PyQt5.QtCore import (Qt, QRect)+ from PyQt5.QtWidgets import (QFormLayout, QListWidget, QHBoxLayout,+ QDialogButtonBox, QVBoxLayout, QFrame,+ QPushButton, QAbstractScrollArea, QLineEdit,+ QMessageBox, QFileDialog, QCheckBox, QSpinBox,+ QComboBox, QListWidgetItem)import osimport krita@@ -44,7 +52,7 @@ class UIExportLayers(object):self.resSpinBox = QSpinBox()self.buttonBox = QDialogButtonBox(- QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)self.kritaInstance = krita.Krita.instance()self.documentsList = []@@ -53,16 +61,16 @@ class UIExportLayers(object):self.batchmodeCheckBox.setChecked(True)self.directoryDialogButton.clicked.connect(self._selectDir)self.widgetDocuments.currentRowChanged.connect(self._setResolution)- self.widgetDocuments.setSelectionMode(3) #multi-selection+ self.widgetDocuments.setSelectionMode(QListWidget.SelectionMode.MultiSelection)self.widgetDocuments.setMouseTracking(True) #enable ToolTips to show the pathsself.refreshButton.clicked.connect(self.refreshButtonClicked)self.buttonBox.accepted.connect(self.confirmButton)self.buttonBox.rejected.connect(self.mainDialog.close)self.cropToImageBounds.stateChanged.connect(self._toggleCropSize)- self.mainDialog.setWindowModality(Qt.NonModal)+ self.mainDialog.setWindowModality(Qt.WindowModality.NonModal)self.widgetDocuments.setSizeAdjustPolicy(- QAbstractScrollArea.AdjustToContents)+ QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents)def initialize(self):self.loadDocuments()@@ -102,8 +110,8 @@ class UIExportLayers(object):i18n("Images extensions:"), self.formatsComboBox)self.line = QFrame()- self.line.setFrameShape(QFrame.HLine)- self.line.setFrameShadow(QFrame.Sunken)+ self.line.setFrameShape(QFrame.Shape.HLine)+ self.line.setFrameShadow(QFrame.Shadow.Sunken)self.mainLayout.addLayout(self.formLayout)self.mainLayout.addWidget(self.line)@@ -163,7 +171,7 @@ class UIExportLayers(object):for doc in selectedDocuments:self.export(doc)self.msgBox.setText(i18n("All layers have been exported."))- self.msgBox.exec_()+ self.msgBox.exec()def mkdir(self, directory):target_directory = self.directoryTextField.text() + directory@@ -234,7 +242,7 @@ class UIExportLayers(object):self.mainDialog,i18n("Select a Folder"),os.path.expanduser("~"),- QFileDialog.ShowDirsOnly)+ QFileDialog.Option.ShowDirsOnly)self.directoryTextField.setText(directory)def _setResolution(self, index):diff --git a/plugins/python/filtermanager/components/filtercombobox.py b/plugins/python/filtermanager/components/filtercombobox.pyindex dc75e96c9a..81949ea322 100644--- a/plugins/python/filtermanager/components/filtercombobox.py+++ b/plugins/python/filtermanager/components/filtercombobox.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QComboBox+try:+ from PyQt6.QtWidgets import QComboBox+except:+ from PyQt5.QtWidgets import QComboBoxclass FilterComboBox(QComboBox):diff --git a/plugins/python/filtermanager/components/filtermanagertreemodel.py b/plugins/python/filtermanager/components/filtermanagertreemodel.pyindex 2924e21651..ef0612a8f6 100644--- a/plugins/python/filtermanager/components/filtermanagertreemodel.py+++ b/plugins/python/filtermanager/components/filtermanagertreemodel.py@@ -1,7 +1,11 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtCore import QAbstractItemModel, QModelIndex, Qt-from PyQt5.QtGui import QPixmap+try:+ from PyQt6.QtCore import QAbstractItemModel, QModelIndex, Qt+ from PyQt6.QtGui import QPixmap+except:+ from PyQt5.QtCore import QAbstractItemModel, QModelIndex, Qt+ from PyQt5.QtGui import QPixmapfrom . import filtermanagertreeitem@@ -69,28 +73,28 @@ class FilterManagerTreeModel(QAbstractItemModel):item = index.internalPointer()- if role == Qt.UserRole + 1:+ if role == Qt.ItemDataRole.UserRole + 1:return item.data(self.NODE_COLUMN)- if role == Qt.UserRole + 2:+ if role == Qt.ItemDataRole.UserRole + 2:return item.data(self.DOCUMENT_COLUMN)- if role == Qt.UserRole + 3:+ if role == Qt.ItemDataRole.UserRole + 3:return item.data(self.TYPE_COLUMN)- if role != Qt.DisplayRole and role != Qt.DecorationRole:+ if role != Qt.ItemDataRole.DisplayRole and role != Qt.ItemDataRole.DecorationRole:return Nonereturn item.data(index.column())def flags(self, index):if not index.isValid():- return Qt.NoItemFlags+ return Qt.ItemFlag.NoItemFlags- return Qt.ItemIsEnabled | Qt.ItemIsSelectable+ return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectabledef headerData(self, section, orientation, role):- if orientation == Qt.Horizontal and role == Qt.DisplayRole:+ if orientation == Qt.Orientation.Horizontal and role == Qt.ItemDataRole.DisplayRole:return self.rootItem.data(section)return Nonediff --git a/plugins/python/filtermanager/filtermanagerdialog.py b/plugins/python/filtermanager/filtermanagerdialog.pyindex a18fe7e951..bf0a369c9e 100644--- a/plugins/python/filtermanager/filtermanagerdialog.py+++ b/plugins/python/filtermanager/filtermanagerdialog.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QDialog+try:+ from PyQt6.QtWidgets import QDialog+except:+ from PyQt5.QtWidgets import QDialogclass FilterManagerDialog(QDialog):diff --git a/plugins/python/filtermanager/uifiltermanager.py b/plugins/python/filtermanager/uifiltermanager.pyindex 571fa6dcd8..cc3917832f 100644--- a/plugins/python/filtermanager/uifiltermanager.py+++ b/plugins/python/filtermanager/uifiltermanager.py@@ -2,9 +2,14 @@from . import filtermanagerdialogfrom .components import (filtercombobox, filtermanagertreemodel)-from PyQt5.QtCore import Qt-from PyQt5.QtWidgets import (QFormLayout, QAbstractItemView, QDialogButtonBox,- QVBoxLayout, QFrame, QTreeView)+try:+ from PyQt6.QtCore import Qt+ from PyQt6.QtWidgets import (QFormLayout, QAbstractItemView, QDialogButtonBox,+ QVBoxLayout, QFrame, QTreeView)+except:+ from PyQt5.QtCore import Qt+ from PyQt5.QtWidgets import (QFormLayout, QAbstractItemView, QDialogButtonBox,+ QVBoxLayout, QFrame, QTreeView)import krita@@ -15,7 +20,7 @@ class UIFilterManager(object):self.mainLayout = QVBoxLayout(self.mainDialog)self.formLayout = QFormLayout()self.buttonBox = QDialogButtonBox(- QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)self.kritaInstance = krita.Krita.instance()self._filters = sorted(self.kritaInstance.filters())@@ -29,8 +34,8 @@ class UIFilterManager(object):self.buttonBox.rejected.connect(self.mainDialog.close)self.documentsTreeView.setSelectionMode(- QAbstractItemView.SingleSelection)- self.mainDialog.setWindowModality(Qt.NonModal)+ QAbstractItemView.SelectionMode.SingleSelection)+ self.mainDialog.setWindowModality(Qt.WindowModality.NonModal)def initialize(self):self.documentsTreeView.setModel(self.treeModel)@@ -42,8 +47,8 @@ class UIFilterManager(object):self.formLayout.addRow(i18nc("Python filters", "Filters:"), self.filterComboBox)self.line = QFrame()- self.line.setFrameShape(QFrame.HLine)- self.line.setFrameShadow(QFrame.Sunken)+ self.line.setFrameShape(QFrame.Shape.HLine)+ self.line.setFrameShadow(QFrame.Shadow.Sunken)self.mainLayout.addWidget(self.documentsTreeView)self.mainLayout.addLayout(self.formLayout)@@ -61,9 +66,9 @@ class UIFilterManager(object):selectionModel = self.documentsTreeView.selectionModel()for index in selectionModel.selectedRows():- node = self.treeModel.data(index, Qt.UserRole + 1)- documentIndex = self.treeModel.data(index, Qt.UserRole + 2)- _type = self.treeModel.data(index, Qt.UserRole + 3)+ node = self.treeModel.data(index, Qt.ItemDataRole.UserRole + 1)+ documentIndex = self.treeModel.data(index, Qt.ItemDataRole.UserRole + 2)+ _type = self.treeModel.data(index, Qt.ItemDataRole.UserRole + 3)if _type == 'Document':self.applyFilterOverDocument(self.documents[documentIndex])diff --git a/plugins/python/highpass/highpass.py b/plugins/python/highpass/highpass.pyindex 160eb350c9..800aabd5e3 100644--- a/plugins/python/highpass/highpass.py+++ b/plugins/python/highpass/highpass.py@@ -1,16 +1,29 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5 import QtCore-from PyQt5.QtWidgets import (- QCheckBox,- QComboBox,- QDialog,- QDialogButtonBox,- QFormLayout,- QMessageBox,- QSpinBox,- QVBoxLayout,-)+try:+ from PyQt6.QtCore import Qt+ from PyQt6.QtWidgets import (+ QCheckBox,+ QComboBox,+ QDialog,+ QDialogButtonBox,+ QFormLayout,+ QMessageBox,+ QSpinBox,+ QVBoxLayout,+ )+except:+ from PyQt5.QtCore import Qt+ from PyQt5.QtWidgets import (+ QCheckBox,+ QComboBox,+ QDialog,+ QDialogButtonBox,+ QFormLayout,+ QMessageBox,+ QSpinBox,+ QVBoxLayout,+ )from krita import Extension@@ -54,9 +67,9 @@ class HighpassExtension(Extension):form.addRow("", self.keepOriginal)self.buttonBox = QDialogButtonBox(self.dialog)- self.buttonBox.setOrientation(QtCore.Qt.Horizontal)+ self.buttonBox.setOrientation(Qt.Orientation.Horizontal)self.buttonBox.setStandardButtons(- QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)self.buttonBox.accepted.connect(self.dialog.accept)self.buttonBox.accepted.connect(self.highpass)self.buttonBox.rejected.connect(self.dialog.reject)@@ -67,7 +80,7 @@ class HighpassExtension(Extension):self.dialog.show()self.dialog.activateWindow()- self.dialog.exec_()+ self.dialog.exec()def highpass(self):# XXX: Start undo macrodiff --git a/plugins/python/krita_script_starter/krita_script_starter.py b/plugins/python/krita_script_starter/krita_script_starter.pyindex 47a3c38430..9249d86890 100644--- a/plugins/python/krita_script_starter/krita_script_starter.py+++ b/plugins/python/krita_script_starter/krita_script_starter.py@@ -32,9 +32,14 @@ BBDimport osimport sys-from PyQt5.QtCore import QStandardPaths, QSettings-from PyQt5.QtWidgets import QApplication, QWidget, QMessageBox-import PyQt5.uic as uic+try:+ from PyQt6.QtCore import QStandardPaths, QSettings+ from PyQt6.QtWidgets import QApplication, QWidget, QMessageBox+ import PyQt6.uic as uic+except:+ from PyQt5.QtCore import QStandardPaths, QSettings+ from PyQt5.QtWidgets import QApplication, QWidget, QMessageBox+ import PyQt5.uic as uictry:import krita@@ -158,7 +163,7 @@ class {class_name}(DockWidget):instance = Krita.instance()dock_widget_factory = DockWidgetFactory(DOCKER_ID,- DockWidgetFactoryBase.DockRight,+ DockWidgetFactoryBase.DockPosition.DockRight,{class_name})instance.addDockWidgetFactory(dock_widget_factory)@@ -324,9 +329,9 @@ class KritaScriptStarter(EXTENSION):msgbox = QMessageBox(self)msgbox.setWindowTitle(title)msgbox.setText(message)- msgbox.setStandardButtons(QMessageBox.Ok)- msgbox.setDefaultButton(QMessageBox.Ok)- msgbox.setIcon(QMessageBox.Information)+ msgbox.setStandardButtons(QMessageBox.StandardButton.Ok)+ msgbox.setDefaultButton(QMessageBox.StandardButton.Ok)+ msgbox.setIcon(QMessageBox.Icon.Information)msgbox.exec()self.ui.close()@@ -419,4 +424,4 @@ if __name__ == "__main__":extension = KritaScriptStarter(None)extension.setup()extension.action_triggered()- sys.exit(app.exec_())+ sys.exit(app.exec())diff --git a/plugins/python/lastdocumentsdocker/__init__.py b/plugins/python/lastdocumentsdocker/__init__.pyindex cea3ba223e..38408781e3 100644--- a/plugins/python/lastdocumentsdocker/__init__.py+++ b/plugins/python/lastdocumentsdocker/__init__.py@@ -8,5 +8,5 @@ from .lastdocumentsdocker import LastDocumentsDockerApplication.addDockWidgetFactory(krita.DockWidgetFactory("lastdocumentsdocker",- krita.DockWidgetFactoryBase.DockRight,+ krita.DockWidgetFactoryBase.DockPosition.DockRight,LastDocumentsDocker))diff --git a/plugins/python/lastdocumentsdocker/lastdocumentsdocker.py b/plugins/python/lastdocumentsdocker/lastdocumentsdocker.pyindex a068735c6b..1350696158 100644--- a/plugins/python/lastdocumentsdocker/lastdocumentsdocker.py+++ b/plugins/python/lastdocumentsdocker/lastdocumentsdocker.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QWidget, QVBoxLayout, QListView, QPushButton+try:+ from PyQt6.QtWidgets import QWidget, QVBoxLayout, QListView, QPushButton+except:+ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QListView, QPushButtonimport kritafrom . import lastdocumentslistmodel@@ -17,7 +20,7 @@ class LastDocumentsDocker(krita.DockWidget):self.listModel = lastdocumentslistmodel.LastDocumentsListModel(self.devicePixelRatioF())self.listView.setModel(self.listModel)- self.listView.setFlow(QListView.LeftToRight)+ self.listView.setFlow(QListView.Flow.LeftToRight)self.layout.addWidget(self.listView)self.layout.addWidget(self.loadButton)diff --git a/plugins/python/lastdocumentsdocker/lastdocumentslistmodel.py b/plugins/python/lastdocumentsdocker/lastdocumentslistmodel.pyindex 0e42283042..2898a524a4 100644--- a/plugins/python/lastdocumentsdocker/lastdocumentslistmodel.py+++ b/plugins/python/lastdocumentsdocker/lastdocumentslistmodel.py@@ -1,7 +1,11 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtCore import QAbstractListModel, Qt, QSize-from PyQt5.QtGui import QImage+try:+ from PyQt6.QtCore import QAbstractListModel, Qt, QSize+ from PyQt6.QtGui import QImage+except:+ from PyQt5.QtCore import QAbstractListModel, Qt, QSize+ from PyQt5.QtGui import QImageimport kritaimport zipfilefrom pathlib import Path@@ -24,7 +28,7 @@ class LastDocumentsListModel(QAbstractListModel):if index.row() >= len(self.recentDocuments):return None- if role == Qt.DecorationRole:+ if role == Qt.ItemDataRole.DecorationRole:return self.recentDocuments[index.row()]else:return None@@ -33,7 +37,7 @@ class LastDocumentsListModel(QAbstractListModel):return len(self.recentDocuments)def headerData(self, section, orientation, role):- if orientation == Qt.Horizontal and role == Qt.DisplayRole:+ if orientation == Qt.Orientation.Horizontal and role == Qt.ItemDataRole.DisplayRole:return self.rootItem[section]return None@@ -60,9 +64,9 @@ class LastDocumentsListModel(QAbstractListModel):thumbSize = QSize(int(200*self.devicePixelRatioF), int(150*self.devicePixelRatioF))if thumbnail.width() <= thumbSize.width() or thumbnail.height() <= thumbSize.height():- thumbnail = thumbnail.scaled(thumbSize, Qt.KeepAspectRatio, Qt.FastTransformation)+ thumbnail = thumbnail.scaled(thumbSize, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.FastTransformation)else:- thumbnail = thumbnail.scaled(thumbSize, Qt.KeepAspectRatio, Qt.SmoothTransformation)+ thumbnail = thumbnail.scaled(thumbSize, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)thumbnail.setDevicePixelRatio(self.devicePixelRatioF)self.recentDocuments.append(thumbnail)self.modelReset.emit()diff --git a/plugins/python/mixer_slider_docker/color_slider.py b/plugins/python/mixer_slider_docker/color_slider.pyindex 584083e1eb..e7ac5ee199 100644--- a/plugins/python/mixer_slider_docker/color_slider.py+++ b/plugins/python/mixer_slider_docker/color_slider.py@@ -5,9 +5,14 @@SPDX-License-Identifier: GPL-3.0-or-later'''-from PyQt5.QtWidgets import QWidget-from PyQt5.QtGui import QPixmap, QPainter, QColor, QBrush, QPolygon-from PyQt5.QtCore import QPoint+try:+ from PyQt6.QtWidgets import QWidget+ from PyQt6.QtGui import QPixmap, QPainter, QColor, QBrush, QPolygon+ from PyQt6.QtCore import QPoint+except:+ from PyQt5.QtWidgets import QWidget+ from PyQt5.QtGui import QPixmap, QPainter, QColor, QBrush, QPolygon+ from PyQt5.QtCore import QPointfrom krita import ManagedColordiff --git a/plugins/python/mixer_slider_docker/mixer_slider_docker.py b/plugins/python/mixer_slider_docker/mixer_slider_docker.pyindex aebf901493..eddf09e32e 100644--- a/plugins/python/mixer_slider_docker/mixer_slider_docker.py+++ b/plugins/python/mixer_slider_docker/mixer_slider_docker.py@@ -5,8 +5,12 @@SPDX-License-Identifier: GPL-3.0-or-later'''-from PyQt5.QtGui import QColor-from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QPushButton+try:+ from PyQt6.QtGui import QColor+ from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QPushButton+except:+ from PyQt5.QtGui import QColor+ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QPushButtonfrom krita import Krita, DockWidget, ManagedColor, DockWidgetFactory, DockWidgetFactoryBase@@ -117,4 +121,4 @@ class MixerSliderDocker(DockWidget):def managedcolor_to_qcolor(self, managedcolor):return managedcolor.colorForCanvas(self.canvas())-Application.addDockWidgetFactory(DockWidgetFactory("mixer_slider_docker", DockWidgetFactoryBase.DockRight, MixerSliderDocker))+Application.addDockWidgetFactory(DockWidgetFactory("mixer_slider_docker", DockWidgetFactoryBase.DockPosition.DockRight, MixerSliderDocker))diff --git a/plugins/python/mixer_slider_docker/settings_dialog.py b/plugins/python/mixer_slider_docker/settings_dialog.pyindex 0396b6beeb..e33641c27c 100644--- a/plugins/python/mixer_slider_docker/settings_dialog.py+++ b/plugins/python/mixer_slider_docker/settings_dialog.py@@ -5,7 +5,10 @@SPDX-License-Identifier: GPL-3.0-or-later'''-from PyQt5.QtWidgets import QDialog+try:+ from PyQt6.QtWidgets import QDialog+except:+ from PyQt5.QtWidgets import QDialogclass SettingsDialog(QDialog):diff --git a/plugins/python/mixer_slider_docker/slider_line.py b/plugins/python/mixer_slider_docker/slider_line.pyindex 8e499e2366..c0fcec342e 100644--- a/plugins/python/mixer_slider_docker/slider_line.py+++ b/plugins/python/mixer_slider_docker/slider_line.py@@ -5,9 +5,14 @@SPDX-License-Identifier: GPL-3.0-or-later'''-from PyQt5.QtWidgets import QHBoxLayout, QWidget-from PyQt5.QtGui import QPixmap, QPainter-from PyQt5.Qt import pyqtSlot, pyqtSignal+try:+ from PyQt6.QtWidgets import QHBoxLayout, QWidget+ from PyQt6.QtGui import QPixmap, QPainter+ from PyQt6.QtCore import pyqtSlot, pyqtSignal+except:+ from PyQt5.QtWidgets import QHBoxLayout, QWidget+ from PyQt5.QtGui import QPixmap, QPainter+ from PyQt5.Qt import pyqtSlot, pyqtSignalfrom .color_slider import ColorSliderdiff --git a/plugins/python/mixer_slider_docker/ui_mixer_slider_docker.py b/plugins/python/mixer_slider_docker/ui_mixer_slider_docker.pyindex 0341097e7f..eaecaa6180 100644--- a/plugins/python/mixer_slider_docker/ui_mixer_slider_docker.py+++ b/plugins/python/mixer_slider_docker/ui_mixer_slider_docker.py@@ -5,9 +5,14 @@SPDX-License-Identifier: GPL-3.0-or-later'''-from PyQt5.QtWidgets import QDialogButtonBox, QLabel, QVBoxLayout, QHBoxLayout, QSpinBox-from PyQt5.QtGui import QIntValidator-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtWidgets import QDialogButtonBox, QLabel, QVBoxLayout, QHBoxLayout, QSpinBox+ from PyQt6.QtGui import QIntValidator+ from PyQt6.QtCore import Qt+except:+ from PyQt5.QtWidgets import QDialogButtonBox, QLabel, QVBoxLayout, QHBoxLayout, QSpinBox+ from PyQt5.QtGui import QIntValidator+ from PyQt5.QtCore import Qtimport kritafrom .settings_dialog import SettingsDialog@@ -26,8 +31,8 @@ class UIMixerSliderDocker(object):self.button_box.accepted.connect(self.main_dialog.accept)self.button_box.rejected.connect(self.main_dialog.reject)- self.button_box.setOrientation(Qt.Horizontal)- self.button_box.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ self.button_box.setOrientation(Qt.Orientation.Horizontal)+ self.button_box.setStandardButtons(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)def initialize(self, docker):self.docker = docker@@ -42,4 +47,4 @@ class UIMixerSliderDocker(object):self.main_dialog.show()self.main_dialog.activateWindow()- self.main_dialog.exec_()+ self.main_dialog.exec()diff --git a/plugins/python/mutator/mutator.py b/plugins/python/mutator/mutator.pyindex 21ca7df9d5..0f901e1572 100644--- a/plugins/python/mutator/mutator.py+++ b/plugins/python/mutator/mutator.py@@ -25,8 +25,13 @@ SOFTWARE.import sys, math, random, colorsys-from PyQt5.QtGui import QIcon-from PyQt5.QtWidgets import QWidget, QAction, QVBoxLayout, QSizePolicy, QPushButton+try:+ from PyQt6.QtGui import QIcon+ from PyQt6.QtWidgets import QWidget, QVBoxLayout, QSizePolicy, QPushButton+ from PyQt6.QtGui import QAction+except:+ from PyQt5.QtGui import QIcon+ from PyQt5.QtWidgets import QWidget, QAction, QVBoxLayout, QSizePolicy, QPushButtonfrom krita import Extension, DockWidget, DockWidgetFactory, SliderSpinBox, ManagedColor@@ -155,7 +160,7 @@ class MutatorDocker(DockWidget):body = QWidget(self)self.setWidget(body)body.setLayout(QVBoxLayout())- body.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))+ body.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred))# Create mutation amount sliders...mutationSettings = QWidget()@@ -282,4 +287,4 @@ class MutatorDocker(DockWidget):# Krita boilerplate.Krita.instance().addExtension(Mutator(Krita.instance()))-Krita.instance().addDockWidgetFactory(DockWidgetFactory("mutatorDocker", DockWidgetFactory.DockRight, MutatorDocker))\ No newline at end of file+Krita.instance().addDockWidgetFactory(DockWidgetFactory("mutatorDocker", DockWidgetFactory.DockPosition.DockRight, MutatorDocker))diff --git a/plugins/python/palette_docker/__init__.py b/plugins/python/palette_docker/__init__.pyindex b018907443..e6087712e6 100644--- a/plugins/python/palette_docker/__init__.py+++ b/plugins/python/palette_docker/__init__.py@@ -7,5 +7,5 @@ from .palette_docker import PaletteDockerApplication.addDockWidgetFactory(- DockWidgetFactory("palette_docker", DockWidgetFactoryBase.DockRight,+ DockWidgetFactory("palette_docker", DockWidgetFactoryBase.DockPosition.DockRight,PaletteDocker))diff --git a/plugins/python/palette_docker/palette_docker.py b/plugins/python/palette_docker/palette_docker.pyindex 60843439f0..6a618ffd91 100644--- a/plugins/python/palette_docker/palette_docker.py+++ b/plugins/python/palette_docker/palette_docker.py@@ -9,11 +9,19 @@# Importing the relevant dependencies:-from PyQt5.QtWidgets import (- QWidget, QVBoxLayout, QHBoxLayout, QComboBox, QAction, QTabWidget,- QLineEdit, QSpinBox, QDialogButtonBox, QToolButton, QDialog,- QPlainTextEdit, QCompleter, QMenu)-from PyQt5.Qt import Qt, pyqtSlot+try:+ from PyQt6.QtWidgets import (+ QWidget, QVBoxLayout, QHBoxLayout, QComboBox, QTabWidget,+ QLineEdit, QSpinBox, QDialogButtonBox, QToolButton, QDialog,+ QPlainTextEdit, QCompleter, QMenu)+ from PyQt6.QtCore import Qt, pyqtSlot+ from PyQt6.QtGui import QAction+except:+ from PyQt5.QtWidgets import (+ QWidget, QVBoxLayout, QHBoxLayout, QComboBox, QAction, QTabWidget,+ QLineEdit, QSpinBox, QDialogButtonBox, QToolButton, QDialog,+ QPlainTextEdit, QCompleter, QMenu)+ from PyQt5.Qt import Qt, pyqtSlotfrom krita import DockWidget, Palette, PaletteView# import the exporters@@ -157,9 +165,9 @@ class PaletteDocker(DockWidget):# if entry.spotColor() is True:# img = colorSquare.toImage()# circlePainter = QPainter()-# img.fill(self.colorComboBox.palette().color(QPalette.Base))+# img.fill(self.colorComboBox.palette().color(QPalette.ColorRole.Base))# circlePainter.begin(img)-# brush = QBrush(Qt.SolidPattern)+# brush = QBrush(Qt.BrushStyle.SolidPattern)# brush.setColor(color)# circlePainter.setBrush(brush)# circlePainter.pen().setWidth(0)@@ -174,11 +182,11 @@ class PaletteDocker(DockWidget):# self.colorList.append(name)# self.colorComboBox.addItem(QIcon(colorSquare), name)self.colorComboBox.setEditable(True)- self.colorComboBox.setInsertPolicy(QComboBox.NoInsert)+ self.colorComboBox.setInsertPolicy(QComboBox.InsertPolicy.NoInsert)self.colorComboBox.completer().setCompletionMode(- QCompleter.PopupCompletion)+ QCompleter.CompletionMode.PopupCompletion)self.colorComboBox.completer().setCaseSensitivity(False)- self.colorComboBox.completer().setFilterMode(Qt.MatchContains)+ self.colorComboBox.completer().setFilterMode(Qt.MatchFlag.MatchContains)def slot_get_color_from_combobox(self):if self.currentPalette is not None:@@ -227,12 +235,12 @@ class PaletteDocker(DockWidget):paletteComment = QPlainTextEdit()paletteComment.appendPlainText(self.currentPalette.comment())paletteWidget.layout().addWidget(paletteComment)- buttons = QDialogButtonBox(QDialogButtonBox.Ok)+ buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok)dialog.layout().addWidget(buttons)buttons.accepted.connect(dialog.accept)# buttons.rejected.connect(dialog.reject())- if dialog.exec_() == QDialog.Accepted:+ if dialog.exec() == QDialog.DialogCode.Accepted:Resource = Application.resources("palette")[self.cmb_palettes.currentText()]Resource.setName(paletteName.text())diff --git a/plugins/python/palette_docker/palette_exporter_gimppalette.py b/plugins/python/palette_docker/palette_exporter_gimppalette.pyindex 939b9289e5..7c1abd6a33 100644--- a/plugins/python/palette_docker/palette_exporter_gimppalette.py+++ b/plugins/python/palette_docker/palette_exporter_gimppalette.py@@ -9,7 +9,10 @@# Importing the relevant dependencies:-from PyQt5.QtWidgets import QFileDialog, QMessageBox+try:+ from PyQt6.QtWidgets import QFileDialog, QMessageBox+except:+ from PyQt5.QtWidgets import QFileDialog, QMessageBoxfrom krita import Palette@@ -27,7 +30,7 @@ class gimpPaletteExporter:done.setText(str(i18n("{input} has been exported to {output}.")).format(input=self.paletteName, output=self.fileName))- done.exec_()+ done.exec()passdef export(self):diff --git a/plugins/python/palette_docker/palette_exporter_inkscapeSVG.py b/plugins/python/palette_docker/palette_exporter_inkscapeSVG.pyindex 243eebbaa9..b2b7122585 100644--- a/plugins/python/palette_docker/palette_exporter_inkscapeSVG.py+++ b/plugins/python/palette_docker/palette_exporter_inkscapeSVG.py@@ -13,8 +13,12 @@# Importing the relevant dependencies:-from PyQt5.QtXml import QDomDocument-from PyQt5.QtWidgets import QFileDialog, QMessageBox+try:+ from PyQt6.QtXml import QDomDocument+ from PyQt6.QtWidgets import QFileDialog, QMessageBox+except:+ from PyQt5.QtXml import QDomDocument+ from PyQt5.QtWidgets import QFileDialog, QMessageBoxfrom krita import Palette@@ -32,7 +36,7 @@ class inkscapeSVGExporter:done.setText(str(i18n("{input} has been exported to {output}.")).format(input=self.paletteName, output=self.fileName))- done.exec_()+ done.exec()passdef export(self):diff --git a/plugins/python/photobash_images/__init__.py b/plugins/python/photobash_images/__init__.pyindex 3819584f5e..92d02a8e20 100644--- a/plugins/python/photobash_images/__init__.py+++ b/plugins/python/photobash_images/__init__.py@@ -18,4 +18,4 @@from krita import *from .photobash_images_docker import *-Krita.instance().addDockWidgetFactory(DockWidgetFactory("PhotobashDocker", DockWidgetFactoryBase.DockRight, PhotobashDocker))\ No newline at end of file+Krita.instance().addDockWidgetFactory(DockWidgetFactory("PhotobashDocker", DockWidgetFactoryBase.DockPosition.DockRight, PhotobashDocker))\ No newline at end of filediff --git a/plugins/python/photobash_images/photobash_images_docker.py b/plugins/python/photobash_images/photobash_images_docker.pyindex fb424fb795..03b7d5eb55 100644--- a/plugins/python/photobash_images/photobash_images_docker.py+++ b/plugins/python/photobash_images/photobash_images_docker.py@@ -19,7 +19,10 @@from krita import *import copyimport math-from PyQt5 import QtWidgets, QtCore, uic+try:+ from PyQt6 import QtWidgets, QtCore, uic+except:+ from PyQt5 import QtWidgets, QtCore, uicfrom .photobash_images_modulo import (Photobash_Display,Photobash_Button,@@ -94,8 +97,8 @@ class PhotobashDocker(DockWidget):]# Adjust Layouts- self.layout.imageWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored)- self.layout.middleWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ self.layout.imageWidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Ignored)+ self.layout.middleWidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)# setup connections for top elementsself.layout.filterTextEdit.textChanged.connect(self.textFilterChanged)@@ -188,7 +191,7 @@ class PhotobashDocker(DockWidget):self.updateImages()return- it = QDirIterator(self.directoryPath, QDirIterator.Subdirectories)+ it = QDirIterator(self.directoryPath, QDirIterator.IteratorFlag.Subdirectories)while(it.hasNext()):@@ -231,7 +234,7 @@ class PhotobashDocker(DockWidget):self.updateImages()def changedFitCanvas(self, state):- if state == Qt.Checked:+ if state == Qt.CheckState.Checked:self.fitCanvasChecked = TrueApplication.writeSetting(self.applicationName, self.fitCanvasSetting, "true")else:@@ -269,7 +272,7 @@ class PhotobashDocker(DockWidget):self.cachedImages.pop(removedPath)self.cachedPathImages = [path] + self.cachedPathImages- self.cachedImages[path] = QImage(path).scaled(200, 200, Qt.KeepAspectRatio, Qt.FastTransformation)+ self.cachedImages[path] = QImage(path).scaled(200, 200, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.FastTransformation)return self.cachedImages[path]@@ -344,11 +347,11 @@ class PhotobashDocker(DockWidget):# Scale Imageif self.fitCanvasChecked:- image = QImage(photoPath).scaled(int(doc.width() * scale), int(doc.height() * scale), Qt.KeepAspectRatio, Qt.SmoothTransformation)+ image = QImage(photoPath).scaled(int(doc.width() * scale), int(doc.height() * scale), Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)else:image = QImage(photoPath)# scale image- image = image.scaled(int(image.width() * scale), int(image.height() * scale), Qt.KeepAspectRatio, Qt.SmoothTransformation)+ image = image.scaled(int(image.width() * scale), int(image.height() * scale), Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)# MimeDatamimedata = QMimeData()@@ -406,12 +409,12 @@ class PhotobashDocker(DockWidget):def openPreview(self, path):self.imageWidget.setImage(path, self.getImage(path))- self.layout.imageWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)- self.layout.middleWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored)+ self.layout.imageWidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)+ self.layout.middleWidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Ignored)def closePreview(self):- self.layout.imageWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored)- self.layout.middleWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ self.layout.imageWidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Ignored)+ self.layout.middleWidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)def pinToFavourites(self, path):self.currPage = 0@@ -451,10 +454,10 @@ class PhotobashDocker(DockWidget):def changePath(self):fileDialog = QFileDialog(QWidget(self));- fileDialog.setFileMode(QFileDialog.DirectoryOnly);+ fileDialog.setFileMode(QFileDialog.FileMode.DirectoryOnly);if self.directoryPath == "":- dialogDirectory = QStandardPaths.writableLocation(QStandardPaths.PicturesLocation)+ dialogDirectory = QStandardPaths.writableLocation(QStandardPaths.StandardLocation.PicturesLocation)else:dialogDirectory = self.directoryPathself.directoryPath = fileDialog.getExistingDirectory(self.mainWidget, i18n("Change Directory for Images"), dialogDirectory)diff --git a/plugins/python/photobash_images/photobash_images_modulo.py b/plugins/python/photobash_images/photobash_images_modulo.pyindex 7a7b49d2db..5e5d5e9108 100644--- a/plugins/python/photobash_images/photobash_images_modulo.py+++ b/plugins/python/photobash_images/photobash_images_modulo.py@@ -16,7 +16,10 @@# along with this program. If not, see <http://www.gnu.org/licenses/>.from krita import *-from PyQt5 import QtWidgets, QtCore+try:+ from PyQt6 import QtWidgets, QtCore+except:+ from PyQt5 import QtWidgets, QtCoreDRAG_DELTA = 30TRIANGLE_SIZE = 20@@ -29,9 +32,9 @@ FAVOURITE_TRIANGLE = QPolygon([def customPaintEvent(instance, event):painter = QPainter(instance)- painter.setRenderHint(QtGui.QPainter.Antialiasing, True)- painter.setPen(QPen(Qt.black, 2, Qt.SolidLine))- painter.setBrush(QBrush(Qt.white, Qt.SolidPattern))+ painter.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing, True)+ painter.setPen(QPen(Qt.GlobalColor.black, 2, Qt.PenStyle.SolidLine))+ painter.setBrush(QBrush(Qt.GlobalColor.white, Qt.BrushStyle.SolidPattern))# Calculationstotal_width = event.rect().width()@@ -84,12 +87,12 @@ def customSetImage(instance, image):instance.update()def customMouseMoveEvent(self, event):- if event.modifiers() != QtCore.Qt.ShiftModifier and event.modifiers() != QtCore.Qt.AltModifier:+ if event.modifiers() != QtCore.Qt.KeyboardModifier.ShiftModifier and event.modifiers() != QtCore.Qt.KeyboardModifier.AltModifier:self.PREVIOUS_DRAG_X = Nonereturn# alt modifier is reserved for scrolling through- if self.PREVIOUS_DRAG_X and event.modifiers() == QtCore.Qt.AltModifier:+ if self.PREVIOUS_DRAG_X and event.modifiers() == QtCore.Qt.KeyboardModifier.AltModifier:if self.PREVIOUS_DRAG_X < event.x() - DRAG_DELTA:self.SIGNAL_WUP.emit(0)self.PREVIOUS_DRAG_X = event.x()@@ -115,11 +118,11 @@ def customMouseMoveEvent(self, event):# only scale to document if it existsif self.fitCanvasChecked and not doc is None:- fullImage = QImage(self.path).scaled(doc.width() * scale, doc.height() * scale, Qt.KeepAspectRatio, Qt.SmoothTransformation)+ fullImage = QImage(self.path).scaled(doc.width() * scale, doc.height() * scale, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)else:fullImage = QImage(self.path)# scale image, now knowing the bounds- fullImage = fullImage.scaled(fullImage.width() * scale, fullImage.height() * scale, Qt.KeepAspectRatio, Qt.SmoothTransformation)+ fullImage = fullImage.scaled(fullImage.width() * scale, fullImage.height() * scale, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)fullPixmap = QPixmap(50, 50).fromImage(fullImage)mimedata.setImageData(fullPixmap)@@ -132,7 +135,7 @@ def customMouseMoveEvent(self, event):drag.setMimeData(mimedata)drag.setPixmap(self.pixmap)drag.setHotSpot(QPoint(self.qimage.width() / 2, self.qimage.height() / 2))- drag.exec_(Qt.CopyAction)+ drag.exec(Qt.DropAction.CopyAction)class Photobash_Display(QWidget):SIGNAL_HOVER = QtCore.pyqtSignal(str)@@ -154,7 +157,7 @@ class Photobash_Display(QWidget):self.SIGNAL_HOVER.emit("None")def mousePressEvent(self, event):- if (event.modifiers() == QtCore.Qt.NoModifier and event.buttons() == QtCore.Qt.LeftButton):+ if (event.modifiers() == QtCore.Qt.KeyboardModifier.NoModifier and event.buttons() == QtCore.Qt.MouseButton.LeftButton):self.SIGNAL_CLOSE.emit(0)def mouseMoveEvent(self, event):@@ -221,9 +224,9 @@ class Photobash_Button(QWidget):self.SIGNAL_HOVER.emit("None")def mousePressEvent(self, event):- if event.modifiers() == QtCore.Qt.NoModifier and event.buttons() == QtCore.Qt.LeftButton:+ if event.modifiers() == QtCore.Qt.KeyboardModifier.NoModifier and event.buttons() == QtCore.Qt.MouseButton.LeftButton:self.SIGNAL_LMB.emit(self.number)- if event.modifiers() == QtCore.Qt.AltModifier:+ if event.modifiers() == QtCore.Qt.KeyboardModifier.AltModifier:self.PREVIOUS_DRAG_X = event.x()def mouseDoubleClickEvent(self, event):@@ -250,11 +253,11 @@ class Photobash_Button(QWidget):cmenuOpenNew = cmenu.addAction("Open as New Document")cmenuReference = cmenu.addAction("Place as Reference")- background = qApp.palette().color(QPalette.Window).name().split("#")[1]+ background = QApplication().instance().palette().color(QPalette.ColorRole.Window).name().split("#")[1]cmenuStyleSheet = f"""QMenu {{ background-color: #AA{background}; border: 1px solid #{background}; }}"""cmenu.setStyleSheet(cmenuStyleSheet)- action = cmenu.exec_(self.mapToGlobal(event.pos()))+ action = cmenu.exec(self.mapToGlobal(event.pos()))if action == cmenuDisplay:self.SIGNAL_PREVIEW.emit(self.path)if action == cmenuFavourite:diff --git a/plugins/python/plugin_importer/plugin_importer_extension.py b/plugins/python/plugin_importer/plugin_importer_extension.pyindex bbb9f428db..f1d5d36272 100644--- a/plugins/python/plugin_importer/plugin_importer_extension.py+++ b/plugins/python/plugin_importer/plugin_importer_extension.py@@ -10,8 +10,12 @@ import tempfileimport krita-from PyQt5.QtCore import QStandardPaths-from PyQt5.QtWidgets import QFileDialog, QMessageBox, QInputDialog+try:+ from PyQt6.QtCore import QStandardPaths+ from PyQt6.QtWidgets import QFileDialog, QMessageBox, QInputDialog+except:+ from PyQt5.QtCore import QStandardPaths+ from PyQt5.QtWidgets import QFileDialog, QMessageBox, QInputDialogfrom .plugin_importer import PluginImporter, PluginImportErrorfrom .plugin_downloader import download_plugin, PluginDownloadError@@ -44,8 +48,8 @@ class PluginImporterExtension(krita.Extension):i18n('Overwrite Plugin'),i18n('The plugin "%s" already exists. Overwrite it?') % (plugin['ui_name']),- QMessageBox.Yes | QMessageBox.No)- return reply == QMessageBox.Yes+ QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)+ return reply == QMessageBox.StandardButton.Yesdef confirm_activate(self, plugins):txt = [@@ -67,8 +71,8 @@ class PluginImporterExtension(krita.Extension):self.parent.activeWindow().qwindow(),i18n('Activate Plugins?'),('\n').join(txt),- QMessageBox.Yes | QMessageBox.No)- return reply == QMessageBox.Yes+ QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)+ return reply == QMessageBox.StandardButton.Yesdef display_errors(self, error):msg = '<p>%s</p><pre>%s</pre>' % (diff --git a/plugins/python/quick_settings_docker/__init__.py b/plugins/python/quick_settings_docker/__init__.pyindex 00ee942058..dd256be55c 100644--- a/plugins/python/quick_settings_docker/__init__.py+++ b/plugins/python/quick_settings_docker/__init__.py@@ -8,5 +8,5 @@ from .quick_settings_docker import QuickSettingsDockerApplication.addDockWidgetFactory(DockWidgetFactory("quick_settings_docker",- DockWidgetFactoryBase.DockRight,+ DockWidgetFactoryBase.DockPosition.DockRight,QuickSettingsDocker))diff --git a/plugins/python/quick_settings_docker/quick_settings_docker.py b/plugins/python/quick_settings_docker/quick_settings_docker.pyindex b27d4700ce..dbda8e00f8 100644--- a/plugins/python/quick_settings_docker/quick_settings_docker.py+++ b/plugins/python/quick_settings_docker/quick_settings_docker.py@@ -10,10 +10,16 @@ similar dockers in other drawing programs.'''# Importing the relevant dependencies:-from PyQt5.QtCore import pyqtSlot, Qt, QPointF-from PyQt5.QtGui import (QStandardItem, QStandardItemModel, QPainter, QPalette,- QPixmap, QImage, QBrush, QPen, QIcon)-from PyQt5.QtWidgets import QWidget, QTabWidget, QListView, QVBoxLayout+try:+ from PyQt6.QtCore import pyqtSlot, Qt, QPointF+ from PyQt6.QtGui import (QStandardItem, QStandardItemModel, QPainter, QPalette,+ QPixmap, QImage, QBrush, QPen, QIcon)+ from PyQt6.QtWidgets import QWidget, QTabWidget, QListView, QVBoxLayout+except:+ from PyQt5.QtCore import pyqtSlot, Qt, QPointF+ from PyQt5.QtGui import (QStandardItem, QStandardItemModel, QPainter, QPalette,+ QPixmap, QImage, QBrush, QPen, QIcon)+ from PyQt5.QtWidgets import QWidget, QTabWidget, QListView, QVBoxLayoutfrom krita import DockWidget@@ -30,25 +36,25 @@ class QuickSettingsDocker(DockWidget):tabWidget = QTabWidget()self.brushSizeTableView = QListView()- self.brushSizeTableView.setViewMode(QListView.IconMode)- self.brushSizeTableView.setMovement(QListView.Static)- self.brushSizeTableView.setResizeMode(QListView.Adjust)+ self.brushSizeTableView.setViewMode(QListView.ViewMode.IconMode)+ self.brushSizeTableView.setMovement(QListView.Movement.Static)+ self.brushSizeTableView.setResizeMode(QListView.ResizeMode.Adjust)self.brushSizeTableView.setUniformItemSizes(True)- self.brushSizeTableView.setSelectionMode(QListView.SingleSelection)+ self.brushSizeTableView.setSelectionMode(QListView.SelectionMode.SingleSelection)self.brushOpacityTableView = QListView()- self.brushOpacityTableView.setViewMode(QListView.IconMode)- self.brushOpacityTableView.setMovement(QListView.Static)- self.brushOpacityTableView.setResizeMode(QListView.Adjust)+ self.brushOpacityTableView.setViewMode(QListView.ViewMode.IconMode)+ self.brushOpacityTableView.setMovement(QListView.Movement.Static)+ self.brushOpacityTableView.setResizeMode(QListView.ResizeMode.Adjust)self.brushOpacityTableView.setUniformItemSizes(True)- self.brushOpacityTableView.setSelectionMode(QListView.SingleSelection)+ self.brushOpacityTableView.setSelectionMode(QListView.SelectionMode.SingleSelection)self.brushFlowTableView = QListView()- self.brushFlowTableView.setViewMode(QListView.IconMode)- self.brushFlowTableView.setMovement(QListView.Static)- self.brushFlowTableView.setResizeMode(QListView.Adjust)+ self.brushFlowTableView.setViewMode(QListView.ViewMode.IconMode)+ self.brushFlowTableView.setMovement(QListView.Movement.Static)+ self.brushFlowTableView.setResizeMode(QListView.ResizeMode.Adjust)self.brushFlowTableView.setUniformItemSizes(True)- self.brushFlowTableView.setSelectionMode(QListView.SingleSelection)+ self.brushFlowTableView.setSelectionMode(QListView.SelectionMode.SingleSelection)tabWidget.addTab(self.brushSizeTableView, i18n("Size"))tabWidget.addTab(self.brushOpacityTableView, i18n("Opacity"))@@ -102,15 +108,15 @@ class QuickSettingsDocker(DockWidget):item.setText(str(self.sizesList[s])+" px")# And from here on we'll make an icon.brushImage = QPixmap(64, 64)- img = QImage(64, 64, QImage.Format_RGBA8888)+ img = QImage(64, 64, QImage.Format.Format_RGBA8888)circlePainter = QPainter()- img.fill(Qt.transparent)+ img.fill(Qt.GlobalColor.transparent)circlePainter.begin(img)- brush = QBrush(Qt.SolidPattern)+ brush = QBrush(Qt.BrushStyle.SolidPattern)brush.setColor(- self.brushSizeTableView.palette().color(QPalette.Text))+ self.brushSizeTableView.palette().color(QPalette.ColorRole.Text))circlePainter.setBrush(brush)- circlePainter.setPen(QPen(QBrush(Qt.transparent), 0))+ circlePainter.setPen(QPen(QBrush(Qt.GlobalColor.transparent), 0))brushSize = max(min(self.sizesList[s], 64), 1)brushSize = brushSize * 0.5circlePainter.drawEllipse(QPointF(32, 32), brushSize, brushSize)@@ -133,15 +139,15 @@ class QuickSettingsDocker(DockWidget):item.setDragEnabled(False)item.setText(str(self.opacityList[s])+" %")brushImage = QPixmap(64, 64)- img = QImage(64, 64, QImage.Format_RGBA8888)+ img = QImage(64, 64, QImage.Format.Format_RGBA8888)circlePainter = QPainter()- img.fill(Qt.transparent)+ img.fill(Qt.GlobalColor.transparent)circlePainter.begin(img)- brush = QBrush(Qt.SolidPattern)+ brush = QBrush(Qt.BrushStyle.SolidPattern)brush.setColor(- self.brushSizeTableView.palette().color(QPalette.Text))+ self.brushSizeTableView.palette().color(QPalette.ColorRole.Text))circlePainter.setBrush(brush)- circlePainter.setPen(QPen(QBrush(Qt.transparent), 0))+ circlePainter.setPen(QPen(QBrush(Qt.GlobalColor.transparent), 0))circlePainter.setOpacity(float(self.opacityList[s]) / 100.0)circlePainter.drawEllipse(QPointF(32, 32), 32, 32)circlePainter.end()diff --git a/plugins/python/scripter/resources_rc.py b/plugins/python/scripter/resources_rc.pyindex 3b603b1ade..0c6e353eee 100644--- a/plugins/python/scripter/resources_rc.py+++ b/plugins/python/scripter/resources_rc.py@@ -6,7 +6,10 @@## WARNING! All changes made in this file will be lost!-from PyQt5 import QtCore+try:+ from PyQt6 import QtCore+except:+ from PyQt5 import QtCoreqt_resource_data = b"\\x00\x00\x03\x58\diff --git a/plugins/python/scripter/scripter.py b/plugins/python/scripter/scripter.pyindex c4dc128649..301e8a0df2 100644--- a/plugins/python/scripter/scripter.py+++ b/plugins/python/scripter/scripter.py@@ -3,7 +3,10 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtCore import QSettings, QStandardPaths+try:+ from PyQt6.QtCore import QSettings, QStandardPaths+except:+ from PyQt5.QtCore import QSettings, QStandardPathsfrom krita import Krita, Extensionfrom . import uicontroller, documentcontroller, debugcontroller@@ -21,8 +24,8 @@ class ScripterExtension(Extension):action.triggered.connect(self.initialize)def initialize(self):- configPath = QStandardPaths.writableLocation(QStandardPaths.GenericConfigLocation)- self.settings = QSettings(configPath + '/krita-scripterrc', QSettings.IniFormat)+ configPath = QStandardPaths.writableLocation(QStandardPaths.StandardLocation.GenericConfigLocation)+ self.settings = QSettings(configPath + '/krita-scripterrc', QSettings.Format.IniFormat)self.uicontroller = uicontroller.UIController()self.documentcontroller = documentcontroller.DocumentController()self.debugcontroller = debugcontroller.DebugController(self)diff --git a/plugins/python/scripter/scripterdialog.py b/plugins/python/scripter/scripterdialog.pyindex bbe0c18739..28b5124a10 100644--- a/plugins/python/scripter/scripterdialog.py+++ b/plugins/python/scripter/scripterdialog.py@@ -3,15 +3,19 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QDialog-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtWidgets import QDialog+ from PyQt6.QtCore import Qt+except:+ from PyQt5.QtWidgets import QDialog+ from PyQt5.QtCore import Qtclass ScripterDialog(QDialog):def __init__(self, uicontroller, parent=None):super(ScripterDialog, self).__init__(parent)- self.setAttribute(Qt.WA_QuitOnClose, False)+ self.setAttribute(Qt.WidgetAttribute.WA_QuitOnClose, False)self.uicontroller = uicontrollerdef closeEvent(self, event):diff --git a/plugins/python/scripter/test.py b/plugins/python/scripter/test.pyindex 21c206d5a7..df0051ee8d 100644--- a/plugins/python/scripter/test.py+++ b/plugins/python/scripter/test.py@@ -5,15 +5,20 @@ SPDX-License-Identifier: GPL-2.0-or-later"""# editor.py-from PyQt5.QtCore import *-from PyQt5.QtGui import *-from PyQt5.QtWidgets import *+try:+ from PyQt6.QtCore import *+ from PyQt6.QtGui import *+ from PyQt6.QtWidgets import *+except:+ from PyQt5.QtCore import *+ from PyQt5.QtGui import *+ from PyQt5.QtWidgets import *import syntaxapp = QApplication([])editor = QPlainTextEdit()-f = QFont("monospace", 10, QFont.Normal)+f = QFont("monospace", 10, QFont.Weight.Normal)f.setFixedPitch(True)editor.document().setDefaultFont(f)highlight = syntax.PythonHighlighter(editor.document())@@ -26,4 +31,4 @@ editor.show()# infile = open('syntax.py', 'r')# editor.setPlainText(infile.read())-app.exec_()+app.exec()diff --git a/plugins/python/scripter/ui_scripter/actions/closeaction/closeaction.py b/plugins/python/scripter/ui_scripter/actions/closeaction/closeaction.pyindex fdf81422c0..3b2645f464 100644--- a/plugins/python/scripter/ui_scripter/actions/closeaction/closeaction.py+++ b/plugins/python/scripter/ui_scripter/actions/closeaction/closeaction.py@@ -3,9 +3,14 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction, QMessageBox-from PyQt5.QtGui import QKeySequence-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtWidgets import QMessageBox+ from PyQt6.QtGui import QKeySequence, QAction+ from PyQt6.QtCore import Qt+except:+ from PyQt5.QtWidgets import QAction, QMessageBox+ from PyQt5.QtGui import QKeySequence+ from PyQt5.QtCore import Qtimport krita@@ -19,7 +24,7 @@ class CloseAction(QAction):self.setText(i18n("Close"))self.setObjectName('close')- self.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q))+ self.setShortcut(QKeySequence(Qt.Key.Key_Control + Qt.Key.Key_Q))@propertydef parent(self):@@ -29,14 +34,14 @@ class CloseAction(QAction):msgBox = QMessageBox(self.scripter.uicontroller.mainWidget)msgBox.setInformativeText(i18n("Do you want to save the current document?"))- msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)- msgBox.setDefaultButton(QMessageBox.Save)+ msgBox.setStandardButtons(QMessageBox.StandardButton.Save | QMessageBox.StandardButton.Discard | QMessageBox.StandardButton.Cancel)+ msgBox.setDefaultButton(QMessageBox.StandardButton.Save)- ret = msgBox.exec_()+ ret = msgBox.exec()- if ret == QMessageBox.Cancel:+ if ret == QMessageBox.StandardButton.Cancel:return- if ret == QMessageBox.Save:+ if ret == QMessageBox.StandardButton.Save:if not self.scripter.uicontroller.invokeAction('save'):returndiff --git a/plugins/python/scripter/ui_scripter/actions/debugaction/debugaction.py b/plugins/python/scripter/ui_scripter/actions/debugaction/debugaction.pyindex e77e80fa15..1bcee8185f 100644--- a/plugins/python/scripter/ui_scripter/actions/debugaction/debugaction.py+++ b/plugins/python/scripter/ui_scripter/actions/debugaction/debugaction.py@@ -3,10 +3,15 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction-from PyQt5.QtGui import QIcon, QKeySequence-from scripter import resources_rc-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtGui import QIcon, QKeySequence, QAction+ from scripter import resources_rc+ from PyQt6.QtCore import Qt+except:+ from PyQt5.QtWidgets import QAction+ from PyQt5.QtGui import QIcon, QKeySequence+ from scripter import resources_rc+ from PyQt5.QtCore import Qtfrom .... import utilsimport krita@@ -23,7 +28,7 @@ class DebugAction(QAction):self.setToolTip(i18n("Debug Ctrl+D"))self.setIcon(utils.getThemedIcon(":/icons/debug.svg"))- self.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_D))+ self.setShortcut(QKeySequence(Qt.Key.Key_Control + Qt.Key.Key_D))@propertydef parent(self):diff --git a/plugins/python/scripter/ui_scripter/actions/newaction/newaction.py b/plugins/python/scripter/ui_scripter/actions/newaction/newaction.pyindex 03832f9804..958568c6ac 100644--- a/plugins/python/scripter/ui_scripter/actions/newaction/newaction.py+++ b/plugins/python/scripter/ui_scripter/actions/newaction/newaction.py@@ -3,9 +3,14 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction, QMessageBox-from PyQt5.QtGui import QKeySequence-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtWidgets import QMessageBox+ from PyQt6.QtGui import QKeySequence, QAction+ from PyQt6.QtCore import Qt+except:+ from PyQt5.QtWidgets import QAction, QMessageBox+ from PyQt5.QtGui import QKeySequence+ from PyQt5.QtCore import Qtimport krita@@ -19,7 +24,7 @@ class NewAction(QAction):self.setText(i18n("New"))self.setObjectName('new')- self.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_N))+ self.setShortcut(QKeySequence(Qt.Key.Key_Control + Qt.Key.Key_N))@propertydef parent(self):@@ -30,14 +35,14 @@ class NewAction(QAction):msgBox.setText(i18n("The document has been modified."))msgBox.setInformativeText(i18n("Do you want to save your changes?"))- msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)- msgBox.setDefaultButton(QMessageBox.Save)+ msgBox.setStandardButtons(QMessageBox.StandardButton.Save | QMessageBox.StandardButton.Discard | QMessageBox.StandardButton.Cancel)+ msgBox.setDefaultButton(QMessageBox.StandardButton.Save)- ret = msgBox.exec_()+ ret = msgBox.exec()- if ret == QMessageBox.Cancel:+ if ret == QMessageBox.StandardButton.Cancel:return- if ret == QMessageBox.Save:+ if ret == QMessageBox.StandardButton.Save:self.scripter.uicontroller.invokeAction('save')self.scripter.documentcontroller.clearActiveDocument()diff --git a/plugins/python/scripter/ui_scripter/actions/openaction/openaction.py b/plugins/python/scripter/ui_scripter/actions/openaction/openaction.pyindex f4ed7981a0..9daad8ceb8 100644--- a/plugins/python/scripter/ui_scripter/actions/openaction/openaction.py+++ b/plugins/python/scripter/ui_scripter/actions/openaction/openaction.py@@ -3,9 +3,14 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction, QFileDialog, QMessageBox-from PyQt5.QtGui import QKeySequence-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtWidgets import QFileDialog, QMessageBox+ from PyQt6.QtGui import QKeySequence, QAction+ from PyQt6.QtCore import Qt+except:+ from PyQt5.QtWidgets import QAction, QFileDialog, QMessageBox+ from PyQt5.QtGui import QKeySequence+ from PyQt5.QtCore import Qtimport kritaimport os@@ -21,7 +26,7 @@ class OpenAction(QAction):self.setText(i18n("Open"))self.setObjectName('open')- self.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_O))+ self.setShortcut(QKeySequence(Qt.Key.Key_Control + Qt.Key.Key_O))@propertydef parent(self):@@ -31,7 +36,7 @@ class OpenAction(QAction):dialog = QFileDialog(self.scripter.uicontroller.mainWidget)dialog.setNameFilter(i18n("Python Files (*.py)"))- if dialog.exec_():+ if dialog.exec():try:selectedFile = dialog.selectedFiles()[0]_, fileExtension = os.path.splitext(selectedFile)diff --git a/plugins/python/scripter/ui_scripter/actions/reloadaction/reloadaction.py b/plugins/python/scripter/ui_scripter/actions/reloadaction/reloadaction.pyindex d71dfc5197..6f53250d59 100644--- a/plugins/python/scripter/ui_scripter/actions/reloadaction/reloadaction.py+++ b/plugins/python/scripter/ui_scripter/actions/reloadaction/reloadaction.py@@ -3,9 +3,14 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction, QMessageBox-from PyQt5.QtGui import QIcon, QKeySequence-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtWidgets import QMessageBox+ from PyQt6.QtGui import QIcon, QKeySequence, QAction+ from PyQt6.QtCore import Qt+except:+ from PyQt5.QtWidgets import QAction, QMessageBox+ from PyQt5.QtGui import QIcon, QKeySequence+ from PyQt5.QtCore import Qtfrom .... import utilsimport krita@@ -21,7 +26,7 @@ class ReloadAction(QAction):self.setText(i18n("Reload File"))self.setObjectName('reloadfile')- self.setShortcut(QKeySequence(Qt.ALT + Qt.Key_R))+ self.setShortcut(QKeySequence(Qt.Key.Key_Alt+ Qt.Key.Key_R))self.setToolTip(i18n('Reload File Alt+R'))self.setIcon(utils.getThemedIcon(':/icons/reload_script.svg'))diff --git a/plugins/python/scripter/ui_scripter/actions/runaction/docwrapper.py b/plugins/python/scripter/ui_scripter/actions/runaction/docwrapper.pyindex ef59b1fce2..26440e4d13 100644--- a/plugins/python/scripter/ui_scripter/actions/runaction/docwrapper.py+++ b/plugins/python/scripter/ui_scripter/actions/runaction/docwrapper.py@@ -3,7 +3,10 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtGui import QTextCursor+try:+ from PyQt6.QtGui import QTextCursor+except:+ from PyQt5.QtGui import QTextCursorclass DocWrapper(object):@@ -14,5 +17,5 @@ class DocWrapper(object):def write(self, text, view=None):cursor = QTextCursor(self.textdocument)cursor.clearSelection()- cursor.movePosition(QTextCursor.End)+ cursor.movePosition(QTextCursor.MoveOperation.End)cursor.insertText(text)diff --git a/plugins/python/scripter/ui_scripter/actions/runaction/runaction.py b/plugins/python/scripter/ui_scripter/actions/runaction/runaction.pyindex aa848404e9..d3f011fdc6 100644--- a/plugins/python/scripter/ui_scripter/actions/runaction/runaction.py+++ b/plugins/python/scripter/ui_scripter/actions/runaction/runaction.py@@ -3,9 +3,13 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction-from PyQt5.QtGui import QIcon, QKeySequence-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtGui import QIcon, QKeySequence, QAction+ from PyQt6.QtCore import Qt+except:+ from PyQt5.QtWidgets import QAction+ from PyQt5.QtGui import QIcon, QKeySequence+ from PyQt5.QtCore import Qtimport sysimport tracebackimport inspect@@ -38,7 +42,7 @@ class RunAction(QAction):self.setText(i18n("Run"))self.setToolTip(i18n('Run Ctrl+R'))- self.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_R))+ self.setShortcut(QKeySequence(Qt.Key.Key_Control + Qt.Key.Key_R))self.setIcon(utils.getThemedIcon(':/icons/run.svg'))@propertydiff --git a/plugins/python/scripter/ui_scripter/actions/saveaction/saveaction.py b/plugins/python/scripter/ui_scripter/actions/saveaction/saveaction.pyindex 73ccd9bbcf..5d1780e090 100644--- a/plugins/python/scripter/ui_scripter/actions/saveaction/saveaction.py+++ b/plugins/python/scripter/ui_scripter/actions/saveaction/saveaction.py@@ -3,9 +3,14 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction, QFileDialog-from PyQt5.QtGui import QKeySequence-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtWidgets import QFileDialog+ from PyQt6.QtGui import QKeySequence, QAction+ from PyQt6.QtCore import Qt+except:+ from PyQt5.QtWidgets import QAction, QFileDialog+ from PyQt5.QtGui import QKeySequence+ from PyQt5.QtCore import Qtimport krita@@ -20,7 +25,7 @@ class SaveAction(QAction):self.setText(i18n("Save"))self.setObjectName('save')- self.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_S))+ self.setShortcut(QKeySequence(Qt.Key.Key_Control + Qt.Key.Key_S))@propertydef parent(self):diff --git a/plugins/python/scripter/ui_scripter/actions/saveasaction/saveasaction.py b/plugins/python/scripter/ui_scripter/actions/saveasaction/saveasaction.pyindex fe6e2648f1..79ea2f9d7e 100644--- a/plugins/python/scripter/ui_scripter/actions/saveasaction/saveasaction.py+++ b/plugins/python/scripter/ui_scripter/actions/saveasaction/saveasaction.py@@ -3,9 +3,14 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction, QFileDialog-from PyQt5.QtGui import QKeySequence-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtWidgets import QFileDialog+ from PyQt6.QtGui import QKeySequence, QAction+ from PyQt6.QtCore import Qt+except:+ from PyQt5.QtWidgets import QAction, QFileDialog+ from PyQt5.QtGui import QKeySequence+ from PyQt5.QtCore import Qtimport krita@@ -20,7 +25,7 @@ class SaveAsAction(QAction):self.setText(i18n("Save As"))self.setObjectName('saveas')- self.setShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_S))+ self.setShortcut(QKeySequence(Qt.Key.Key_Control + Qt.Key.Key_Shift + Qt.Key.Key_S))@propertydef parent(self):diff --git a/plugins/python/scripter/ui_scripter/actions/settingsaction/fontscombobox.py b/plugins/python/scripter/ui_scripter/actions/settingsaction/fontscombobox.pyindex 0811efd458..87eca2680a 100644--- a/plugins/python/scripter/ui_scripter/actions/settingsaction/fontscombobox.py+++ b/plugins/python/scripter/ui_scripter/actions/settingsaction/fontscombobox.py@@ -3,9 +3,14 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QComboBox, QCompleter-from PyQt5.QtGui import QFontDatabase-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtWidgets import QComboBox, QCompleter+ from PyQt6.QtGui import QFontDatabase+ from PyQt6.QtCore import Qt, QLibraryInfo+except:+ from PyQt5.QtWidgets import QComboBox, QCompleter+ from PyQt5.QtGui import QFontDatabase+ from PyQt5.QtCore import Qt, QLibraryInfoclass FontsComboBox(QComboBox):@@ -15,15 +20,16 @@ class FontsComboBox(QComboBox):self.editor = editor- _fontDataBase = QFontDatabase()-- self.addItems(_fontDataBase.families())+ if QLibraryInfo.version().majorVersion() == 6: # PyQt6+ self.addItems(QFontDatabase.families())+ else: # PyQt5+ self.addItems(QFontDatabase().families())self.setCurrentIndex(self.findText(self.editor.font))# Style sheet to set false on combobox-popupself.setMaxVisibleItems(10)self.setEditable(True)- self.setInsertPolicy(QComboBox.NoInsert)+ self.setInsertPolicy(QComboBox.InsertPolicy.NoInsert)self.currentIndexChanged.connect(self._currentIndexChanged)def _currentIndexChanged(self, index):diff --git a/plugins/python/scripter/ui_scripter/actions/settingsaction/settingsaction.py b/plugins/python/scripter/ui_scripter/actions/settingsaction/settingsaction.pyindex 7da0b46e99..b459fc0137 100644--- a/plugins/python/scripter/ui_scripter/actions/settingsaction/settingsaction.py+++ b/plugins/python/scripter/ui_scripter/actions/settingsaction/settingsaction.py@@ -3,8 +3,12 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction-from PyQt5.QtCore import Qt+try:+ from PyQt6.QtGui import QAction+ from PyQt6.QtCore import Qt+except:+ from PyQt5.QtWidgets import QAction+ from PyQt5.QtCore import Qtfrom . import settingsdialogimport krita@@ -18,7 +22,7 @@ class SettingsAction(QAction):self.triggered.connect(self.openSettings)self.settingsDialog = settingsdialog.SettingsDialog(self.scripter)- self.settingsDialog.setWindowModality(Qt.WindowModal)+ self.settingsDialog.setWindowModality(Qt.WindowModality.WindowModal)self.settingsDialog.setFixedSize(400, 250)self.setText(i18n("Settings"))@@ -29,7 +33,7 @@ class SettingsAction(QAction):def openSettings(self):self.settingsDialog.show()- self.settingsDialog.exec_()+ self.settingsDialog.exec()def readSettings(self):self.settingsDialog.readSettings(self.scripter.settings)diff --git a/plugins/python/scripter/ui_scripter/actions/settingsaction/settingsdialog.py b/plugins/python/scripter/ui_scripter/actions/settingsaction/settingsdialog.pyindex c79f057872..70b8227625 100644--- a/plugins/python/scripter/ui_scripter/actions/settingsaction/settingsdialog.py+++ b/plugins/python/scripter/ui_scripter/actions/settingsaction/settingsdialog.py@@ -3,7 +3,10 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QDialog, QFormLayout+try:+ from PyQt6.QtWidgets import QDialog, QFormLayout+except:+ from PyQt5.QtWidgets import QDialog, QFormLayoutfrom . import syntaxstylescombobox, fontscomboboximport krita@@ -21,10 +24,10 @@ class SettingsDialog(QDialog):def readSettings(self, settings):for index in range(self.mainLayout.rowCount()):- widget = self.mainLayout.itemAt(index, QFormLayout.FieldRole).widget()+ widget = self.mainLayout.itemAt(index, QFormLayout.ItemRole.FieldRole).widget()widget.readSettings(settings)def writeSettings(self, settings):for index in range(self.mainLayout.rowCount()):- widget = self.mainLayout.itemAt(index, QFormLayout.FieldRole).widget()+ widget = self.mainLayout.itemAt(index, QFormLayout.ItemRole.FieldRole).widget()widget.writeSettings(settings)diff --git a/plugins/python/scripter/ui_scripter/actions/settingsaction/syntaxstylescombobox.py b/plugins/python/scripter/ui_scripter/actions/settingsaction/syntaxstylescombobox.pyindex d9e1e8b3a8..de04f35ba0 100644--- a/plugins/python/scripter/ui_scripter/actions/settingsaction/syntaxstylescombobox.py+++ b/plugins/python/scripter/ui_scripter/actions/settingsaction/syntaxstylescombobox.py@@ -3,8 +3,12 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QComboBox-from PyQt5.QtGui import QPalette+try:+ from PyQt6.QtWidgets import QComboBox+ from PyQt6.QtGui import QPalette+except:+ from PyQt5.QtWidgets import QComboBox+ from PyQt5.QtGui import QPalettefrom scripter.ui_scripter.syntax import syntaxstyles@@ -31,8 +35,8 @@ class SyntaxStylesComboBox(QComboBox):self.highlight.setSyntaxStyle(syntaxStyle)self.highlight.rehighlight()p = self.editor.palette()- p.setColor(QPalette.Base, syntaxStyle['background'].foreground().color())- p.setColor(QPalette.Text, syntaxStyle['foreground'].foreground().color())+ p.setColor(QPalette.ColorRole.Base, syntaxStyle['background'].foreground().color())+ p.setColor(QPalette.ColorRole.Text, syntaxStyle['foreground'].foreground().color())self.editor.setPalette(p)self.editor.highlightCurrentLine()diff --git a/plugins/python/scripter/ui_scripter/editor/debugarea.py b/plugins/python/scripter/ui_scripter/editor/debugarea.pyindex ca162666a0..5ad0e3f747 100644--- a/plugins/python/scripter/ui_scripter/editor/debugarea.py+++ b/plugins/python/scripter/ui_scripter/editor/debugarea.py@@ -3,8 +3,12 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QWidget-from PyQt5.QtCore import QSize+try:+ from PyQt6.QtWidgets import QWidget+ from PyQt6.QtCore import QSize+except:+ from PyQt5.QtWidgets import QWidget+ from PyQt5.QtCore import QSizeclass DebugArea(QWidget):diff --git a/plugins/python/scripter/ui_scripter/editor/linenumberarea.py b/plugins/python/scripter/ui_scripter/editor/linenumberarea.pyindex 77bd1cfa7a..081e3a9786 100644--- a/plugins/python/scripter/ui_scripter/editor/linenumberarea.py+++ b/plugins/python/scripter/ui_scripter/editor/linenumberarea.py@@ -3,8 +3,12 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QWidget-from PyQt5.QtCore import QSize+try:+ from PyQt6.QtWidgets import QWidget+ from PyQt6.QtCore import QSize+except:+ from PyQt5.QtWidgets import QWidget+ from PyQt5.QtCore import QSizeclass LineNumberArea(QWidget):diff --git a/plugins/python/scripter/ui_scripter/editor/pythoneditor.py b/plugins/python/scripter/ui_scripter/editor/pythoneditor.pyindex da3efbc89c..ff8bb81c33 100644--- a/plugins/python/scripter/ui_scripter/editor/pythoneditor.py+++ b/plugins/python/scripter/ui_scripter/editor/pythoneditor.py@@ -3,9 +3,14 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtCore import Qt, QRect, QSize, QPoint, pyqtSlot-from PyQt5.QtWidgets import QPlainTextEdit, QTextEdit, QLabel-from PyQt5.QtGui import QIcon, QColor, QPainter, QTextFormat, QFont, QTextCursor+try:+ from PyQt6.QtCore import Qt, QRect, QSize, QPoint, pyqtSlot+ from PyQt6.QtWidgets import QPlainTextEdit, QTextEdit, QLabel+ from PyQt6.QtGui import QIcon, QColor, QPainter, QTextFormat, QFont, QTextCursor+except:+ from PyQt5.QtCore import Qt, QRect, QSize, QPoint, pyqtSlot+ from PyQt5.QtWidgets import QPlainTextEdit, QTextEdit, QLabel+ from PyQt5.QtGui import QIcon, QColor, QPainter, QTextFormat, QFont, QTextCursorfrom scripter.ui_scripter.editor import linenumberarea, debugarea##################@@ -15,8 +20,8 @@ from scripter.ui_scripter.editor import linenumberarea, debugareaINDENT_WIDTH = 4 # size in spaces of indent in editor window.# ideally make this a setting sometime?-MODIFIER_COMMENT = Qt.ControlModifier-KEY_COMMENT = Qt.Key_M+MODIFIER_COMMENT = Qt.KeyboardModifier.ControlModifier+KEY_COMMENT = Qt.Key.Key_MCHAR_COMMENT = "#"CHAR_SPACE = " "@@ -36,7 +41,7 @@ class CodeEditor(QPlainTextEdit):def __init__(self, scripter, parent=None):super(CodeEditor, self).__init__(parent)- self.setLineWrapMode(self.NoWrap)+ self.setLineWrapMode(QPlainTextEdit.LineWrapMode.NoWrap)self.scripter = scripterself.lineNumberArea = linenumberarea.LineNumberArea(self)@@ -68,7 +73,7 @@ class CodeEditor(QPlainTextEdit):max_ /= 10digits += 1- space = 3 + self.fontMetrics().width('9') * digits + 3+ space = 3 + self.fontMetrics().horizontalAdvance('9') * digits + 3return space@@ -123,7 +128,7 @@ class CodeEditor(QPlainTextEdit):number = str(blockNumber + 1)painter.setPen(self.palette().text().color())painter.drawText(0, top, self.lineNumberArea.width() - 3, self.fontMetrics().height(),- Qt.AlignRight, number)+ Qt.AlignmentFlag.AlignRight, number)block = block.next()top = bottom@@ -157,7 +162,7 @@ class CodeEditor(QPlainTextEdit):lineColor = QColor(43, 43, 43)currentSelection.format.setBackground(lineColor)- currentSelection.format.setProperty(QTextFormat.FullWidthSelection, True)+ currentSelection.format.setProperty(QTextFormat.Property.FullWidthSelection, True)currentSelection.cursor = self.textCursor()currentSelection.cursor.clearSelection()@@ -166,7 +171,7 @@ class CodeEditor(QPlainTextEdit):def wheelEvent(self, e):"""When the CTRL is pressed during the wheelEvent, zoomIn and zoomOutslots are invoked"""- if e.modifiers() == Qt.ControlModifier:+ if e.modifiers() == Qt.KeyboardModifier.ControlModifier:delta = e.angleDelta().y()if delta < 0:self.zoomOut()@@ -177,13 +182,13 @@ class CodeEditor(QPlainTextEdit):def keyPressEvent(self, e):modifiers = e.modifiers()- if (e.key() == Qt.Key_Tab):+ if (e.key() == Qt.Key.Key_Tab):self.indent()- elif e.key() == Qt.Key_Backtab:+ elif e.key() == Qt.Key.Key_Backtab:self.dedent()elif modifiers == MODIFIER_COMMENT and e.key() == KEY_COMMENT:self.toggleComment()- elif e.key() == Qt.Key_Return:+ elif e.key() == Qt.Key.Key_Return:super(CodeEditor, self).keyPressEvent(e)self.autoindent()else:@@ -195,10 +200,10 @@ class CodeEditor(QPlainTextEdit):# get block textcursor = self.textCursor()- cursor.movePosition(QTextCursor.Start)- cursor.movePosition(QTextCursor.NextBlock, n=blockNumber)- cursor.movePosition(QTextCursor.StartOfLine)- cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor)+ cursor.movePosition(QTextCursor.MoveOperation.Start)+ cursor.movePosition(QTextCursor.MoveOperation.NextBlock, n=blockNumber)+ cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)+ cursor.movePosition(QTextCursor.MoveOperation.EndOfLine, QTextCursor.MoveMode.KeepAnchor)text = cursor.selectedText()if text.strip() == "":return True@@ -226,27 +231,27 @@ class CodeEditor(QPlainTextEdit):cursor.setPosition(selectionEnd)endBlock = cursor.blockNumber()- cursor.movePosition(QTextCursor.Start)- cursor.movePosition(QTextCursor.NextBlock, n=startBlock)+ cursor.movePosition(QTextCursor.MoveOperation.Start)+ cursor.movePosition(QTextCursor.MoveOperation.NextBlock, n=startBlock)for i in range(0, endBlock - startBlock + 1):if not self.isEmptyBlock(startBlock + i): # Don't insert whitespace on empty lines- cursor.movePosition(QTextCursor.StartOfLine)+ cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)cursor.insertText(" " * self.indent_width)- cursor.movePosition(QTextCursor.NextBlock)+ cursor.movePosition(QTextCursor.MoveOperation.NextBlock)# QT maintains separate cursors, so don't need to track or reset user's cursordef dedentBlock(self, blockNumber):# dedent the line at blockNumbercursor = self.textCursor()- cursor.movePosition(QTextCursor.Start)- cursor.movePosition(QTextCursor.NextBlock, n=blockNumber)+ cursor.movePosition(QTextCursor.MoveOperation.Start)+ cursor.movePosition(QTextCursor.MoveOperation.NextBlock, n=blockNumber)for _ in range(self.indent_width):- cursor.movePosition(QTextCursor.StartOfLine)- cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor)+ cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)+ cursor.movePosition(QTextCursor.MoveOperation.Right, QTextCursor.ModeMode.KeepAnchor)if cursor.selectedText() == " ": # need to test each charcursor.removeSelectedText()else:@@ -349,33 +354,33 @@ class CodeEditor(QPlainTextEdit):cursor.setPosition(selectionEnd)endBlock = cursor.blockNumber()- cursor.movePosition(QTextCursor.Start)- cursor.movePosition(QTextCursor.NextBlock, n=startBlock)+ cursor.movePosition(QTextCursor.MoveOperation.Start)+ cursor.movePosition(QTextCursor.MoveOperation.NextBlock, n=startBlock)for _ in range(0, endBlock - startBlock + 1):# Test for empty line (if the line is empty moving the cursor right will overflow# to next line, throwing the line tracking off)- cursor.movePosition(QTextCursor.StartOfLine)+ cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)p1 = cursor.position()- cursor.movePosition(QTextCursor.EndOfLine)+ cursor.movePosition(QTextCursor.MoveOperation.EndOfLine)p2 = cursor.position()if p1 == p2: # empty line - comment it- cursor.movePosition(QTextCursor.StartOfLine)+ cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)cursor.insertText(CHAR_COMMENT)- cursor.movePosition(QTextCursor.NextBlock)+ cursor.movePosition(QTextCursor.MoveOperation.NextBlock)continue- cursor.movePosition(QTextCursor.StartOfLine)- cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor)+ cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)+ cursor.movePosition(QTextCursor.MoveOperation.Right, QTextCursor.MoveMode.KeepAnchor)text = cursor.selectedText()if text == CHAR_COMMENT:cursor.removeSelectedText()else:- cursor.movePosition(QTextCursor.StartOfLine)+ cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)cursor.insertText(CHAR_COMMENT)- cursor.movePosition(QTextCursor.NextBlock)+ cursor.movePosition(QTextCursor.MoveOperation.NextBlock)@propertydef font(self):diff --git a/plugins/python/scripter/ui_scripter/editor/statusbar.py b/plugins/python/scripter/ui_scripter/editor/statusbar.pyindex ae32263b94..49dca4a5d8 100644--- a/plugins/python/scripter/ui_scripter/editor/statusbar.py+++ b/plugins/python/scripter/ui_scripter/editor/statusbar.py@@ -3,8 +3,12 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QWidget-from PyQt5.QtCore import QSize+try:+ from PyQt6.QtWidgets import QWidget+ from PyQt6.QtCore import QSize+except:+ from PyQt5.QtWidgets import QWidget+ from PyQt5.QtCore import QSizeclass StatusBar(QWidget):diff --git a/plugins/python/scripter/ui_scripter/syntax/syntax.py b/plugins/python/scripter/ui_scripter/syntax/syntax.pyindex b0d3088e03..5aba81ed74 100644--- a/plugins/python/scripter/ui_scripter/syntax/syntax.py+++ b/plugins/python/scripter/ui_scripter/syntax/syntax.py@@ -5,9 +5,12 @@ SPDX-License-Identifier: GPL-2.0-or-later"""# syntax.py: taken from https://wiki.python.org/moin/PyQt/Python%20syntax%20highlighting--from PyQt5.QtCore import QRegExp-from PyQt5.QtGui import QSyntaxHighlighter+try:+ from PyQt6.QtCore import QRegularExpression+ from PyQt6.QtGui import QSyntaxHighlighter+except:+ from PyQt5.QtCore import QRegularExpression+ from PyQt5.QtGui import QSyntaxHighlighterclass PythonHighlighter (QSyntaxHighlighter):@@ -51,8 +54,8 @@ class PythonHighlighter (QSyntaxHighlighter):# Multi-line strings (expression, flag, style)# FIXME: The triple-quotes in these two lines will mess up the# syntax highlighting from this point onward- self.tri_single = (QRegExp(r"""'''(?!")"""), 1, 'string2')- self.tri_double = (QRegExp(r'''"""(?!')'''), 2, 'string2')+ self.tri_single = (QRegularExpression(r"""'''(?!")"""), 1, 'string2')+ self.tri_double = (QRegularExpression(r'''"""(?!')'''), 2, 'string2')rules = []@@ -88,22 +91,20 @@ class PythonHighlighter (QSyntaxHighlighter):(r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 0, 'numbers'),]- # Build a QRegExp for each pattern- self.rules = [(QRegExp(pat), index, identifier)+ # Build a QRegularExpression for each pattern+ self.rules = [(QRegularExpression(pat), index, identifier)for (pat, index, identifier) in rules]def highlightBlock(self, text):"""Apply syntax highlighting to the given block of text."""# Do other syntax formattingfor expression, nth, identifier in self.rules:- index = expression.indexIn(text, 0)-- while index >= 0:- # We actually want the index of the nth match- index = expression.pos(nth)- length = len(expression.cap(nth))+ matchIter = expression.globalMatch(text)+ while matchIter.hasNext():+ match = matchIter.next()+ index = match.capturedStart(nth)+ length = match.capturedLength(nth)self.setFormat(index, length, self.syntaxStyle[identifier])- index = expression.indexIn(text, index + length)self.setCurrentBlockState(0)@@ -114,7 +115,7 @@ class PythonHighlighter (QSyntaxHighlighter):def match_multiline(self, text, delimiter, in_state, style):"""Do highlighting of multi-line strings. ``delimiter`` should be a- ``QRegExp`` for triple-single-quotes or triple-double-quotes, and+ ``QRegularExpression`` for triple-single-quotes or triple-double-quotes, and``in_state`` should be a unique integer to represent the correspondingstate changes when inside those strings. Returns True if we're stillinside a multi-line string when this function is finished.@@ -125,17 +126,18 @@ class PythonHighlighter (QSyntaxHighlighter):add = 0# Otherwise, look for the delimiter on this lineelse:- start = delimiter.indexIn(text)+ start = delimiter.match(text).capturedStart()# Move past this match- add = delimiter.matchedLength()+ add = delimiter.match(text).capturedLength(delimiter.match(text).lastCapturedIndex())# As long as there's a delimiter match on this line...while start >= 0:# Look for the ending delimiter- end = delimiter.indexIn(text, start + add)+ match = delimiter.match(text, start + add)+ end = match.capturedStart()# Ending delimiter on this line?if end >= add:- length = end - start + add + delimiter.matchedLength()+ length = end - start + add + match.capturedLength(match.lastCapturedIndex())self.setCurrentBlockState(0)# No; multi-line stringelse:@@ -144,7 +146,7 @@ class PythonHighlighter (QSyntaxHighlighter):# Apply formattingself.setFormat(start, length, self.syntaxStyle[style])# Look for the next match- start = delimiter.indexIn(text, start + length)+ start = delimiter.match(text, start + length).capturedStart()# Return True if still inside a multi-line string, False otherwiseif self.currentBlockState() == in_state:diff --git a/plugins/python/scripter/ui_scripter/syntax/syntaxstyles.py b/plugins/python/scripter/ui_scripter/syntax/syntaxstyles.pyindex ca26372e43..b9f6fba3ad 100644--- a/plugins/python/scripter/ui_scripter/syntax/syntaxstyles.py+++ b/plugins/python/scripter/ui_scripter/syntax/syntaxstyles.py@@ -3,7 +3,10 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtGui import QColor, QTextCharFormat, QFont+try:+ from PyQt6.QtGui import QColor, QTextCharFormat, QFont+except:+ from PyQt5.QtGui import QColor, QTextCharFormat, QFontdef _format(color, style='', darker=100, lighter=100):@@ -16,7 +19,7 @@ def _format(color, style='', darker=100, lighter=100):fmt = QTextCharFormat()fmt.setForeground(_color)if 'bold' in style:- fmt.setFontWeight(QFont.Bold)+ fmt.setFontWeight(QFont.Weight.Bold)if 'italic' in style:fmt.setFontItalic(True)diff --git a/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/debuggertable.py b/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/debuggertable.pyindex 4c2c5e7698..d85cbce65c 100644--- a/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/debuggertable.py+++ b/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/debuggertable.py@@ -3,7 +3,10 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QTableWidget, QTableWidgetItem+try:+ from PyQt6.QtWidgets import QTableWidget, QTableWidgetItem+except:+ from PyQt5.QtWidgets import QTableWidget, QTableWidgetItemclass DebuggerTable(QTableWidget):@@ -15,7 +18,7 @@ class DebuggerTable(QTableWidget):tableHeader = [i18n('Scope'), i18n('Name'), i18nc('Value in DebuggerTable', 'Value'), i18n('Type')]self.setHorizontalHeaderLabels(tableHeader)- self.setEditTriggers(self.NoEditTriggers)+ self.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)def updateTable(self, data):self.clearContents()diff --git a/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/debuggerwidget.py b/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/debuggerwidget.pyindex 7345f1ab23..52e9a29102 100644--- a/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/debuggerwidget.py+++ b/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/debuggerwidget.py@@ -3,7 +3,11 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QWidget, QVBoxLayout, QToolBar, QTableWidget, QAction+try:+ from PyQt6.QtWidgets import QWidget, QVBoxLayout, QToolBar, QTableWidget+ #from PyQt6.QtGui import QAction+except:+ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QToolBar, QTableWidget, QActionfrom . import stepaction, stopaction, debuggertablediff --git a/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/stepaction.py b/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/stepaction.pyindex 990298794b..c5b672b71a 100644--- a/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/stepaction.py+++ b/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/stepaction.py@@ -3,8 +3,11 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction-from PyQt5.QtGui import QIcon+try:+ from PyQt6.QtGui import QIcon, QAction+except:+ from PyQt5.QtWidgets import QAction+ from PyQt5.QtGui import QIconfrom scripter import resources_rcfrom .... import utilsimport kritadiff --git a/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/stopaction.py b/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/stopaction.pyindex dd9861636c..c1fec4848b 100644--- a/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/stopaction.py+++ b/plugins/python/scripter/ui_scripter/tabwidgets/debuggerwidget/stopaction.py@@ -3,8 +3,11 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction-from PyQt5.QtGui import QIcon+try:+ from PyQt6.QtGui import QIcon, QAction+except:+ from PyQt5.QtWidgets import QAction+ from PyQt5.QtGui import QIconfrom scripter import resources_rcimport kritadiff --git a/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/clearaction.py b/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/clearaction.pyindex a97b00962f..d01dd894f6 100644--- a/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/clearaction.py+++ b/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/clearaction.py@@ -3,8 +3,11 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QAction-from PyQt5.QtGui import QIcon+try:+ from PyQt6.QtGui import QIcon, QAction+except:+ from PyQt5.QtWidgets import QAction+ from PyQt5.QtGui import QIconfrom scripter import resources_rcimport kritadiff --git a/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/outputtextedit.py b/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/outputtextedit.pyindex 0c35048663..d45b853980 100644--- a/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/outputtextedit.py+++ b/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/outputtextedit.py@@ -3,7 +3,10 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QPlainTextEdit+try:+ from PyQt6.QtWidgets import QPlainTextEdit+except:+ from PyQt5.QtWidgets import QPlainTextEditclass OutPutTextEdit(QPlainTextEdit):diff --git a/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/outputwidget.py b/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/outputwidget.pyindex 3d436508cc..42673dd44f 100644--- a/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/outputwidget.py+++ b/plugins/python/scripter/ui_scripter/tabwidgets/outputwidget/outputwidget.py@@ -3,7 +3,11 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtWidgets import QWidget, QVBoxLayout, QToolBar, QTableWidget, QAction+try:+ from PyQt6.QtWidgets import QWidget, QVBoxLayout, QToolBar, QTableWidget+ #from PyQt6.QtGui import QAction+except:+ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QToolBar, QTableWidget, QActionfrom . import clearaction, outputtexteditdiff --git a/plugins/python/scripter/uicontroller.py b/plugins/python/scripter/uicontroller.pyindex 274d403a17..4c755543b2 100644--- a/plugins/python/scripter/uicontroller.py+++ b/plugins/python/scripter/uicontroller.py@@ -3,11 +3,18 @@ SPDX-FileCopyrightText: 2017 Eliakin Costa <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtCore import Qt, QObject, QFileInfo, QRect-from PyQt5.QtGui import QTextCursor, QPalette-from PyQt5.QtWidgets import (QToolBar, QMenuBar, QTabWidget,- QLabel, QVBoxLayout, QMessageBox,- QSplitter, QSizePolicy)+try:+ from PyQt6.QtCore import Qt, QObject, QFileInfo, QRect+ from PyQt6.QtGui import QTextCursor, QPalette+ from PyQt6.QtWidgets import (QToolBar, QMenuBar, QTabWidget,+ QLabel, QVBoxLayout, QMessageBox,+ QSplitter, QSizePolicy)+except:+ from PyQt5.QtCore import Qt, QObject, QFileInfo, QRect+ from PyQt5.QtGui import QTextCursor, QPalette+ from PyQt5.QtWidgets import (QToolBar, QMenuBar, QTabWidget,+ QLabel, QVBoxLayout, QMessageBox,+ QSplitter, QSizePolicy)from .ui_scripter.syntax import syntax, syntaxstylesfrom .ui_scripter.editor import pythoneditorfrom . import scripterdialog, utils@@ -24,15 +31,16 @@ class Elided_Text_Label(QLabel):def __init__(self, parent=None):super(QLabel, self).__init__(parent)- self.setMinimumWidth(self.fontMetrics().width("..."))- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)++ self.setMinimumWidth(self.fontMetrics().horizontalAdvance("..."))+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)def setMainText(self, text=str()):self.mainText = textself.elideText()def elideText(self):- self.setText(self.fontMetrics().elidedText(self.mainText, Qt.ElideRight, self.width()))+ self.setText(self.fontMetrics().elidedText(self.mainText, Qt.TextElideMode.ElideRight, self.width()))def resizeEvent(self, event):self.elideText()@@ -52,7 +60,7 @@ class UIController(object):self.actions = []- self.mainWidget.setWindowModality(Qt.NonModal)+ self.mainWidget.setWindowModality(Qt.WindowModality.NonModal)def initialize(self, scripter):self.editor = pythoneditor.CodeEditor(scripter)@@ -60,11 +68,11 @@ class UIController(object):self.statusBar = Elided_Text_Label()self.statusBar.setMainText('untitled')self.splitter = QSplitter()- self.splitter.setOrientation(Qt.Vertical)+ self.splitter.setOrientation(Qt.Orientation.Vertical)self.highlight = syntax.PythonHighlighter(self.editor.document(), syntaxstyles.DefaultSyntaxStyle())p = self.editor.palette()- p.setColor(QPalette.Base, syntaxstyles.DefaultSyntaxStyle()['background'].foreground().color())- p.setColor(QPalette.Text, syntaxstyles.DefaultSyntaxStyle()['foreground'].foreground().color())+ p.setColor(QPalette.ColorRole.Base, syntaxstyles.DefaultSyntaxStyle()['background'].foreground().color())+ p.setColor(QPalette.ColorRole.Text, syntaxstyles.DefaultSyntaxStyle()['foreground'].foreground().color())self.editor.setPalette(p)utils.setNeedDarkIcon(self.mainWidget.palette().window().color())@@ -166,10 +174,10 @@ class UIController(object):def setDocumentEditor(self, document):self.editor.clear()- self.editor.moveCursor(QTextCursor.Start)+ self.editor.moveCursor(QTextCursor.MoveOperation.Start)self.editor._documentModified = Falseself.editor.setPlainText(document.data)- self.editor.moveCursor(QTextCursor.End)+ self.editor.moveCursor(QTextCursor.MoveOperation.End)def setStatusBar(self, value='untitled'):self.documentStatusBarText = valuediff --git a/plugins/python/scripter/utils.py b/plugins/python/scripter/utils.pyindex eb768c0ece..9432653eb6 100644--- a/plugins/python/scripter/utils.py+++ b/plugins/python/scripter/utils.py@@ -3,7 +3,10 @@ SPDX-FileCopyrightText: 2022 Ivan Santa Maria <[email protected]>SPDX-License-Identifier: GPL-2.0-or-later"""-from PyQt5.QtGui import QIcon, QPixmap, QColor, QPainter+try:+ from PyQt6.QtGui import QIcon, QPixmap, QColor, QPainter+except:+ from PyQt5.QtGui import QIcon, QPixmap, QColor, QPainterneedDarkIcon = False@@ -16,7 +19,7 @@ def getThemedIcon(filepath) -> QIcon:global needDarkIconpixmap = QPixmap(filepath)painter = QPainter(pixmap)- painter.setCompositionMode(QPainter.CompositionMode_SourceIn)+ painter.setCompositionMode(QPainter.CompositionMode.CompositionMode_SourceIn)if needDarkIcon:painter.fillRect(pixmap.rect(),QColor(32,32,32))diff --git a/plugins/python/selectionsbagdocker/__init__.py b/plugins/python/selectionsbagdocker/__init__.pyindex 6cab427d88..8f9137aff4 100644--- a/plugins/python/selectionsbagdocker/__init__.py+++ b/plugins/python/selectionsbagdocker/__init__.py@@ -7,5 +7,5 @@ from .selectionsbagdocker import SelectionsBagDockerKrita.instance().addDockWidgetFactory(DockWidgetFactory("SelectionsBagDocker",- DockWidgetFactory.DockRight,+ DockWidgetFactory.DockPosition.DockRight,SelectionsBagDocker))diff --git a/plugins/python/selectionsbagdocker/selectionsbagdocker.py b/plugins/python/selectionsbagdocker/selectionsbagdocker.pyindex 9d9aa9858a..cbece64d62 100644--- a/plugins/python/selectionsbagdocker/selectionsbagdocker.py+++ b/plugins/python/selectionsbagdocker/selectionsbagdocker.py@@ -1,8 +1,13 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QWidget+try:+ from PyQt6.QtWidgets import QWidget-from PyQt5 import uic+ from PyQt6 import uic+except:+ from PyQt5.QtWidgets import QWidget++ from PyQt5 import uicfrom krita import DockWidgetimport osdiff --git a/plugins/python/tenbrushes/dropbutton.py b/plugins/python/tenbrushes/dropbutton.pyindex e3ff721847..d9e35c38ee 100644--- a/plugins/python/tenbrushes/dropbutton.py+++ b/plugins/python/tenbrushes/dropbutton.py@@ -1,8 +1,13 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QPushButton-from PyQt5.QtGui import QPixmap, QIcon-from PyQt5.QtCore import QSize+try:+ from PyQt6.QtWidgets import QPushButton+ from PyQt6.QtGui import QPixmap, QIcon+ from PyQt6.QtCore import QSize+except:+ from PyQt5.QtWidgets import QPushButton+ from PyQt5.QtGui import QPixmap, QIcon+ from PyQt5.QtCore import QSizeclass DropButton(QPushButton):diff --git a/plugins/python/tenbrushes/tenbrushes.py b/plugins/python/tenbrushes/tenbrushes.pyindex c53fc714ea..05b48677e1 100644--- a/plugins/python/tenbrushes/tenbrushes.py+++ b/plugins/python/tenbrushes/tenbrushes.py@@ -1,7 +1,10 @@# SPDX-License-Identifier: CC0-1.0import krita-from PyQt5.QtGui import QPixmap, QIcon+try:+ from PyQt6.QtGui import QPixmap, QIcon+except:+ from PyQt5.QtGui import QPixmap, QIconfrom . import uitenbrushesdiff --git a/plugins/python/tenbrushes/tenbrushesdialog.py b/plugins/python/tenbrushes/tenbrushesdialog.pyindex 3378b4b091..04da0b56ee 100644--- a/plugins/python/tenbrushes/tenbrushesdialog.py+++ b/plugins/python/tenbrushes/tenbrushesdialog.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QDialog+try:+ from PyQt6.QtWidgets import QDialog+except:+ from PyQt5.QtWidgets import QDialogclass TenBrushesDialog(QDialog):diff --git a/plugins/python/tenbrushes/uitenbrushes.py b/plugins/python/tenbrushes/uitenbrushes.pyindex 791d1cee00..219ae72332 100644--- a/plugins/python/tenbrushes/uitenbrushes.py+++ b/plugins/python/tenbrushes/uitenbrushes.py@@ -1,9 +1,15 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtCore import Qt-from PyQt5.QtGui import QPixmap, QIcon-from PyQt5.QtWidgets import (QDialogButtonBox, QLabel, QVBoxLayout,- QHBoxLayout, QCheckBox)+try:+ from PyQt6.QtCore import Qt+ from PyQt6.QtGui import QPixmap, QIcon+ from PyQt6.QtWidgets import (QDialogButtonBox, QLabel, QVBoxLayout,+ QHBoxLayout, QCheckBox)+except:+ from PyQt5.QtCore import Qt+ from PyQt5.QtGui import QPixmap, QIcon+ from PyQt5.QtWidgets import (QDialogButtonBox, QLabel, QVBoxLayout,+ QHBoxLayout, QCheckBox)from . import tenbrushesdialog, dropbuttonimport krita@@ -31,9 +37,9 @@ class UITenBrushes(object):self.buttonBox.accepted.connect(self.mainDialog.accept)self.buttonBox.rejected.connect(self.mainDialog.reject)- self.buttonBox.setOrientation(Qt.Horizontal)+ self.buttonBox.setOrientation(Qt.Orientation.Horizontal)self.buttonBox.setStandardButtons(- QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)self.presetChooser = krita.PresetChooser(self.mainDialog)@@ -64,7 +70,7 @@ class UITenBrushes(object):self.mainDialog.show()self.mainDialog.activateWindow()- self.mainDialog.exec_()+ self.mainDialog.exec()def setActivatePrev(self, checked):self.tenbrushes.activatePrev = checked@@ -98,7 +104,7 @@ class UITenBrushes(object):label = QLabel(action.shortcut().toString())- label.setAlignment(Qt.AlignHCenter)+ label.setAlignment(Qt.AlignmentFlag.AlignHCenter)buttonLayout.addWidget(label)self.hbox.addLayout(buttonLayout)diff --git a/plugins/python/tenscripts/tenscripts.py b/plugins/python/tenscripts/tenscripts.pyindex 712d3df183..74ca0c5c17 100644--- a/plugins/python/tenscripts/tenscripts.py+++ b/plugins/python/tenscripts/tenscripts.py@@ -2,7 +2,10 @@import sysimport krita-from PyQt5.QtGui import QIcon+try:+ from PyQt6.QtGui import QIcon+except:+ from PyQt5.QtGui import QIconfrom . import uitenscriptsif sys.version_info[0] > 2:diff --git a/plugins/python/tenscripts/tenscriptsdialog.py b/plugins/python/tenscripts/tenscriptsdialog.pyindex a2c55f0812..d7e590a71f 100644--- a/plugins/python/tenscripts/tenscriptsdialog.py+++ b/plugins/python/tenscripts/tenscriptsdialog.py@@ -1,6 +1,9 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtWidgets import QDialog+try:+ from PyQt6.QtWidgets import QDialog+except:+ from PyQt5.QtWidgets import QDialogclass TenScriptsDialog(QDialog):diff --git a/plugins/python/tenscripts/uitenscripts.py b/plugins/python/tenscripts/uitenscripts.pyindex e71e57e9ba..1b363befe6 100644--- a/plugins/python/tenscripts/uitenscripts.py+++ b/plugins/python/tenscripts/uitenscripts.py@@ -1,10 +1,17 @@# SPDX-License-Identifier: CC0-1.0-from PyQt5.QtCore import Qt-from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QPushButton,- QLineEdit, QScrollArea, QGridLayout, QFileDialog,- QLabel, QDialogButtonBox)-from PyQt5.QtGui import QKeySequence+try:+ from PyQt6.QtCore import Qt+ from PyQt6.QtWidgets import (QWidget, QVBoxLayout, QPushButton,+ QLineEdit, QScrollArea, QGridLayout, QFileDialog,+ QLabel, QDialogButtonBox)+ from PyQt6.QtGui import QKeySequence+except:+ from PyQt5.QtCore import Qt+ from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QPushButton,+ QLineEdit, QScrollArea, QGridLayout, QFileDialog,+ QLabel, QDialogButtonBox)+ from PyQt5.QtGui import QKeySequencefrom . import tenscriptsdialogimport krita@@ -26,9 +33,9 @@ class UITenScripts(object):self.buttonBox.accepted.connect(self.mainDialog.accept)self.buttonBox.rejected.connect(self.mainDialog.reject)- self.buttonBox.setOrientation(Qt.Horizontal)+ self.buttonBox.setOrientation(Qt.Orientation.Horizontal)self.buttonBox.setStandardButtons(- QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)self.scrollArea.setWidgetResizable(True)def initialize(self, tenscripts):@@ -50,7 +57,7 @@ class UITenScripts(object):self.mainDialog.show()self.mainDialog.activateWindow()- self.mainDialog.exec_()+ self.mainDialog.exec()def addNewRow(self, index):rowPosition = self.scriptsLayout.rowCount()@@ -62,20 +69,20 @@ class UITenScripts(object):action = Application.action(self.tenscripts.indexToAction[index])directoryTextField.setReadOnly(True)- label.setText(action.shortcut().toString(QKeySequence.NativeText))+ label.setText(action.shortcut().toString(QKeySequence.SequenceFormat.NativeText))directoryTextField.setToolTip(i18n("Selected path"))directoryDialogButton.setToolTip(i18n("Select the script"))directoryDialogButton.clicked.connect(self._selectScript)directoryClearButton.clicked.connect(self._clearScript)self.scriptsLayout.addWidget(- label, rowPosition, 0, Qt.AlignLeft | Qt.AlignTop)+ label, rowPosition, 0, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)self.scriptsLayout.addWidget(- directoryTextField, rowPosition, 1, Qt.AlignLeft | Qt.AlignTop)+ directoryTextField, rowPosition, 1, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)self.scriptsLayout.addWidget(- directoryClearButton, rowPosition, 2, Qt.AlignLeft | Qt.AlignTop)+ directoryClearButton, rowPosition, 2, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)self.scriptsLayout.addWidget(- directoryDialogButton, rowPosition, 3, Qt.AlignLeft | Qt.AlignTop)+ directoryDialogButton, rowPosition, 3, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)def saved_scripts(self):_saved_scripts = []@@ -98,7 +105,7 @@ class UITenScripts(object):dialog = QFileDialog(self.mainDialog)dialog.setNameFilter(i18n("Python files (*.py)"))- if dialog.exec_():+ if dialog.exec():selectedFile = dialog.selectedFiles()[0]obj = self.mainDialog.sender()textField = self.scriptsLayout.itemAt(diff --git a/plugins/python/workflow_buttons/buttons_settings_dialog.py b/plugins/python/workflow_buttons/buttons_settings_dialog.pyindex 85b084a9d6..44d608502b 100644--- a/plugins/python/workflow_buttons/buttons_settings_dialog.py+++ b/plugins/python/workflow_buttons/buttons_settings_dialog.py@@ -3,11 +3,18 @@# Timothée Giet <[email protected]># SPDX-License-Identifier: GPL-3.0-or-later-from PyQt5.QtCore import QSize-from PyQt5.QtGui import QIcon, QPixmap, QColor, QPen, QBrush, QPainter, QImageReader-from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QWidget, QScrollArea, QPushButton,- QToolButton, QLabel, QLineEdit, QComboBox, QDialogButtonBox,- QFileDialog, QFrame, QWidget, QSizePolicy)+try:+ from PyQt6.QtCore import QSize, Qt+ from PyQt6.QtGui import QIcon, QPixmap, QColor, QPen, QBrush, QPainter, QImageReader+ from PyQt6.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QWidget, QScrollArea, QPushButton,+ QToolButton, QLabel, QLineEdit, QComboBox, QDialogButtonBox,+ QFileDialog, QFrame, QWidget, QSizePolicy)+except:+ from PyQt5.QtCore import QSize, Qt+ from PyQt5.QtGui import QIcon, QPixmap, QColor, QPen, QBrush, QPainter, QImageReader+ from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QWidget, QScrollArea, QPushButton,+ QToolButton, QLabel, QLineEdit, QComboBox, QDialogButtonBox,+ QFileDialog, QFrame, QWidget, QSizePolicy)from krita import Krita, PresetChooser, ManagedColorfrom .flow_layout import FlowLayoutimport copy@@ -99,7 +106,7 @@ class ButtonsSettingsDialog(QDialog):layoutForSelectorControls.addWidget(self.selectedButtonIDLabel)spacer1 = QWidget(self)- spacer1.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ spacer1.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)layoutForSelectorControls.addWidget(spacer1)# button to add a custom button@@ -143,7 +150,7 @@ class ButtonsSettingsDialog(QDialog):layoutForIconMode.addWidget(self.iconModeSelector)spacer2 = QWidget(self)- spacer2.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ spacer2.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)layoutForIconMode.addWidget(spacer2)mainLayout.addLayout(layoutForIconMode)@@ -186,7 +193,7 @@ class ButtonsSettingsDialog(QDialog):layoutForToolSelector.addWidget(self.toolSelector)spacer3 = QWidget(self)- spacer3.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ spacer3.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)layoutForToolSelector.addWidget(spacer3)mainLayout.addLayout(layoutForToolSelector)@@ -219,7 +226,7 @@ class ButtonsSettingsDialog(QDialog):layoutForFGColorInput.addWidget(FGColorClear)spacer4 = QWidget(self)- spacer4.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ spacer4.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)layoutForFGColorInput.addWidget(spacer4)mainLayout.addLayout(layoutForFGColorInput)@@ -234,7 +241,7 @@ class ButtonsSettingsDialog(QDialog):layoutForFGColorInfo.addWidget(self.FGColorInfoLabel)spacer5 = QWidget(self)- spacer5.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ spacer5.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)layoutForFGColorInfo.addWidget(spacer5)mainLayout.addLayout(layoutForFGColorInfo)@@ -251,7 +258,7 @@ class ButtonsSettingsDialog(QDialog):layoutForBGColorInput.addWidget(BGColorClear)spacer6 = QWidget(self)- spacer6.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ spacer6.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)layoutForBGColorInput.addWidget(spacer6)mainLayout.addLayout(layoutForBGColorInput)@@ -264,7 +271,7 @@ class ButtonsSettingsDialog(QDialog):layoutForBGColorInfo.addWidget(self.BGColorInfoLabel)spacer7 = QWidget(self)- spacer7.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ spacer7.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)layoutForBGColorInfo.addWidget(spacer7)mainLayout.addLayout(layoutForBGColorInfo)@@ -288,8 +295,8 @@ class ButtonsSettingsDialog(QDialog):# spacer for global controlsspacerLine = QFrame(self)- spacerLine.setFrameShape(QFrame.HLine)- spacerLine.setFrameShadow(QFrame.Sunken)+ spacerLine.setFrameShape(QFrame.Shape.HLine)+ spacerLine.setFrameShadow(QFrame.Shadow.Sunken)mainLayout.addWidget(spacerLine)# button's size selector@@ -303,7 +310,7 @@ class ButtonsSettingsDialog(QDialog):layoutForButtonsSize.addWidget(self.buttonsSizeSelector)spacer8 = QWidget(self)- spacer8.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ spacer8.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)layoutForButtonsSize.addWidget(spacer8)mainLayout.addLayout(layoutForButtonsSize)@@ -320,7 +327,7 @@ class ButtonsSettingsDialog(QDialog):layoutForSettingsButtonOption.addWidget(self.settingsButtonPositionSelector)spacer9 = QWidget(self)- spacer9.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ spacer9.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)layoutForSettingsButtonOption.addWidget(spacer9)mainLayout.addLayout(layoutForSettingsButtonOption)@@ -328,7 +335,7 @@ class ButtonsSettingsDialog(QDialog):# main dialog's default buttonslayoutForBottom = QHBoxLayout()buttonBox = QDialogButtonBox(self)- buttonBox.setStandardButtons( QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ buttonBox.setStandardButtons( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)buttonBox.accepted.connect(self.accept)buttonBox.rejected.connect(self.reject)layoutForBottom.addWidget(buttonBox)@@ -452,7 +459,7 @@ class ButtonsSettingsDialog(QDialog):# The format string cannot be translated, only the descriptiondialog.setNameFilter(i18n("Icon files ") + "(" + formatsString + ")")- if dialog.exec_():+ if dialog.exec():selectedFile = dialog.selectedFiles()[0]self.iconPathInput.setText(selectedFile)self.iconPathChanged()@@ -487,12 +494,12 @@ class ButtonsSettingsDialog(QDialog):presetChooser = PresetChooser(dialog)dialogLayout.addWidget(presetChooser)buttonBox = QDialogButtonBox(dialog)- buttonBox.setStandardButtons( QDialogButtonBox.Ok | QDialogButtonBox.Cancel)+ buttonBox.setStandardButtons( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)buttonBox.accepted.connect(dialog.accept)buttonBox.rejected.connect(dialog.reject)dialogLayout.addWidget(buttonBox)- dialog.exec_()+ dialog.exec()if dialog.result() == 1 and presetChooser.currentPreset():self.presetSelectorInput.setText(presetChooser.currentPreset().name())self.presetChanged()@@ -578,7 +585,7 @@ class ButtonsSettingsDialog(QDialog):dialog = QFileDialog(self)dialog.setNameFilter(i18n("Script files ") + "(*.py)")- if dialog.exec_():+ if dialog.exec():selectedFile = dialog.selectedFiles()[0]self.scriptPathInput.setText(selectedFile)self.scriptPathChanged()@@ -673,8 +680,8 @@ class selectedButtonHighlight(QWidget):def paintEvent(self, event):painter = QPainter(self)- painter.setPen(QPen(self.colorPen, 4, 1)) # last 1 is for Qt.SolidLine- painter.setBrush(QBrush(self.colorBrush, 1)) # last 1 is for Qt.SolidPattern+ painter.setPen(QPen(self.colorPen, 4, Qt.PenStyle.SolidLine))+ painter.setBrush(QBrush(self.colorBrush, Qt.BrushStyle.SolidPattern))painter.drawRect(2, 2, self.minimumSize().width() - 3, self.minimumSize().height() - 4)@@ -692,8 +699,8 @@ class SelectedColorPreview(QWidget):def paintEvent(self, event):painter = QPainter(self)- painter.setPen(QPen(self.outlineColor, 1, 1)) # last 1 is for Qt.SolidLine- painter.setBrush(QBrush(self.color, 1)) # last 1 is for Qt.SolidPattern+ painter.setPen(QPen(self.outlineColor, 1, Qt.PenStyle.SolidLine))+ painter.setBrush(QBrush(self.color, Qt.BrushStyle.SolidPattern))painter.drawRect(1, 1, 30, 30)def convertColorInfoToQColor(self):diff --git a/plugins/python/workflow_buttons/flow_layout.py b/plugins/python/workflow_buttons/flow_layout.pyindex 35744c2be1..366c49f9bf 100644--- a/plugins/python/workflow_buttons/flow_layout.py+++ b/plugins/python/workflow_buttons/flow_layout.py@@ -4,8 +4,12 @@# FlowLayout class copied from https://doc.qt.io/qtforpython-6/examples/example_widgets_layouts_flowlayout.html-from PyQt5.QtCore import Qt, QMargins, QPoint, QRect, QSize-from PyQt5.QtWidgets import QLayout, QSizePolicy+try:+ from PyQt6.QtCore import Qt, QMargins, QPoint, QRect, QSize+ from PyQt6.QtWidgets import QLayout, QSizePolicy+except:+ from PyQt5.QtCore import Qt, QMargins, QPoint, QRect, QSize+ from PyQt5.QtWidgets import QLayout, QSizePolicyclass FlowLayout(QLayout):def __init__(self, parent=None):@@ -74,10 +78,10 @@ class FlowLayout(QLayout):for item in self._item_list:style = item.widget().style()layout_spacing_x = style.layoutSpacing(- QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Horizontal+ QSizePolicy.ControlType.PushButton, QSizePolicy.ControlType.PushButton, Qt.Orientation.Horizontal)layout_spacing_y = style.layoutSpacing(- QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Vertical+ QSizePolicy.ControlType.PushButton, QSizePolicy.ControlType.PushButton, Qt.Orientation.Vertical)space_x = spacing + layout_spacing_xspace_y = spacing + layout_spacing_ydiff --git a/plugins/python/workflow_buttons/workflow_buttons.py b/plugins/python/workflow_buttons/workflow_buttons.pyindex dda70debf6..b84cbd7288 100644--- a/plugins/python/workflow_buttons/workflow_buttons.py+++ b/plugins/python/workflow_buttons/workflow_buttons.py@@ -3,9 +3,14 @@# Timothée Giet <[email protected]># SPDX-License-Identifier: GPL-3.0-or-later-from PyQt5.QtCore import QSize-from PyQt5.QtGui import QIcon, QPixmap-from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QScrollArea, QToolButton, QPushButton, QToolBar, QAction, QSizePolicy+try:+ from PyQt6.QtCore import QSize+ from PyQt6.QtGui import QIcon, QPixmap, QAction+ from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QScrollArea, QToolButton, QPushButton, QToolBar, QSizePolicy+except:+ from PyQt5.QtCore import QSize+ from PyQt5.QtGui import QIcon, QPixmap+ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QScrollArea, QToolButton, QPushButton, QToolBar, QAction, QSizePolicyfrom krita import Krita, DockWidget, DockWidgetFactory, DockWidgetFactoryBase, ManagedColorfrom .flow_layout import FlowLayoutfrom .buttons_settings_dialog import LISTOFTOOLS, LISTOFSIZES, ButtonsSettingsDialog@@ -50,7 +55,7 @@ class WorkflowButtons(DockWidget):self.bottomBar.setIconSize(QSize(22,22))self.bottomBar.setStyleSheet("QToolBar{spacing:0px; margin:0px;}")barSpacer = QWidget(self.bottomBar)- barSpacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)+ barSpacer.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)self.bottomBar.addWidget(barSpacer)self.bottomLayout.addWidget(self.bottomBar)@@ -129,7 +134,7 @@ class WorkflowButtons(DockWidget):def openSettingsDialog(self):newDialog = ButtonsSettingsDialog(self, self.buttonsContentList, self.sizeIndex, self.settingsButtonPosition)- newDialog.exec_()+ newDialog.exec()if newDialog.result() == 1:self.buttonsContentList = newDialog.buttonsContentListself.sizeIndex = newDialog.sizeIndex@@ -194,7 +199,7 @@ class CustomButton(QToolButton):dock_widget_factory = DockWidgetFactory(DOCKER_ID,- DockWidgetFactoryBase.DockRight,+ DockWidgetFactoryBase.DockPosition.DockRight,WorkflowButtons)INSTANCE.addDockWidgetFactory(dock_widget_factory)