summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2018-05-15 11:49:01 +0300
committerTomi Korpipää <tomi.korpipaa@qt.io>2018-05-30 05:43:24 +0000
commita28264b8734182049f6d19c83d7613227c68a49f (patch)
tree10f959bd12f62732cf4bed03819f3caf9af040c8
parent59c7138ef169c62a3aeec9ac51cf1b4e31bfa9de (diff)
Bind new datainput directly when added from "Add new datainput"
Binds the newly created datainput directly as controller for slide or timeline, when datainput is created using "Add New Data Input" from datainput selector dialog. Also, use appropriate window titles. Change-Id: I288286d11f8a22f5a4d97183067c8e1412ba6002 Task-Id: QT3DS-1538 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Studio/Application/DataInputDlg.cpp1
-rw-r--r--src/Authoring/Studio/Application/DataInputListDlg.cpp16
-rw-r--r--src/Authoring/Studio/Application/DataInputListDlg.h8
-rw-r--r--src/Authoring/Studio/Application/DataInputSelectView.cpp13
-rw-r--r--src/Authoring/Studio/Application/DataInputSelectView.h6
-rw-r--r--src/Authoring/Studio/Palettes/Slide/SlideView.cpp2
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp2
7 files changed, 39 insertions, 9 deletions
diff --git a/src/Authoring/Studio/Application/DataInputDlg.cpp b/src/Authoring/Studio/Application/DataInputDlg.cpp
index d428d1a2..57c16e4d 100644
--- a/src/Authoring/Studio/Application/DataInputDlg.cpp
+++ b/src/Authoring/Studio/Application/DataInputDlg.cpp
@@ -105,6 +105,7 @@ void CDataInputDlg::initDialog()
#endif
} else {
m_name = getUniqueId(tr("newDataInput"));
+ m_ui->comboBoxTypeList->setCurrentIndex(m_dataInput->type);
m_ui->lineEditInputName->setText(m_name);
}
diff --git a/src/Authoring/Studio/Application/DataInputListDlg.cpp b/src/Authoring/Studio/Application/DataInputListDlg.cpp
index d277d734..c5fba701 100644
--- a/src/Authoring/Studio/Application/DataInputListDlg.cpp
+++ b/src/Authoring/Studio/Application/DataInputListDlg.cpp
@@ -42,11 +42,12 @@
const int columnCount = 3;
CDataInputListDlg::CDataInputListDlg(QMap<QString, CDataInputDialogItem *> *datainputs,
- bool goToAdd, QWidget *parent)
+ bool goToAdd, QWidget *parent, EDataType defaultType)
: QDialog(parent, Qt::MSWindowsFixedSizeDialogHint)
, m_ui(new Ui::DataInputListDlg)
, m_actualDataInputs(datainputs)
, m_goToAdd(goToAdd)
+ , m_defaultType(defaultType)
, m_currentDataInputIndex(-1)
, m_tableContents(new QStandardItemModel(0, columnCount, this))
, m_sortColumn(-1)
@@ -230,12 +231,23 @@ void CDataInputListDlg::onAddDataInput()
{
// Create a new data input dialog item and give it to dialog
CDataInputDialogItem *dataInput = new CDataInputDialogItem();
+ dataInput->type = m_defaultType;
CDataInputDlg datainputdialog(&dataInput, m_tableContents, this);
- if (datainputdialog.exec() == QDialog::Accepted)
+ datainputdialog.setWindowTitle("Add Data Input");
+ if (datainputdialog.exec() == QDialog::Accepted) {
m_dataInputs.insert(dataInput->name, dataInput);
+ m_mostRecentlyAdded = dataInput->name;
+ } else {
+ m_mostRecentlyAdded.clear();
+ }
updateButtons();
updateContents();
+
+ // If we went straight to adding a new datainput, close
+ // dialog automatically
+ if (m_goToAdd)
+ on_buttonBox_accepted();
}
void CDataInputListDlg::onRemoveDataInput()
diff --git a/src/Authoring/Studio/Application/DataInputListDlg.h b/src/Authoring/Studio/Application/DataInputListDlg.h
index e2e9d4d1..4ad1c7e7 100644
--- a/src/Authoring/Studio/Application/DataInputListDlg.h
+++ b/src/Authoring/Studio/Application/DataInputListDlg.h
@@ -31,6 +31,7 @@
#include <QtWidgets/qdialog.h>
#include <QtCore/qmap.h>
+#include "DataInputDlg.h"
#ifdef QT_NAMESPACE
using namespace QT_NAMESPACE;
@@ -52,9 +53,12 @@ class CDataInputListDlg : public QDialog
Q_OBJECT
public:
CDataInputListDlg(QMap<QString, CDataInputDialogItem *> *datainputs,
- bool goToAdd = false, QWidget *parent = nullptr);
+ bool goToAdd = false, QWidget *parent = nullptr,
+ EDataType defaultType = EDataType::DataTypeFloat);
~CDataInputListDlg();
+ QString getAddedDataInput() { return m_mostRecentlyAdded; }
+
protected:
void initDialog();
void updateButtons();
@@ -82,6 +86,8 @@ private:
bool m_goToAdd;
int m_sortColumn;
Qt::SortOrder m_sortOrder;
+ QString m_mostRecentlyAdded;
+ EDataType m_defaultType;
};
#endif
diff --git a/src/Authoring/Studio/Application/DataInputSelectView.cpp b/src/Authoring/Studio/Application/DataInputSelectView.cpp
index d0a53e2f..11c45e6e 100644
--- a/src/Authoring/Studio/Application/DataInputSelectView.cpp
+++ b/src/Authoring/Studio/Application/DataInputSelectView.cpp
@@ -38,9 +38,11 @@
#include "DataInputDlg.h"
#include "StudioApp.h"
-DataInputSelectView::DataInputSelectView(QWidget *parent)
+DataInputSelectView::DataInputSelectView(QWidget *parent, EDataType defaultType)
: QQuickWidget(parent)
, m_model(new DataInputSelectModel(this))
+ , m_defaultType(defaultType)
+
{
setWindowTitle(tr("Datainputs"));
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
@@ -131,11 +133,16 @@ void DataInputSelectView::setSelection(int index)
Q_EMIT dataInputChanged(m_handle, m_instance, sel);
Q_EMIT selectedChanged();
} else {
- CDataInputListDlg dataInputDlg(&(g_StudioApp.m_dataInputDialogItems), true);
+ CDataInputListDlg dataInputDlg(&(g_StudioApp.m_dataInputDialogItems), true,
+ nullptr, m_defaultType);
dataInputDlg.exec();
- if (dataInputDlg.result() == QDialog::Accepted)
+ if (dataInputDlg.result() == QDialog::Accepted) {
+ m_mostRecentlyAdded = dataInputDlg.getAddedDataInput();
+ if (m_mostRecentlyAdded.size())
+ Q_EMIT dataInputChanged(m_handle, m_instance, m_mostRecentlyAdded);
g_StudioApp.SaveUIAFile(false);
+ }
}
QTimer::singleShot(0, this, &DataInputSelectView::close);
}
diff --git a/src/Authoring/Studio/Application/DataInputSelectView.h b/src/Authoring/Studio/Application/DataInputSelectView.h
index c979a1e4..92456972 100644
--- a/src/Authoring/Studio/Application/DataInputSelectView.h
+++ b/src/Authoring/Studio/Application/DataInputSelectView.h
@@ -31,6 +31,7 @@
#include <QtQuickWidgets/qquickwidget.h>
#include <QtCore/qstringlistmodel.h>
#include "DataInputSelectModel.h"
+#include "DataInputDlg.h"
class DataInputSelectModel;
@@ -39,7 +40,8 @@ class DataInputSelectView : public QQuickWidget
Q_OBJECT
Q_PROPERTY(int selected MEMBER m_selection NOTIFY selectedChanged)
public:
- explicit DataInputSelectView(QWidget *parent = nullptr);
+ explicit DataInputSelectView(QWidget *parent = nullptr,
+ EDataType defaultType = EDataType::DataTypeFloat);
void setData(const QVector<QPair<QString, int>> &dataInputList,
const QString &currentController,
int handle = 0, int instance = 0);
@@ -65,6 +67,8 @@ private:
DataInputSelectModel *m_model = nullptr;
int m_selection = -1;
QString m_currController;
+ QString m_mostRecentlyAdded;
+ EDataType m_defaultType;
};
#endif // DATAINPUTSELECTDLG_H
diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
index 80f90083..bfcb2505 100644
--- a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
+++ b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
@@ -388,7 +388,7 @@ void SlideView::initialize()
engine()->addImportPath(qmlImportPath());
setSource(QUrl("qrc:/Palettes/Slide/SlideView.qml"_L1));
- m_dataInputSelector = new DataInputSelectView(this);
+ m_dataInputSelector = new DataInputSelectView(this, EDataType::DataTypeString);
connect(m_dataInputSelector, &DataInputSelectView::dataInputChanged,
this, &SlideView::onDataInputChange);
}
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
index 7e248578..84ffb267 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
@@ -146,7 +146,7 @@ TimelineToolbar::TimelineToolbar() : QToolBar()
std::bind(&TimelineToolbar::onSelectionChange, this, std::placeholders::_1));
// make datainput indicator listen to selection dialog choice
- m_dataInputSelector = new DataInputSelectView(this);
+ m_dataInputSelector = new DataInputSelectView(this, EDataType::DataTypeRangedNumber);
g_StudioApp.GetCore()->GetDispatch()->AddDataModelListener(this);
connect(m_dataInputSelector, &DataInputSelectView::dataInputChanged,
this, &TimelineToolbar::onDataInputChange);