summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaj Grönholm <kaj.gronholm@qt.io>2018-02-26 16:34:42 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-03-02 12:53:32 +0000
commit4fac25bd7db955e9bfef9b8de8278fc84afc5327 (patch)
treed3023703503df0bc32bb2c70cf6cbfa3b2f2a788
parentb22771e6953c7f0d25decaae4dabeff9a520ecd9 (diff)
Use correct icons in mesh selector1.1
Allows setting custom icon for choosers. Task-number: QT3DS-195 Change-Id: Iec1d7fd3cf6ebcfaabba222609ec90d86069c9ab Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.cpp13
-rw-r--r--src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.h3
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ChooserDelegate.qml2
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp5
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.h1
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/FileChooserModel.cpp2
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.cpp2
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/MeshChooserModel.cpp11
8 files changed, 31 insertions, 8 deletions
diff --git a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.cpp b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.cpp
index 0888063d..5a4fff9d 100644
--- a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.cpp
+++ b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.cpp
@@ -42,7 +42,12 @@ BasicObjectsModel::BasicObjectsModel(QObject *parent) : QAbstractListModel(paren
void BasicObjectsModel::initialize()
{
- m_ObjectItems = {
+ m_ObjectItems = InitializeObjectModel();
+}
+
+const QVector<BasicObjectItem> BasicObjectsModel::InitializeObjectModel()
+{
+ return {
{tr("Rectangle"), "Asset-Rectangle-Normal.png"_L1, OBJTYPE_MODEL, PRIMITIVETYPE_RECT},
{tr("Sphere"), "Asset-Sphere-Normal.png"_L1, OBJTYPE_MODEL, PRIMITIVETYPE_SPHERE},
{tr("Cube"), "Asset-Cube-Normal.png"_L1, OBJTYPE_MODEL, PRIMITIVETYPE_BOX},
@@ -57,6 +62,12 @@ void BasicObjectsModel::initialize()
};
}
+// Returns meshes part of basic objects
+const QVector<BasicObjectItem> BasicObjectsModel::BasicMeshesModel()
+{
+ return InitializeObjectModel().mid(0, 5);
+}
+
QVariant BasicObjectsModel::data(const QModelIndex &index, int role) const
{
if (!hasIndex(index.row(), index.column(),index.parent()))
diff --git a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.h b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.h
index 1f0edbf9..2e2faa83 100644
--- a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.h
+++ b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.h
@@ -88,8 +88,11 @@ public:
QStringList mimeTypes() const override;
QMimeData *mimeData(const QModelIndexList &indexes) const override;
+ static const QVector<BasicObjectItem> BasicMeshesModel();
+
private:
void initialize();
+ static const QVector<BasicObjectItem> InitializeObjectModel();
QVector<BasicObjectItem> m_ObjectItems;
diff --git a/src/Authoring/Studio/Palettes/Inspector/ChooserDelegate.qml b/src/Authoring/Studio/Palettes/Inspector/ChooserDelegate.qml
index 6ee4445c..95090e66 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ChooserDelegate.qml
+++ b/src/Authoring/Studio/Palettes/Inspector/ChooserDelegate.qml
@@ -63,6 +63,8 @@ Rectangle {
Image {
source: fileIcon
+ width: 16
+ height: 16
}
StyledLabel {
diff --git a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp
index c0a21750..92e5a516 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp
@@ -83,7 +83,10 @@ QVariant ChooserModelBase::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DecorationRole:
- return resourceImageUrl() + CStudioObjectTypes::GetNormalIconName(item.iconType);
+ if (!item.iconSource.isEmpty())
+ return resourceImageUrl() + item.iconSource;
+ else
+ return resourceImageUrl() + CStudioObjectTypes::GetNormalIconName(item.iconType);
case IsExpandableRole:
return false;
diff --git a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.h b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.h
index e14937db..cf177870 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.h
+++ b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.h
@@ -77,6 +77,7 @@ protected:
struct FixedItem
{
EStudioObjectType iconType;
+ QString iconSource;
QString name;
};
diff --git a/src/Authoring/Studio/Palettes/Inspector/FileChooserModel.cpp b/src/Authoring/Studio/Palettes/Inspector/FileChooserModel.cpp
index 6c57635b..cef01850 100644
--- a/src/Authoring/Studio/Palettes/Inspector/FileChooserModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/FileChooserModel.cpp
@@ -45,6 +45,6 @@ bool FileChooserModel::isVisible(const QString &path) const
const QVector<ChooserModelBase::FixedItem> FileChooserModel::getFixedItems() const
{
- static const QVector<FixedItem> items = { { OBJTYPE_GROUP, tr("[None]") } };
+ static const QVector<FixedItem> items = { { OBJTYPE_GROUP, "", tr("[None]") } };
return items;
}
diff --git a/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.cpp b/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.cpp
index 98732f74..d70d5837 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.cpp
@@ -44,6 +44,6 @@ bool ImageChooserModel::isVisible(const QString &path) const
const QVector<ChooserModelBase::FixedItem> ImageChooserModel::getFixedItems() const
{
- static const QVector<FixedItem> items = { { OBJTYPE_IMAGE, tr("[None]") } };
+ static const QVector<FixedItem> items = { { OBJTYPE_IMAGE, "", tr("[None]") } };
return items;
}
diff --git a/src/Authoring/Studio/Palettes/Inspector/MeshChooserModel.cpp b/src/Authoring/Studio/Palettes/Inspector/MeshChooserModel.cpp
index e1b61bbf..f87dc89b 100644
--- a/src/Authoring/Studio/Palettes/Inspector/MeshChooserModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/MeshChooserModel.cpp
@@ -31,6 +31,7 @@
#include "Doc.h"
#include "IDocumentBufferCache.h"
#include "StudioApp.h"
+#include "BasicObjectsModel.h"
MeshChooserModel::MeshChooserModel(QObject *parent)
: ChooserModelBase(parent)
@@ -52,11 +53,13 @@ const QVector<ChooserModelBase::FixedItem> MeshChooserModel::getFixedItems() con
static QVector<FixedItem> items;
if (items.isEmpty()) {
- auto primitiveNames = g_StudioApp.GetCore()->GetDoc()->GetBufferCache().GetPrimitiveNames();
- for (auto item = primitiveNames; *item; ++item) {
- auto itemName = *item;
+ auto primitives = BasicObjectsModel::BasicMeshesModel();
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ for (int i = 0; i < primitives.size(); i++) {
+ auto item = primitives.at(i);
+ const wchar_t *itemName = doc->GetBufferCache().GetPrimitiveName(item.primitiveType());
if (itemName[0] == L'#')
- items.append({ OBJTYPE_MODEL, QString::fromWCharArray(itemName + 1) });
+ items.append({ OBJTYPE_MODEL, item.icon(), QString::fromWCharArray(itemName + 1) });
}
}