diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-02-21 14:10:19 +0200 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-02-21 14:00:28 +0000 |
commit | 05ec6f079013b7000288f43e4f219bce5ec2952b (patch) | |
tree | b5ea5ea8b122745c4beeba150065e6df3bb80e62 | |
parent | c754ca6ea03f245a6f0d59244f4bfac3695c5dbf (diff) |
Implement variants UI on the slide view
Task-number: QT3DS-3087
Change-Id: Ie402e48d2a948bde32388d0ea4c4245a87e94e21
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
12 files changed, 163 insertions, 59 deletions
diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp index c86a5dba..8ce3d6c0 100644 --- a/src/Authoring/Studio/Application/StudioApp.cpp +++ b/src/Authoring/Studio/Application/StudioApp.cpp @@ -1730,6 +1730,7 @@ bool CStudioApp::OnLoadDocument(const QString &inDocument, bool inShowStartupDia m_core->getProjectFile().loadSubpresentationsAndDatainputs(m_subpresentations, m_dataInputDialogItems); m_core->getProjectFile().loadVariants(); + GetViews()->getMainFrame()->getSlideView()->refreshVariants(); getRenderer().RegisterSubpresentations(m_subpresentations); m_authorZoom = false; diff --git a/src/Authoring/Studio/MainFrm.cpp b/src/Authoring/Studio/MainFrm.cpp index a2a712d2..dcabd529 100644 --- a/src/Authoring/Studio/MainFrm.cpp +++ b/src/Authoring/Studio/MainFrm.cpp @@ -60,6 +60,7 @@ #include "ProjectView.h" #include "RowTree.h" #include "WidgetControl.h" +#include "SlideView.h" #include <QtGui/qevent.h> #include <QtGui/qdesktopservices.h> @@ -1920,6 +1921,12 @@ TimelineWidget *CMainFrame::getTimelineWidget() const return static_cast<TimelineWidget *>(control->getControl()); } +SlideView *CMainFrame::getSlideView() const +{ + return static_cast<SlideView *>(m_paletteManager->GetControl(CPaletteManager::CONTROLTYPE_SLIDE) + ->widget()); +} + CRecentItems *CMainFrame::GetRecentItems() { return m_recentItems.data(); diff --git a/src/Authoring/Studio/MainFrm.h b/src/Authoring/Studio/MainFrm.h index dfcf887c..6c3a2ce7 100644 --- a/src/Authoring/Studio/MainFrm.h +++ b/src/Authoring/Studio/MainFrm.h @@ -56,6 +56,7 @@ class ITimelineTimebar; class RemoteDeploymentSender; class TimelineWidget; class CStudioPreferencesPropSheet; +class SlideView; #ifdef QT_NAMESPACE using namespace QT_NAMESPACE; @@ -235,6 +236,7 @@ public: void onCtrlNPressed(); TimelineWidget *getTimelineWidget() const; + SlideView *getSlideView() const; void EditPreferences(short inPageIndex); diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp index e7dbfe7f..5cf47d1f 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp @@ -130,7 +130,7 @@ void InspectorControlModel::setInspectable(CInspectableBase *inInspectable) if (m_notifier.get() == nullptr) { m_notifier = signalProvider->ConnectInstancePropertyValue( - std::bind(&InspectorControlModel::notifyInstancePropertyValue, + std::bind(&InspectorControlModel::onPropertyChanged, this, std::placeholders::_1, std::placeholders::_2)); } if (m_slideNotifier.get() == nullptr) { @@ -173,14 +173,20 @@ CInspectableBase *getReferenceMaterialInspectable(CInspectableBase *inspectBase) return nullptr; } -void InspectorControlModel::notifyInstancePropertyValue(qt3dsdm::Qt3DSDMInstanceHandle inHandle, - qt3dsdm::Qt3DSDMPropertyHandle inProperty) +void InspectorControlModel::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, + qt3dsdm::Qt3DSDMPropertyHandle inProperty) { auto doc = g_StudioApp.GetCore()->GetDoc(); - const auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem() - ->GetClientDataModelBridge(); - if (!bridge->IsSceneGraphInstance(inHandle)) + const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); + if (!bridge->IsSceneGraphInstance(inInstance)) + return; + + if (inProperty == bridge->GetLayer().m_variants) { + // only update the variants model if its property changes + m_variantsModel->refresh(); return; + } + bool changed = false; for (int row = 0; row < m_groupElements.count(); ++row) { auto group = m_groupElements[row]; @@ -193,7 +199,7 @@ void InspectorControlModel::notifyInstancePropertyValue(qt3dsdm::Qt3DSDMInstance imageInstance = doc->GetDocumentReader().GetImageInstanceForProperty( property->m_instance, property->m_property); } - if (property->m_property == inProperty || imageInstance == inHandle) { + if (property->m_property == inProperty || imageInstance == inInstance) { updatePropertyValue(property); changed = true; } @@ -1241,9 +1247,6 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c stringValue = stringValue.mid(index + 1); } - if (bridge->IsLayerInstance(instance)) - m_variantsModel->refresh(); - element->m_value = stringValue; } // intentional fall-through for other String-derived datatypes case qt3dsdm::DataModelDataType::StringOrInt: @@ -1259,7 +1262,7 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c } auto slideSystem = studioSystem->GetSlideSystem(); - if (element->m_title == QStringLiteral("Play Mode")) { + if (element->m_title == QLatin1String("Play Mode")) { std::pair<bool, bool> slideData( getSlideCharacteristics(element->m_instance, *studioSystem->GetSlideCore(), *slideSystem)); @@ -1267,7 +1270,7 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c bool hasPreviousSlide(slideData.second); if (!hasNextSlide && !hasPreviousSlide) stringlist.removeAll("Play Through To..."); - } else if (element->m_title == QStringLiteral("Play Through To")) { + } else if (element->m_title == QLatin1String("Play Through To")) { // the code duplication is intentional as we may ask for slide characteristics // only if the property refers to slides std::pair<bool, bool> slideData( @@ -1311,7 +1314,8 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c } element->m_value = QString(selectedIndex > 0 ? stringlist[selectedIndex] - : stringlist.first()).replace("|separator", ""); + : stringlist.first()).replace(QLatin1String("|separator"), + QString()); } element->m_values = stringlist; } else if (element->m_propertyType == qt3dsdm::AdditionalMetaDataType::Import) { diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h index 21e6b3a7..23205050 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h @@ -220,7 +220,8 @@ private: void updatePropertyValue(InspectorControlBase *element) const; void rebuildTree(); void refreshTree(); - void notifyInstancePropertyValue(qt3dsdm::Qt3DSDMInstanceHandle, qt3dsdm::Qt3DSDMPropertyHandle inProperty); + void onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, + qt3dsdm::Qt3DSDMPropertyHandle inProperty); void updateAnimateToggleState(InspectorControlBase *inItem); void updateControlledToggleState(InspectorControlBase *inItem) const; diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp index 0dda40aa..38e4d6f9 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp @@ -62,6 +62,7 @@ #include "VariantTagDialog.h" #include "Views.h" #include "MainFrm.h" +#include "SlideView.h" #include "TimelineWidget.h" #include <QtCore/qtimer.h> @@ -480,6 +481,7 @@ void InspectorControlView::showTagContextMenu(int x, int y, const QString &group connect(actionDelete, &QAction::triggered, this, [&]() { g_StudioApp.GetCore()->getProjectFile().deleteVariantTag(group, tag); g_StudioApp.GetViews()->getMainFrame()->getTimelineWidget()->refreshVariants(); + g_StudioApp.GetViews()->getMainFrame()->getSlideView()->refreshVariants(); }); theContextMenu.exec(mapToGlobal({x, y})); @@ -506,12 +508,16 @@ void InspectorControlView::showGroupContextMenu(int x, int y, const QString &gro const auto variantsDef = g_StudioApp.GetCore()->getProjectFile().variantsDef(); QColor newColor = this->showColorDialog(variantsDef[group].m_color); projectFile.changeVariantGroupColor(group, newColor.name()); + // no need to refresh variants in the timeline widget as it references the group color in + // the project file m_variants, and a redraw is triggered upon color selection dialog close. + g_StudioApp.GetViews()->getMainFrame()->getSlideView()->refreshVariants(); }); auto actionDelete = theContextMenu.addAction(QObject::tr("Delete Group")); connect(actionDelete, &QAction::triggered, this, [&]() { projectFile.deleteVariantGroup(group); g_StudioApp.GetViews()->getMainFrame()->getTimelineWidget()->refreshVariants(); + g_StudioApp.GetViews()->getMainFrame()->getSlideView()->refreshVariants(); }); theContextMenu.exec(mapToGlobal({x, y})); diff --git a/src/Authoring/Studio/Palettes/Inspector/VariantsGroupModel.cpp b/src/Authoring/Studio/Palettes/Inspector/VariantsGroupModel.cpp index d43232d2..36464ae3 100644 --- a/src/Authoring/Studio/Palettes/Inspector/VariantsGroupModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/VariantsGroupModel.cpp @@ -36,6 +36,7 @@ #include "VariantTagDialog.h" #include "StudioUtils.h" #include "Dialogs.h" + #include <QtCore/qsavefile.h> VariantsGroupModel::VariantsGroupModel(QObject *parent) diff --git a/src/Authoring/Studio/Palettes/Slide/SlideModel.cpp b/src/Authoring/Studio/Palettes/Slide/SlideModel.cpp index 75d5a266..eba5d044 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideModel.cpp +++ b/src/Authoring/Studio/Palettes/Slide/SlideModel.cpp @@ -56,6 +56,10 @@ QVariant SlideModel::data(const QModelIndex &index, int role) const return slideName(m_slides[row]); case SelectedRole: return row == m_selectedRow; + case VariantsRole: + int slideIdx = GetDoc()->GetStudioSystem()->GetSlideSystem()->GetSlideIndex(m_slides[row]); + if (slideIdx < m_variants.size()) + return m_variants.at(slideIdx); } return {}; @@ -91,7 +95,7 @@ bool SlideModel::setData(const QModelIndex &index, const QVariant &value, int ro } Q_EMIT dataChanged(this->index(0, 0), this->index(rowCount() - 1, 0), {role}); - return true; + break; } default: return false; @@ -112,6 +116,7 @@ QHash<int, QByteArray> SlideModel::roleNames() const { auto names = QAbstractListModel::roleNames(); names.insert(NameRole, "name"); + names.insert(VariantsRole, "variants"); names.insert(SelectedRole, "selected"); return names; @@ -347,6 +352,61 @@ void SlideModel::setSlideName(const qt3dsdm::Qt3DSDMSlideHandle &handle, const Q } } +void SlideModel::refreshVariants(const QStringList &variants) +{ + m_variants.clear(); + + if (variants.isEmpty()) { + const auto *slideSystem = GetDoc()->GetStudioSystem()->GetSlideSystem(); + int slideCount = slideSystem->GetSlideCount(slideSystem->GetMasterSlide( + GetDoc()->GetActiveSlide())); + + QString vTemplate = QStringLiteral(" <font color='%1'>%2</font>"); + QVector<QHash<QString, int>> counts(slideCount); // <group, total count tags> + + const auto propertySystem = GetDoc()->GetPropertySystem(); + const auto layers = GetDoc()->getLayers(); + for (auto layer : layers) { + int slideIdx = slideIndex(slideSystem->GetAssociatedSlide(layer)); + qt3dsdm::SValue sValue; + if (propertySystem->GetInstancePropertyValue(layer, GetBridge()->GetLayer().m_variants, + sValue)) { + QString propVal = QString::fromWCharArray(qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue) + ->GetData()); + if (!propVal.isEmpty()) { + QStringList tagPairs = propVal.split(QLatin1Char(',')); + for (int i = 0; i < tagPairs.size(); ++i) { + QString group = tagPairs[i].left(tagPairs[i].indexOf(QLatin1Char(':'))); + ++counts[slideIdx][group]; + } + } + } + } + + // add master slide layers counts to other layers + const auto keys = counts[0].keys(); + for (int i = 1; i < slideCount; ++i) { + for (auto g : keys) + counts[i][g] += counts[0][g]; + } + + // update the variants counts model (m_variants) + auto variantsDef = g_StudioApp.GetCore()->getProjectFile().variantsDef(); + for (int i = 0; i < counts.size(); ++i) { // slides indexes + QString slideVariants; + const auto keys = counts[i].keys(); + for (auto g : keys) // variants groups + slideVariants.append(vTemplate.arg(variantsDef[g].m_color).arg(counts[i][g])); + + m_variants << slideVariants; + } + } else { + m_variants = variants; + } + + Q_EMIT dataChanged(this->index(0, 0), this->index(rowCount() - 1, 0), {VariantsRole}); +} + CDoc *SlideModel::GetDoc() const { return g_StudioApp.GetCore()->GetDoc(); @@ -375,10 +435,10 @@ void SlideModel::refreshSlideLabel(qt3dsdm::Qt3DSDMInstanceHandle instanceHandle if (m_slides[i] == slideHandle) { setData(index(i, 0), GetBridge()->GetName(instanceHandle).toQString(), SlideModel::NameRole); + break; } } } - } // Set selected slide highlight on UI diff --git a/src/Authoring/Studio/Palettes/Slide/SlideModel.h b/src/Authoring/Studio/Palettes/Slide/SlideModel.h index 1de717cd..6f2de22f 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideModel.h +++ b/src/Authoring/Studio/Palettes/Slide/SlideModel.h @@ -44,7 +44,8 @@ public: enum Roles { NameRole = Qt::DisplayRole, HandleRole = Qt::UserRole + 1, - SelectedRole + SelectedRole, + VariantsRole }; SlideModel(int slideCount, QObject *parent = nullptr); @@ -76,6 +77,8 @@ public: void refreshSlideLabel(qt3dsdm::Qt3DSDMInstanceHandle instanceHandle, qt3dsdm::Qt3DSDMPropertyHandle propertyHandle); void setSelectedSlideIndex(const QModelIndex &index); + void refreshVariants(const QStringList &variants = {}); + QStringList variants() const { return m_variants; } private: bool hasSlideWithName(const QString &name) const; @@ -89,6 +92,7 @@ private: int m_selectedRow = -1; int m_rearrangeStartRow = -1; int m_rearrangeEndRow = -1; + QStringList m_variants; // model for variants tags display QHash<qt3dsdm::Qt3DSDMInstanceHandle, qt3dsdm::Qt3DSDMSlideHandle> m_slideLookupHash; }; diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp index 302d3025..e459deda 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp @@ -27,11 +27,9 @@ ****************************************************************************/ #include "SlideView.h" -#include "CColor.h" #include "Core.h" #include "Dispatch.h" #include "Doc.h" -#include "Literals.h" #include "StudioPreferences.h" #include "SlideModel.h" #include "StudioApp.h" @@ -45,22 +43,19 @@ #include "Qt3DSDMSlides.h" #include "Dialogs.h" -#include <QtCore/qcoreapplication.h> #include <QtCore/qtimer.h> #include <QtQml/qqmlcontext.h> #include <QtQml/qqmlengine.h> -#include <QtWidgets/qdesktopwidget.h> -#include <QtWidgets/qdockwidget.h> SlideView::SlideView(QWidget *parent) : QQuickWidget(parent) , m_MasterSlideModel(new SlideModel(1, this)) , m_SlidesModel(new SlideModel(0, this)) + , m_CurrentModel(m_SlidesModel) , m_ActiveRoot(0) , m_toolTip(tr("No Controller")) { g_StudioApp.GetCore()->GetDispatch()->AddPresentationChangeListener(this); setResizeMode(QQuickWidget::SizeRootObjectToView); - m_CurrentModel = m_SlidesModel; QTimer::singleShot(0, this, &SlideView::initialize); } @@ -82,10 +77,7 @@ void SlideView::setShowMasterSlide(bool show) if (show == currentIsMaster) return; - if (show) - m_CurrentModel = m_MasterSlideModel; - else - m_CurrentModel = m_SlidesModel; + m_CurrentModel = show ? m_MasterSlideModel : m_SlidesModel; // We need to get the first slide in the correct master mode CDoc *theDoc = GetDoc(); @@ -124,8 +116,6 @@ void SlideView::showControllerDialog(const QPoint &point) m_dataInputSelector->setData(dataInputList, currCtr); CDialogs::showWidgetBrowser(this, m_dataInputSelector, point, CDialogs::WidgetBrowserAlign::ToolButton); - - return; } bool SlideView::toolTipsEnabled() @@ -142,7 +132,7 @@ QSize SlideView::minimumSizeHint() const { // prevent datainput control indicator from overlapping // with slide name too much when panel is minimised - return {80, 0}; + return {100, 0}; } void SlideView::deselectAll() @@ -209,8 +199,9 @@ void SlideView::OnNewPresentation() // Set up listener for the name changes to slide m_Connections.push_back(theSignalProvider->ConnectInstancePropertyValue( - std::bind(&SlideModel::refreshSlideLabel, m_SlidesModel, + std::bind(&SlideView::onPropertyChanged, this, std::placeholders::_1, std::placeholders::_2))); + // Set up listener for undo/redo changes in order to update // slide datainput control CDispatch *theDispatch = g_StudioApp.GetCore()->GetDispatch(); @@ -290,18 +281,16 @@ void SlideView::onDataInputChange(int handle, int instance, const QString &dataI m_toolTip = tr("No Controller"); } qt3dsdm::Qt3DSDMPropertyHandle ctrldProp; - if (bridge->GetObjectType(slideRoot) == EStudioObjectType::OBJTYPE_SCENE) { + if (bridge->GetObjectType(slideRoot) == EStudioObjectType::OBJTYPE_SCENE) ctrldProp = bridge->GetObjectDefinitions().m_Scene.m_ControlledProperty; - } else if (bridge->GetObjectType(slideRoot) == - EStudioObjectType::OBJTYPE_COMPONENT) { + else if (bridge->GetObjectType(slideRoot) == EStudioObjectType::OBJTYPE_COMPONENT) ctrldProp = bridge->GetObjectDefinitions().m_Component.m_ControlledProperty; - } else { + else Q_ASSERT(false); - } qt3dsdm::SValue controlledPropertyVal; - doc->GetStudioSystem()->GetPropertySystem()->GetInstancePropertyValue( - slideRoot, ctrldProp, controlledPropertyVal); + doc->GetStudioSystem()->GetPropertySystem()->GetInstancePropertyValue(slideRoot, ctrldProp, + controlledPropertyVal); // To indicate that slide transitions are controlled by data input, // we set "controlled property" of this scene to contain the name of @@ -309,27 +298,27 @@ void SlideView::onDataInputChange(int handle, int instance, const QString &dataI // If we have existing slide control in this root element, replace it. // Otherwise just append slide control string to controlledproperty // (it might already contain timeline control information) - auto existingCtrl = qt3dsdm::get<QString>(controlledPropertyVal); - if (existingCtrl.contains("@slide")) { - int slideStrPos = existingCtrl.indexOf("@slide"); + QString existingCtrl = qt3dsdm::get<QString>(controlledPropertyVal); + if (existingCtrl.contains(QLatin1String("@slide"))) { + int slideStrPos = existingCtrl.indexOf(QLatin1String("@slide")); // find the controlling datainput name and build the string to replace - int ctrStrPos = existingCtrl.lastIndexOf("$", slideStrPos - 2); + int ctrStrPos = existingCtrl.lastIndexOf(QLatin1Char('$'), slideStrPos - 2); QString prevCtrler = existingCtrl.mid(ctrStrPos, slideStrPos - ctrStrPos - 1); - existingCtrl.replace(prevCtrler + " @slide", fullSlideControlStr); + existingCtrl.replace(prevCtrler + QLatin1String(" @slide"), fullSlideControlStr); } else { - (!existingCtrl.isEmpty() && m_controlled) ? existingCtrl.append(" ") : 0; + if (!existingCtrl.isEmpty() && m_controlled) + existingCtrl.append(QLatin1Char(' ')); existingCtrl.append(fullSlideControlStr); } - if (existingCtrl.endsWith(" ")) + if (existingCtrl.endsWith(QLatin1Char(' '))) existingCtrl.chop(1); - if (existingCtrl.startsWith(" ")) + if (existingCtrl.startsWith(QLatin1Char(' '))) existingCtrl.remove(0, 1); qt3dsdm::SValue fullCtrlPropVal - = std::make_shared<qt3dsdm::CDataStr>( - Q3DStudio::CString::fromQString(existingCtrl)); + = std::make_shared<qt3dsdm::CDataStr>(Q3DStudio::CString::fromQString(existingCtrl)); Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QObject::tr("Set Slide control")) ->SetInstancePropertyValue(slideRoot, ctrldProp, fullCtrlPropVal); @@ -338,6 +327,17 @@ void SlideView::onDataInputChange(int handle, int instance, const QString &dataI Q_EMIT controlledChanged(); } +void SlideView::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, + qt3dsdm::Qt3DSDMPropertyHandle inProperty) +{ + // refresh slide name + m_SlidesModel->refreshSlideLabel(inInstance, inProperty); + + // refresh variants + if (inProperty == GetBridge()->GetLayer().m_variants) + refreshVariants(); +} + void SlideView::onDockLocationChange(Qt::DockWidgetArea area) { m_dockArea = area; @@ -353,24 +353,22 @@ void SlideView::updateDataInputStatus() qt3dsdm::Qt3DSDMInstanceHandle slideRoot = doc->GetActiveRootInstance(); qt3dsdm::Qt3DSDMPropertyHandle ctrldProp; - if (bridge->GetObjectType(slideRoot) == EStudioObjectType::OBJTYPE_SCENE) { + if (bridge->GetObjectType(slideRoot) == EStudioObjectType::OBJTYPE_SCENE) ctrldProp = bridge->GetObjectDefinitions().m_Scene.m_ControlledProperty; - } else if (bridge->GetObjectType(slideRoot) == - EStudioObjectType::OBJTYPE_COMPONENT) { + else if (bridge->GetObjectType(slideRoot) == EStudioObjectType::OBJTYPE_COMPONENT) ctrldProp = bridge->GetObjectDefinitions().m_Component.m_ControlledProperty; - } else { + else Q_ASSERT(false); - } qt3dsdm::SValue controlledPropertyVal; - doc->GetStudioSystem()->GetPropertySystem()->GetInstancePropertyValue( - slideRoot, ctrldProp, controlledPropertyVal); - auto existingCtrl = qt3dsdm::get<QString>(controlledPropertyVal); + doc->GetStudioSystem()->GetPropertySystem()->GetInstancePropertyValue(slideRoot, ctrldProp, + controlledPropertyVal); + QString existingCtrl = qt3dsdm::get<QString>(controlledPropertyVal); QString newController; - int slideStrPos = existingCtrl.indexOf("@slide"); + int slideStrPos = existingCtrl.indexOf(QLatin1String("@slide")); if (slideStrPos != -1) { - int ctrStrPos = existingCtrl.lastIndexOf("$", slideStrPos - 2); + int ctrStrPos = existingCtrl.lastIndexOf(QLatin1Char('$'), slideStrPos - 2); newController = existingCtrl.mid(ctrStrPos + 1, slideStrPos - ctrStrPos - 2); } if (newController != m_currentController) { @@ -505,6 +503,12 @@ bool SlideView::isMaster(const qt3dsdm::Qt3DSDMSlideHandle &inSlideHandle) return (0 == GetSlideIndex(inSlideHandle)); } +void SlideView::refreshVariants() +{ + m_SlidesModel->refreshVariants(); + m_MasterSlideModel->refreshVariants(m_SlidesModel->variants()); +} + void SlideView::OnBeginDataModelNotifications() { } diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.h b/src/Authoring/Studio/Palettes/Slide/SlideView.h index e95ac314..18c4d1d7 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.h +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.h @@ -67,6 +67,7 @@ public: QSize minimumSizeHint() const override; void onDataInputChange(int handle, int instance, const QString &dataInputName); void onDockLocationChange(Qt::DockWidgetArea area); + void refreshVariants(); Q_INVOKABLE void deselectAll(); Q_INVOKABLE void addNewSlide(int row); @@ -120,10 +121,12 @@ private: long GetSlideIndex(const qt3dsdm::Qt3DSDMSlideHandle &inSlideHandle); bool isMaster(const qt3dsdm::Qt3DSDMSlideHandle &inSlideHandle); void rebuildSlideList(const qt3dsdm::Qt3DSDMSlideHandle &inActiveSlideHandle); + void onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, + qt3dsdm::Qt3DSDMPropertyHandle inProperty); - SlideModel *m_CurrentModel = nullptr; SlideModel *m_MasterSlideModel = nullptr; SlideModel *m_SlidesModel = nullptr; + SlideModel *m_CurrentModel = nullptr; DataInputSelectView *m_dataInputSelector = nullptr; QColor m_BaseColor = QColor::fromRgb(75, 75, 75); std::vector<std::shared_ptr<qt3dsdm::ISignalConnection>> diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.qml b/src/Authoring/Studio/Palettes/Slide/SlideView.qml index c8f409d0..4113c947 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.qml +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.qml @@ -263,6 +263,17 @@ Rectangle { } } + Label { // variants + width: slideImage.width + font.pixelSize: _fontSize + padding: 3 + verticalAlignment: Text.AlignVCenter + background: Rectangle { color:"#111111" } + wrapMode: Text.WordWrap + visible: model.variants !== "" + text: model.variants + } + Item { anchors.horizontalCenter: slideImage.horizontalCenter |