summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/Slide
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-02-27 11:28:18 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-02-27 13:30:25 +0200
commit26a16b56b39f3904c382c392d7ed958fab73108b (patch)
tree09778baf8c65d62ee1c1e309e909ef265e286d2d /src/Authoring/Studio/Palettes/Slide
parent7730cb4a0e14d4bee8ceb54d3ea019464175b613 (diff)
parent677d3ca825287b18c7133b94ec4d45d393db3390 (diff)
Merge branch 'master' into wip/timeline
Diffstat (limited to 'src/Authoring/Studio/Palettes/Slide')
-rw-r--r--src/Authoring/Studio/Palettes/Slide/SlideView.cpp148
-rw-r--r--src/Authoring/Studio/Palettes/Slide/SlideView.h27
-rw-r--r--src/Authoring/Studio/Palettes/Slide/SlideView.qml61
3 files changed, 230 insertions, 6 deletions
diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
index 65889a24..7cb74be4 100644
--- a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
+++ b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
@@ -37,6 +37,9 @@
#include "StudioApp.h"
#include "StudioUtils.h"
#include "SlideContextMenu.h"
+#include "DataInputSelectDlg.h"
+#include "DataInputDlg.h"
+#include "IDocumentEditor.h"
#include "ClientDataModelBridge.h"
#include "Qt3DSDMStudioSystem.h"
@@ -62,6 +65,7 @@ SlideView::~SlideView()
{
clearSlideList();
g_StudioApp.GetCore()->GetDispatch()->RemovePresentationChangeListener(this);
+ delete m_dataInputSelector;
}
bool SlideView::showMasterSlide() const
@@ -111,6 +115,22 @@ void SlideView::setShowMasterSlide(bool show)
Q_EMIT currentModelChanged();
}
+void SlideView::showControllerDialog(const QPoint &point)
+{
+ QStringList dataInputList;
+ dataInputList.append(tr("[No control]"));
+ for (int i = 0; i < g_StudioApp.m_dataInputDialogItems.size(); i++) {
+ if (g_StudioApp.m_dataInputDialogItems[i]->type == EDataType::DataTypeString)
+ dataInputList.append(g_StudioApp.m_dataInputDialogItems[i]->name);
+ }
+ QString currCtr = m_currentController.size() ?
+ m_currentController : tr("[No control]");
+ m_dataInputSelector->setData(dataInputList, currCtr);
+ m_dataInputSelector->showDialog(point);
+
+ return;
+}
+
QSize SlideView::sizeHint() const
{
return {150, 500};
@@ -182,7 +202,11 @@ void SlideView::OnNewPresentation()
m_Connections.push_back(theSignalProvider->ConnectInstancePropertyValue(
std::bind(&SlideModel::refreshSlideLabel, m_SlidesModel,
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();
+ theDispatch->AddDataModelListener(this);
+ updateDataInputStatus(false);
}
void SlideView::OnClosingPresentation()
@@ -219,6 +243,102 @@ void SlideView::OnSlideRearranged(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, i
m_SlidesModel->onSlideRearranged(inMaster, inOldIndex, inNewIndex);
}
+void SlideView::onDataInputChange(const QString &dataInputName)
+{
+ if (dataInputName == m_currentController ||
+ (dataInputName == tr("[No Control]") && !m_currentController.size())) {
+ return;
+ }
+
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ CClientDataModelBridge *bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+ qt3dsdm::Qt3DSDMInstanceHandle slideRoot = doc->GetSceneInstance();
+ QString fullSlideControlStr;
+
+ if (dataInputName != tr("[No control]")) {
+ fullSlideControlStr = dataInputName + " @slide";
+ m_controlled = true;
+ m_currentController = dataInputName;
+ m_toolTip = tr("Slide Controller:\n") + m_currentController;
+ } else {
+ m_controlled = false;
+ m_currentController.clear();
+ m_toolTip = tr("No controller");
+ }
+
+ qt3dsdm::Qt3DSDMPropertyHandle ctrldProp
+ = bridge->GetObjectDefinitions().m_Scene.m_ControlledProperty;
+ qt3dsdm::Option<qt3dsdm::SValue> controlledPropertyVal
+ = Q3DStudio::SCOPED_DOCUMENT_EDITOR(
+ *doc,
+ QObject::tr("Get DataInput control"))->GetInstancePropertyValue(slideRoot,
+ ctrldProp);
+
+ // To indicate that slide transitions are controlled by data input,
+ // we set "controlled property" of this scene to contain the name of
+ // controller followed by special indicator "@slide".
+ // 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.getValue());
+ if (existingCtrl.contains("@slide")) {
+ int slideStrPos = existingCtrl.indexOf("@slide");
+ // find the controlling datainput name and build the string to replace
+ int ctrStrPos = existingCtrl.lastIndexOf(" ", slideStrPos - 2);
+ QString prevCtrler = existingCtrl.mid(ctrStrPos + 1, slideStrPos - ctrStrPos - 1);
+ existingCtrl.replace(prevCtrler + "@slide", fullSlideControlStr);
+ } else {
+ (!existingCtrl.isEmpty() && m_controlled) ? existingCtrl.append(" ") : 0;
+ existingCtrl.append(fullSlideControlStr);
+ }
+
+ if (existingCtrl.endsWith(" "))
+ existingCtrl.chop(1);
+
+ if (existingCtrl.startsWith(" "))
+ existingCtrl.remove(0, 1);
+
+ qt3dsdm::SValue fullCtrlPropVal
+ = std::make_shared<qt3dsdm::CDataStr>(
+ Q3DStudio::CString::fromQString(existingCtrl));
+
+ Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QObject::tr("Set Slide control"))
+ ->SetInstancePropertyValue(slideRoot, ctrldProp, fullCtrlPropVal);
+
+ Q_EMIT controlledChanged();
+}
+
+// Set the state of slide control based on scene
+// controlledproperty
+void SlideView::updateDataInputStatus(bool isViaDispatch)
+{
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ CClientDataModelBridge *bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+ qt3dsdm::Qt3DSDMInstanceHandle slideRoot = doc->GetSceneInstance();
+ qt3dsdm::Qt3DSDMPropertyHandle ctrldProp
+ = bridge->GetObjectDefinitions().m_Scene.m_ControlledProperty;
+ qt3dsdm::Option<qt3dsdm::SValue> controlledPropertyVal
+ = Q3DStudio::SCOPED_DOCUMENT_EDITOR(
+ *doc,
+ QObject::tr("Get DataInput control"))->GetInstancePropertyValue(slideRoot,
+ ctrldProp);
+
+ auto existingCtrl = qt3dsdm::get<QString>(controlledPropertyVal.getValue());
+ if (existingCtrl.contains("@slide")) {
+ int slideStrPos = existingCtrl.indexOf("@slide");
+ int ctrStrPos = existingCtrl.lastIndexOf(" ", slideStrPos - 2);
+ m_currentController = existingCtrl.mid(ctrStrPos + 1, slideStrPos - ctrStrPos - 2);
+ m_toolTip = tr("Slide Controller:\n") + m_currentController;
+ m_controlled = true;
+ } else {
+ m_currentController.clear();
+ m_toolTip = tr("No controller");
+ m_controlled = false;
+ }
+
+ // update UI
+ Q_EMIT controlledChanged();
+}
void SlideView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
@@ -227,6 +347,12 @@ void SlideView::initialize()
engine()->addImportPath(qmlImportPath());
setSource(QUrl("qrc:/Palettes/Slide/SlideView.qml"_L1));
+
+ m_dataInputSelector = new DataInputSelectDlg(parentWidget());
+ connect(m_dataInputSelector, &DataInputSelectDlg::dataInputChanged,
+ this, &SlideView::onDataInputChange);
+ m_dataInputSelector->hide();
+ m_dataInputSelector->setWindowTitle(tr("Select slide controller"));
}
void SlideView::clearSlideList()
@@ -329,4 +455,24 @@ bool SlideView::isMaster(const qt3dsdm::Qt3DSDMSlideHandle &inSlideHandle)
return (0 == GetSlideIndex(inSlideHandle));
}
+void SlideView::OnBeginDataModelNotifications()
+{
+}
+
+void SlideView::OnEndDataModelNotifications()
+{
+ updateDataInputStatus(true);
+}
+
+void SlideView::OnImmediateRefreshInstanceSingle(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
+{
+ updateDataInputStatus(true);
+}
+
+void SlideView::OnImmediateRefreshInstanceMultiple(
+ qt3dsdm::Qt3DSDMInstanceHandle *inInstance, long inInstanceCount)
+{
+ updateDataInputStatus(true);
+}
+
diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.h b/src/Authoring/Studio/Palettes/Slide/SlideView.h
index b8f6d01d..12594637 100644
--- a/src/Authoring/Studio/Palettes/Slide/SlideView.h
+++ b/src/Authoring/Studio/Palettes/Slide/SlideView.h
@@ -33,9 +33,11 @@
#include "DispatchListeners.h"
#include "SlideModel.h"
-
+#include "DataInputSelectDlg.h"
#include "Qt3DSDMHandles.h"
#include "Qt3DSDMSignals.h"
+#include "DispatchListeners.h"
+#include "Dispatch.h"
#include <unordered_map>
class CClientDataModelBridge;
class CDoc;
@@ -44,11 +46,16 @@ namespace qt3dsdm {
class ISlideSystem;
}
-class SlideView : public QQuickWidget, public CPresentationChangeListener
+class SlideView : public QQuickWidget,
+ public CPresentationChangeListener,
+ public IDataModelListener
{
Q_OBJECT
Q_PROPERTY(QAbstractItemModel *currentModel READ currentModel NOTIFY currentModelChanged FINAL)
Q_PROPERTY(bool showMasterSlide READ showMasterSlide WRITE setShowMasterSlide NOTIFY showMasterSlideChanged FINAL)
+ Q_PROPERTY(bool controlled MEMBER m_controlled NOTIFY controlledChanged)
+ Q_PROPERTY(QString currController MEMBER m_currentController NOTIFY controlledChanged)
+ Q_PROPERTY(QString toolTip MEMBER m_toolTip NOTIFY controlledChanged)
public:
SlideView(QWidget *parent = nullptr);
~SlideView();
@@ -57,6 +64,7 @@ public:
void setShowMasterSlide(bool show);
QAbstractItemModel *currentModel() { return m_CurrentModel; }
QSize sizeHint() const override;
+ void onDataInputChange(const QString &dataInputName);
Q_INVOKABLE void deselectAll();
Q_INVOKABLE void addNewSlide(int row);
@@ -66,14 +74,23 @@ public:
Q_INVOKABLE void moveSlide(int from, int to);
Q_INVOKABLE void finishSlideRearrange(bool commit);
Q_INVOKABLE void showContextMenu(int x, int y, int row);
+ Q_INVOKABLE void showControllerDialog(const QPoint &point);
// Presentation Change Listener
void OnNewPresentation() override;
void OnClosingPresentation() override;
+ // IDataModelListener
+ void OnBeginDataModelNotifications() override;
+ void OnEndDataModelNotifications() override;
+ void OnImmediateRefreshInstanceSingle(qt3dsdm::Qt3DSDMInstanceHandle inInstance) override;
+ void OnImmediateRefreshInstanceMultiple(qt3dsdm::Qt3DSDMInstanceHandle *inInstance,
+ long inInstanceCount) override;
+
Q_SIGNALS:
void currentModelChanged();
void showMasterSlideChanged();
+ void controlledChanged();
protected:
@@ -85,6 +102,8 @@ protected:
virtual void OnSlideRearranged(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, int inOldIndex,
int inNewIndex);
+ void updateDataInputStatus(bool isViaDispatch);
+
private:
void initialize();
void clearSlideList();
@@ -99,6 +118,7 @@ private:
SlideModel *m_CurrentModel = nullptr;
SlideModel *m_MasterSlideModel = nullptr;
SlideModel *m_SlidesModel = nullptr;
+ DataInputSelectDlg *m_dataInputSelector = nullptr;
QColor m_BaseColor = QColor::fromRgb(75, 75, 75);
std::vector<std::shared_ptr<qt3dsdm::ISignalConnection>>
m_Connections; /// connections to the DataModel
@@ -110,6 +130,9 @@ private:
qt3dsdm::Qt3DSDMInstanceHandle m_ActiveRoot; ///< the object containing the slides to be inspected.
qt3dsdm::Qt3DSDMSlideHandle m_ActiveSlideHandle; ///< the active slide handle
+ bool m_controlled; // Are slides in this slide set controlled by datainput?
+ QString m_currentController;
+ QString m_toolTip;
};
#endif // SLIDEVIEW_H
diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.qml b/src/Authoring/Studio/Palettes/Slide/SlideView.qml
index 1d7670f6..60bf3883 100644
--- a/src/Authoring/Studio/Palettes/Slide/SlideView.qml
+++ b/src/Authoring/Studio/Palettes/Slide/SlideView.qml
@@ -28,6 +28,7 @@
import QtQuick 2.8
import QtQuick.Controls 2.2
+import QtQuick.Layouts 1.3
import "../controls"
Rectangle {
@@ -59,6 +60,7 @@ Rectangle {
}
spacing: 5
+ width: parent.width
MouseArea {
id: masterMouseArea
@@ -111,8 +113,12 @@ Rectangle {
ScrollBar.vertical: ScrollBar {}
width: root.width
- height: root.height - masterButtonColumn.height
- - separator.height - parent.spacing * 2 - 10
+ property int listItemHeight: root.height - masterButtonColumn.height
+ - separator.height - separator2.height
+ - parent.spacing * 2 - 14 - slideControlButton.height
+ - slideControlButton.spacing * 2
+ height: listItemHeight > 0 ? listItemHeight : 0
+
anchors.horizontalCenter: parent.horizontalCenter
boundsBehavior: Flickable.StopAtBounds
clip: true
@@ -276,6 +282,55 @@ Rectangle {
}
}
}
- }
+ StyledMenuSeparator {
+ id: separator2
+ leftPadding: 12
+ rightPadding: 12
+ }
+ // RowLayout for possible addition and positioning of label
+ // showing the controller name
+ RowLayout {
+ Layout.rightMargin: 12
+ Layout.leftMargin: 12
+ anchors.left: parent.left
+ Button {
+ id: slideControlButton
+ width: dataInputImage.sourceSize.width
+ height: dataInputImage.sourceSize.height
+ Layout.leftMargin: 12
+ property bool controlled: _slideView.controlled
+ property string currentController: _slideView.currController
+ property string toolTip: _slideView.toolTip
+ background: Rectangle {
+ color: "transparent"
+ }
+ MouseArea {
+ id: controlButtonArea
+ anchors.fill: parent
+ hoverEnabled: true
+ acceptedButtons: Qt.LeftButton
+ onClicked: {
+ _slideView.showControllerDialog(mapToGlobal(mouse.x, mouse.y));
+ }
+ }
+ Image {
+ id: dataInputImage
+ anchors.fill: parent
+ fillMode: Image.Pad
+ property bool controlled: parent.controlled
+ source: {
+ _resDir + (controlled
+ ? "Objects-DataInput-Normal.png"
+ : "Objects-DataInput-Disabled.png")
+ }
+ }
+ StyledTooltip {
+ id: tooltip
+ visible: controlButtonArea.containsMouse
+ text: parent.toolTip
+ }
+ }
+ }
+ }
}