diff options
author | Christian Stromme <christian.stromme@qt.io> | 2018-05-31 23:47:42 +0200 |
---|---|---|
committer | Andy Nichols <andy.nichols@qt.io> | 2018-06-01 13:46:25 +0000 |
commit | f9c4dde00969738f515bace791ae5c2dd1b8c456 (patch) | |
tree | 4646f1d23a91bd2b02eee684ed74e4e3ad658b88 | |
parent | 00278e1e10b3c53beb7d13d44ed5e0bc829f8127 (diff) |
Set player mode on components
Component players inherits the player mode from its parent player, and
if the mode changes after creating, then that change should be applied
to all component players as well.
Change-Id: I8058f8afc97913d2b953b8a6468b44747346ce70
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r-- | src/runtime/q3dsslideplayer.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/runtime/q3dsslideplayer.cpp b/src/runtime/q3dsslideplayer.cpp index f1baf01..48b3ef1 100644 --- a/src/runtime/q3dsslideplayer.cpp +++ b/src/runtime/q3dsslideplayer.cpp @@ -357,6 +357,30 @@ float Q3DSSlidePlayer::position() const void Q3DSSlidePlayer::setMode(Q3DSSlidePlayer::PlayerMode mode) { m_mode = mode; + if (!m_data.slideDeck) + return; + + Q3DSSlide *currentSlide = m_data.slideDeck->currentSlide(); + Q_ASSERT(currentSlide); + + const auto notifyComponentPlayers = [mode](Q3DSSlide *slide) { + if (!slide) + return; + + const auto &objects = slide->objects(); + std::find_if(objects.constBegin(), objects.constEnd(), [mode](Q3DSGraphObject *obj) { + if (obj->type() == Q3DSGraphObject::Component && obj->state() == Q3DSGraphObject::Enabled) { + Q3DSComponentNode *comp = static_cast<Q3DSComponentNode *>(obj); + Q3DSSlide *compSlide = comp->currentSlide(); + Q3DSSlidePlayer *player = compSlide->attached<Q3DSSlideAttached>()->slidePlayer; + player->setMode(mode); + } + return false; + }); + }; + notifyComponentPlayers(static_cast<Q3DSSlide *>(currentSlide->parent())); + notifyComponentPlayers(currentSlide); + reload(); } @@ -476,6 +500,7 @@ void Q3DSSlidePlayer::setSlideDeck(Q3DSSlideDeck *slideDeck) if (!compMasterData->slidePlayer) { qCDebug(lcSlidePlayer, "No player found for Component \"%s\", adding one", qPrintable(comp->name())); compMasterData->slidePlayer = new Q3DSSlidePlayer(m_animationManager, m_sceneManager, comp, this); + compMasterData->slidePlayer->setMode(mode()); compMasterSlide->attached<Q3DSSlideAttached>()->entity = comp->attached()->entity; Q3DSSlide *s = static_cast<Q3DSSlide *>(compMasterSlide->firstChild()); while (s) { |