Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions Render/subcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from threading import Thread, Event
import pathlib
import configparser

import sys

import FreeCADGui as Gui
import FreeCAD as App
Expand All @@ -69,13 +69,16 @@
Qt,
QEventLoop,
)

from PySide.QtGui import (
QWidget,
QWindow,
QMdiSubWindow,
QGuiApplication,
)

from PySide.QtWidgets import QWidget, QLabel, QVBoxLayout


class ConnectionServer(QObject):
"""A server to connect the host process and the sub process."""
Expand Down Expand Up @@ -336,17 +339,34 @@ def start(self):
def attach_process(self, winid):
"""Attach subprocess to FreeCAD Gui."""
# Create container and embed process inside
self.window = QWindow.fromWinId(winid)
self.window.setObjectName("RenderWindowFromWinid")
self.container = QWidget.createWindowContainer(
self.window,
parent=None,
flags=Qt.FramelessWindowHint | Qt.ForeignWindow,
)
self.container.setObjectName("RenderProcessWindowContainer")
self.setWidget(self.container)
self.container.setParent(self)
self.show()
# QWindow.fromWinId is not supported on macOS and QT <6, so open a new window instead.
if sys.platform == "darwin":
print(
"QWindow.fromWinId not supported on macOS – showing placeholder window."
)
self.container = QWidget()
layout = QVBoxLayout(self.container)
label = QLabel(
"Renderer running in external window.\nEmbedding not supported on macOS."
)
label.setAlignment(Qt.AlignCenter)
layout.addWidget(label)
self.setWidget(self.container)
self.container.setParent(self)
self.show()
return
else:
self.window = QWindow.fromWinId(winid)
self.window.setObjectName("RenderWindowFromWinid")
self.container = QWidget.createWindowContainer(
self.window,
parent=None,
flags=Qt.FramelessWindowHint | Qt.ForeignWindow,
)
self.container.setObjectName("RenderProcessWindowContainer")
self.setWidget(self.container)
self.container.setParent(self)
self.show()

@Slot()
def detach_process(self):
Expand Down