forked from qt-creator/qt-creator
QmlDesigner: Hide root window when rendering using qml-renderer puppet
Window needs to have visible set to false as initial property or the window will briefly flash on the screen. Also suppress mac task bar icon. Fixes: QDS-15008 Change-Id: I2ee58b205bbf14ef8928a8adc6052fffa140e6b5 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -22,6 +22,9 @@ constexpr int DEFAULT_MAX_DIM = 1024;
|
|||||||
|
|
||||||
void QmlRenderer::initCoreApp()
|
void QmlRenderer::initCoreApp()
|
||||||
{
|
{
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
qputenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM", "true");
|
||||||
|
#endif
|
||||||
#if defined QT_WIDGETS_LIB
|
#if defined QT_WIDGETS_LIB
|
||||||
createCoreApp<QApplication>();
|
createCoreApp<QApplication>();
|
||||||
#else
|
#else
|
||||||
@@ -144,9 +147,14 @@ bool QmlRenderer::setupRenderer()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject *renderObj = component.create();
|
// Window components will flash the window briefly if we don't initialize visible to false
|
||||||
|
QVariantMap initialProps;
|
||||||
|
initialProps["visible"] = false;
|
||||||
|
QObject *renderObj = component.createWithInitialProperties(initialProps);
|
||||||
|
|
||||||
if (renderObj) {
|
if (renderObj) {
|
||||||
|
if (!qobject_cast<QWindow *>(renderObj))
|
||||||
|
renderObj->setProperty("visible", true);
|
||||||
#ifdef QUICK3D_MODULE
|
#ifdef QUICK3D_MODULE
|
||||||
QQuickItem *contentItem3D = nullptr;
|
QQuickItem *contentItem3D = nullptr;
|
||||||
renderObj->setParent(m_window->contentItem());
|
renderObj->setParent(m_window->contentItem());
|
||||||
@@ -195,11 +203,6 @@ bool QmlRenderer::setupRenderer()
|
|||||||
// Hack to render Window items: reparent window content to m_window->contentItem()
|
// Hack to render Window items: reparent window content to m_window->contentItem()
|
||||||
setRenderSize(renderWindow->size());
|
setRenderSize(renderWindow->size());
|
||||||
m_containerItem = m_window->contentItem();
|
m_containerItem = m_window->contentItem();
|
||||||
// Suppress the original window.
|
|
||||||
// Offscreen position ensures we don't get even brief flash of it.
|
|
||||||
renderWindow->setVisible(false);
|
|
||||||
renderWindow->resize(2, 2);
|
|
||||||
renderWindow->setPosition(-10000, -10000);
|
|
||||||
const QList<QQuickItem *> childItems = renderWindow->contentItem()->childItems();
|
const QList<QQuickItem *> childItems = renderWindow->contentItem()->childItems();
|
||||||
for (QQuickItem *item : childItems) {
|
for (QQuickItem *item : childItems) {
|
||||||
item->setParent(m_window->contentItem());
|
item->setParent(m_window->contentItem());
|
||||||
|
Reference in New Issue
Block a user