From 579371fd7cfe3b5f48a3eac2415ab28d1e26d851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 1 Oct 2024 12:18:17 +0200 Subject: [PATCH] [qt6] Replace all `PySide2/shiboken2` imports by `PySide6/shiboken6` --- COPYING.md | 2 +- meshroom/common/qt.py | 6 +++--- meshroom/ui/app.py | 10 +++++----- meshroom/ui/commands.py | 4 ++-- meshroom/ui/components/__init__.py | 2 +- meshroom/ui/components/clipboard.py | 4 ++-- meshroom/ui/components/csvData.py | 4 ++-- meshroom/ui/components/edge.py | 6 +++--- meshroom/ui/components/filepath.py | 4 ++-- meshroom/ui/components/scene3D.py | 8 ++++---- meshroom/ui/components/scriptEditor.py | 2 +- meshroom/ui/components/thumbnail.py | 4 ++-- meshroom/ui/graph.py | 2 +- meshroom/ui/palette.py | 6 +++--- meshroom/ui/reconstruction.py | 4 ++-- meshroom/ui/utils.py | 10 +++++----- tests/test_model.py | 2 +- 17 files changed, 40 insertions(+), 40 deletions(-) diff --git a/COPYING.md b/COPYING.md index d0144329..6a168fc6 100644 --- a/COPYING.md +++ b/COPYING.md @@ -15,7 +15,7 @@ Meshroom is licensed under the [MPL2 license](LICENSE-MPL2.md). Copyright (c) 2001-2018 Python Software Foundation. Distributed under the [PSFL V2 license](https://www.python.org/download/releases/2.7/license/). - * __Qt/PySide2__ + * __Qt/PySide6__ [https://www.qt.io](https://www.qt.io) Copyright (C) 2018 The Qt Company Ltd and other contributors. Distributed under the [LGPL V3 license](https://opensource.org/licenses/LGPL-3.0). diff --git a/meshroom/common/qt.py b/meshroom/common/qt.py index 438a7537..80a09504 100644 --- a/meshroom/common/qt.py +++ b/meshroom/common/qt.py @@ -1,5 +1,5 @@ -from PySide2 import QtCore, QtQml -import shiboken2 +from PySide6 import QtCore, QtQml +import shiboken6 class QObjectListModel(QtCore.QAbstractListModel): @@ -285,7 +285,7 @@ class QObjectListModel(QtCore.QAbstractListModel): def _dereferenceItem(self, item): # Ask for object deletion if parented to the model - if shiboken2.isValid(item) and item.parent() == self: + if shiboken6.isValid(item) and item.parent() == self: # delay deletion until the next event loop # This avoids warnings when the QML engine tries to evaluate (but should not) # an object that has already been deleted diff --git a/meshroom/ui/app.py b/meshroom/ui/app.py index 0a2de795..f9bc827c 100644 --- a/meshroom/ui/app.py +++ b/meshroom/ui/app.py @@ -4,10 +4,10 @@ import re import argparse import json -from PySide2 import QtCore -from PySide2.QtCore import Qt, QUrl, QJsonValue, qInstallMessageHandler, QtMsgType, QSettings -from PySide2.QtGui import QIcon -from PySide2.QtWidgets import QApplication +from PySide6 import QtCore +from PySide6.QtCore import Qt, QUrl, QJsonValue, qInstallMessageHandler, QtMsgType, QSettings +from PySide6.QtGui import QIcon +from PySide6.QtWidgets import QApplication import meshroom from meshroom.core import nodesDesc @@ -188,7 +188,7 @@ class MeshroomApp(QApplication): def __init__(self, args): meshroom.core.initPipelines() - QtArgs = [args[0], '-style', 'fusion'] + args[1:] # force Fusion style by default + QtArgs = [args[0], '-style', 'Fusion'] + args[1:] # force Fusion style by default args = createMeshroomParser(args) diff --git a/meshroom/ui/commands.py b/meshroom/ui/commands.py index 95a54025..47be0a33 100755 --- a/meshroom/ui/commands.py +++ b/meshroom/ui/commands.py @@ -2,8 +2,8 @@ import logging import traceback from contextlib import contextmanager -from PySide2.QtWidgets import QUndoCommand, QUndoStack -from PySide2.QtCore import Property, Signal +from PySide6.QtGui import QUndoCommand, QUndoStack +from PySide6.QtCore import Property, Signal from meshroom.core.attribute import ListAttribute, Attribute from meshroom.core.graph import GraphModification diff --git a/meshroom/ui/components/__init__.py b/meshroom/ui/components/__init__.py index 260acb04..59c77618 100755 --- a/meshroom/ui/components/__init__.py +++ b/meshroom/ui/components/__init__.py @@ -1,6 +1,6 @@ def registerTypes(): - from PySide2.QtQml import qmlRegisterType + from PySide6.QtQml import qmlRegisterType from meshroom.ui.components.clipboard import ClipboardHelper from meshroom.ui.components.edge import EdgeMouseArea from meshroom.ui.components.filepath import FilepathHelper diff --git a/meshroom/ui/components/clipboard.py b/meshroom/ui/components/clipboard.py index ab95d70c..aaee965a 100644 --- a/meshroom/ui/components/clipboard.py +++ b/meshroom/ui/components/clipboard.py @@ -1,5 +1,5 @@ -from PySide2.QtCore import Slot, QObject -from PySide2.QtGui import QClipboard +from PySide6.QtCore import Slot, QObject +from PySide6.QtGui import QClipboard class ClipboardHelper(QObject): diff --git a/meshroom/ui/components/csvData.py b/meshroom/ui/components/csvData.py index c9ecef2f..f52cabe9 100644 --- a/meshroom/ui/components/csvData.py +++ b/meshroom/ui/components/csvData.py @@ -1,7 +1,7 @@ from meshroom.common.qt import QObjectListModel -from PySide2.QtCore import QObject, Slot, Signal, Property -from PySide2.QtCharts import QtCharts +from PySide6.QtCore import QObject, Slot, Signal, Property +from PySide6 import QtCharts import csv import os diff --git a/meshroom/ui/components/edge.py b/meshroom/ui/components/edge.py index 64a9f0e3..d802d5b6 100755 --- a/meshroom/ui/components/edge.py +++ b/meshroom/ui/components/edge.py @@ -1,6 +1,6 @@ -from PySide2.QtCore import Signal, Property, QPointF, Qt, QObject -from PySide2.QtGui import QPainterPath, QVector2D -from PySide2.QtQuick import QQuickItem +from PySide6.QtCore import Signal, Property, QPointF, Qt, QObject +from PySide6.QtGui import QPainterPath, QVector2D +from PySide6.QtQuick import QQuickItem class MouseEvent(QObject): diff --git a/meshroom/ui/components/filepath.py b/meshroom/ui/components/filepath.py index 411eaf72..ae8124be 100644 --- a/meshroom/ui/components/filepath.py +++ b/meshroom/ui/components/filepath.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # coding:utf-8 -from PySide2.QtCore import QUrl, QFileInfo -from PySide2.QtCore import QObject, Slot +from PySide6.QtCore import QUrl, QFileInfo +from PySide6.QtCore import QObject, Slot import os import glob diff --git a/meshroom/ui/components/scene3D.py b/meshroom/ui/components/scene3D.py index d39ea6f6..7187110a 100644 --- a/meshroom/ui/components/scene3D.py +++ b/meshroom/ui/components/scene3D.py @@ -1,9 +1,9 @@ from math import acos, pi, sqrt, atan2, cos, sin, asin -from PySide2.QtCore import QObject, Slot, QSize, Signal, QPointF -from PySide2.Qt3DCore import Qt3DCore -from PySide2.Qt3DRender import Qt3DRender -from PySide2.QtGui import QVector3D, QQuaternion, QVector2D, QVector4D, QMatrix4x4 +from PySide6.QtCore import QObject, Slot, QSize, Signal, QPointF +from PySide6.Qt3DCore import Qt3DCore +from PySide6.Qt3DRender import Qt3DRender +from PySide6.QtGui import QVector3D, QQuaternion, QVector2D, QVector4D, QMatrix4x4 from meshroom.ui.utils import makeProperty diff --git a/meshroom/ui/components/scriptEditor.py b/meshroom/ui/components/scriptEditor.py index a8326080..da3731ad 100644 --- a/meshroom/ui/components/scriptEditor.py +++ b/meshroom/ui/components/scriptEditor.py @@ -1,4 +1,4 @@ -from PySide2.QtCore import QObject, Slot +from PySide6.QtCore import QObject, Slot from io import StringIO from contextlib import redirect_stdout diff --git a/meshroom/ui/components/thumbnail.py b/meshroom/ui/components/thumbnail.py index 86864593..acfd1591 100644 --- a/meshroom/ui/components/thumbnail.py +++ b/meshroom/ui/components/thumbnail.py @@ -1,7 +1,7 @@ from meshroom.common import Signal -from PySide2.QtCore import QObject, Slot, QSize, QUrl, Qt, QStandardPaths -from PySide2.QtGui import QImageReader, QImageWriter +from PySide6.QtCore import QObject, Slot, QSize, QUrl, Qt, QStandardPaths +from PySide6.QtGui import QImageReader, QImageWriter import os from pathlib import Path diff --git a/meshroom/ui/graph.py b/meshroom/ui/graph.py index 448f2548..3fd8b9ff 100644 --- a/meshroom/ui/graph.py +++ b/meshroom/ui/graph.py @@ -8,7 +8,7 @@ from enum import Enum from threading import Thread, Event, Lock from multiprocessing.pool import ThreadPool -from PySide2.QtCore import Slot, QJsonValue, QObject, QUrl, Property, Signal, QPoint +from PySide6.QtCore import Slot, QJsonValue, QObject, QUrl, Property, Signal, QPoint from meshroom.core import sessionUid from meshroom.common.qt import QObjectListModel diff --git a/meshroom/ui/palette.py b/meshroom/ui/palette.py index 0d87ec21..4d968709 100644 --- a/meshroom/ui/palette.py +++ b/meshroom/ui/palette.py @@ -1,6 +1,6 @@ -from PySide2.QtCore import QObject, Qt, Slot, Property, Signal -from PySide2.QtGui import QPalette, QColor -from PySide2.QtWidgets import QApplication +from PySide6.QtCore import QObject, Qt, Slot, Property, Signal +from PySide6.QtGui import QPalette, QColor +from PySide6.QtWidgets import QApplication class PaletteManager(QObject): diff --git a/meshroom/ui/reconstruction.py b/meshroom/ui/reconstruction.py index e1aaaa5f..3f1acb6c 100755 --- a/meshroom/ui/reconstruction.py +++ b/meshroom/ui/reconstruction.py @@ -6,8 +6,8 @@ from collections.abc import Iterable from multiprocessing.pool import ThreadPool from threading import Thread -from PySide2.QtCore import QObject, Slot, Property, Signal, QUrl, QSizeF, QPoint -from PySide2.QtGui import QMatrix4x4, QMatrix3x3, QQuaternion, QVector3D, QVector2D +from PySide6.QtCore import QObject, Slot, Property, Signal, QUrl, QSizeF, QPoint +from PySide6.QtGui import QMatrix4x4, QMatrix3x3, QQuaternion, QVector3D, QVector2D import meshroom.core import meshroom.common diff --git a/meshroom/ui/utils.py b/meshroom/ui/utils.py index e09408ea..5e6339ec 100755 --- a/meshroom/ui/utils.py +++ b/meshroom/ui/utils.py @@ -1,12 +1,12 @@ import os import time -from PySide2.QtCore import QFileSystemWatcher, QUrl, Slot, QTimer, Property, QObject -from PySide2.QtQml import QQmlApplicationEngine +from PySide6.QtCore import QFileSystemWatcher, QUrl, Slot, QTimer, Property, QObject +from PySide6.QtQml import QQmlApplicationEngine try: - from PySide2 import shiboken2 + from PySide6 import shiboken6 except Exception: - import shiboken2 + import shiboken6 class QmlInstantEngine(QQmlApplicationEngine): @@ -237,7 +237,7 @@ def makeProperty(T, attributeName, notify=None, resetOnDestroy=False): setattr(instance, resetCallbackName, lambda self=instance, *args: setter(self, None)) resetCallback = getattr(instance, resetCallbackName, None) - if resetCallback and currentValue and shiboken2.isValid(currentValue): + if resetCallback and currentValue and shiboken6.isValid(currentValue): currentValue.destroyed.disconnect(resetCallback) setattr(instance, attributeName, value) if resetCallback and value: diff --git a/tests/test_model.py b/tests/test_model.py index 1c05c3ca..b7ddc2fe 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -1,6 +1,6 @@ import pytest -from PySide2.QtCore import QObject, Property +from PySide6.QtCore import QObject, Property from meshroom.common.core import CoreDictModel from meshroom.common.qt import QObjectListModel, QTypedObjectListModel