Hide the video overlay when the QML element is hidden
An display invalid rect is used for invisible QML items. Change-Id: Ifb2a25f1c5387ab8cef1359ac6c3e2f90a42cd10 Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@gmail.com>
This commit is contained in:
committed by
Qt by Nokia
parent
06302999da
commit
bce8b5486d
@@ -48,7 +48,8 @@
|
|||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QDeclarativeVideoWindowBackend::QDeclarativeVideoWindowBackend(QDeclarativeVideoOutput *parent)
|
QDeclarativeVideoWindowBackend::QDeclarativeVideoWindowBackend(QDeclarativeVideoOutput *parent)
|
||||||
: QDeclarativeVideoBackend(parent)
|
: QDeclarativeVideoBackend(parent),
|
||||||
|
m_visible(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,11 +77,21 @@ bool QDeclarativeVideoWindowBackend::init(QMediaService *service)
|
|||||||
void QDeclarativeVideoWindowBackend::itemChange(QQuickItem::ItemChange change,
|
void QDeclarativeVideoWindowBackend::itemChange(QQuickItem::ItemChange change,
|
||||||
const QQuickItem::ItemChangeData &changeData)
|
const QQuickItem::ItemChangeData &changeData)
|
||||||
{
|
{
|
||||||
if (change == QQuickItem::ItemSceneChange && m_videoWindowControl) {
|
if (!m_videoWindowControl)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (change) {
|
||||||
|
case QQuickItem::ItemVisibleHasChanged:
|
||||||
|
m_visible = changeData.boolValue;
|
||||||
|
updateGeometry();
|
||||||
|
break;
|
||||||
|
case QQuickItem::ItemSceneChange:
|
||||||
if (changeData.window)
|
if (changeData.window)
|
||||||
m_videoWindowControl->setWinId(changeData.window->winId());
|
m_videoWindowControl->setWinId(changeData.window->winId());
|
||||||
else
|
else
|
||||||
m_videoWindowControl->setWinId(0);
|
m_videoWindowControl->setWinId(0);
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +126,7 @@ void QDeclarativeVideoWindowBackend::updateGeometry()
|
|||||||
};
|
};
|
||||||
|
|
||||||
const QRectF canvasRect = q->mapRectToScene(QRectF(0, 0, q->width(), q->height()));
|
const QRectF canvasRect = q->mapRectToScene(QRectF(0, 0, q->width(), q->height()));
|
||||||
m_videoWindowControl->setDisplayRect(canvasRect.toAlignedRect());
|
m_videoWindowControl->setDisplayRect(m_visible ? canvasRect.toAlignedRect() : QRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode *QDeclarativeVideoWindowBackend::updatePaintNode(QSGNode *oldNode,
|
QSGNode *QDeclarativeVideoWindowBackend::updatePaintNode(QSGNode *oldNode,
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<QVideoWindowControl> m_videoWindowControl;
|
QPointer<QVideoWindowControl> m_videoWindowControl;
|
||||||
|
bool m_visible;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -292,10 +292,13 @@ void BbVideoWindowControl::updateVideoPosition()
|
|||||||
if (m_window != 0) {
|
if (m_window != 0) {
|
||||||
const int position[2] = { topLeft.x(), topLeft.y() };
|
const int position[2] = { topLeft.x(), topLeft.y() };
|
||||||
const int size[2] = { width, height };
|
const int size[2] = { width, height };
|
||||||
|
const int visible = m_displayRect.isValid();
|
||||||
if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, position) != 0)
|
if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, position) != 0)
|
||||||
perror("Setting video position failed");
|
perror("Setting video position failed");
|
||||||
if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, size) != 0)
|
if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, size) != 0)
|
||||||
perror("Setting video size failed");
|
perror("Setting video size failed");
|
||||||
|
if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_VISIBLE, &visible) != 0)
|
||||||
|
perror("Setting video visibility failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user