summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-10-17 11:04:01 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-10-18 08:58:42 +0000
commit510029c1d1974d3e0d417e87da30261357fec510 (patch)
tree9c89094f221c33d46a9a3ff13242a3995459bbed
parent4430b2eb13f2b37068b4af65d0ec038d30ff0233 (diff)
Clean up StudioUtils
Made StudioUtils a class of static functions instead of global functions. Also cleaned up the code a bit where changes happened because of this change. Change-Id: Ic583dd25bf228c7e344be6664b6651958d84906e Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Janne Kangas <janne.kangas@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Qt3DSDMStudioSystem.cpp2
-rw-r--r--src/Authoring/Studio/Application/DataInputSelectModel.cpp6
-rw-r--r--src/Authoring/Studio/Application/DataInputSelectView.cpp12
-rw-r--r--src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp2
-rw-r--r--src/Authoring/Studio/Palettes/Action/ActionView.cpp24
-rw-r--r--src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp10
-rw-r--r--src/Authoring/Studio/Palettes/Action/EventsModel.cpp4
-rw-r--r--src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.cpp2
-rw-r--r--src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp10
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp12
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/FileChooserView.cpp12
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp12
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp23
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp12
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp13
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp2
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp10
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp2
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectView.cpp8
-rw-r--r--src/Authoring/Studio/Palettes/Slide/SlideView.cpp8
-rw-r--r--src/Authoring/Studio/Render/StudioRenderer.cpp10
-rw-r--r--src/Authoring/Studio/Render/StudioRotationWidget.cpp2
-rw-r--r--src/Authoring/Studio/Render/StudioScaleWidget.cpp2
-rw-r--r--src/Authoring/Studio/Render/StudioTranslationWidget.cpp2
-rw-r--r--src/Authoring/Studio/Utils/ResourceCache.cpp8
-rw-r--r--src/Authoring/Studio/Utils/StudioUtils.cpp98
-rw-r--r--src/Authoring/Studio/Utils/StudioUtils.h36
27 files changed, 125 insertions, 219 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/Qt3DSDMStudioSystem.cpp b/src/Authoring/Client/Code/Core/Doc/Qt3DSDMStudioSystem.cpp
index 54e925f0..89a75611 100644
--- a/src/Authoring/Client/Code/Core/Doc/Qt3DSDMStudioSystem.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/Qt3DSDMStudioSystem.cpp
@@ -148,7 +148,7 @@ void CStudioSystem::ResetDatabase()
std::shared_ptr<IStringTable> theStringTable(theNewMetaData->GetStringTablePtr());
std::shared_ptr<IDOMFactory> theFactory(IDOMFactory::CreateDOMFactory(theStringTable));
Q3DStudio::CString theFullPath(Q3DStudio::CString::fromQString(
- resourcePath()
+ StudioUtils::resourcePath()
+ QStringLiteral("/DataModelMetadata/en-us/MetaData.xml")));
// Load the new meta data
{
diff --git a/src/Authoring/Studio/Application/DataInputSelectModel.cpp b/src/Authoring/Studio/Application/DataInputSelectModel.cpp
index 2723623d..baacb744 100644
--- a/src/Authoring/Studio/Application/DataInputSelectModel.cpp
+++ b/src/Authoring/Studio/Application/DataInputSelectModel.cpp
@@ -43,12 +43,14 @@ DataInputSelectModel::~DataInputSelectModel()
QString DataInputSelectModel::getActiveIconPath() const
{
- return resourceImageUrl() + CStudioObjectTypes::GetNormalIconName(OBJTYPE_DATAINPUT);
+ return StudioUtils::resourceImageUrl()
+ + CStudioObjectTypes::GetNormalIconName(OBJTYPE_DATAINPUT);
}
QString DataInputSelectModel::getInactiveIconPath() const
{
- return resourceImageUrl() + CStudioObjectTypes::GetDisabledIconName(OBJTYPE_DATAINPUT);
+ return StudioUtils::resourceImageUrl()
+ + CStudioObjectTypes::GetDisabledIconName(OBJTYPE_DATAINPUT);
}
QVariant DataInputSelectModel::data(const QModelIndex &index, int role) const
diff --git a/src/Authoring/Studio/Application/DataInputSelectView.cpp b/src/Authoring/Studio/Application/DataInputSelectView.cpp
index 59c1f0a0..1145f584 100644
--- a/src/Authoring/Studio/Application/DataInputSelectView.cpp
+++ b/src/Authoring/Studio/Application/DataInputSelectView.cpp
@@ -180,10 +180,10 @@ void DataInputSelectView::focusOutEvent(QFocusEvent *event)
void DataInputSelectView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_resDir"_L1,
- resourceImageUrl());
- rootContext()->setContextProperty("_dataInputSelectView"_L1, this);
- rootContext()->setContextProperty("_dataInputSelectModel"_L1, m_model);
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/Inspector/DataInputChooser.qml"_L1));
+ rootContext()->setContextProperty(QStringLiteral("_resDir"),
+ StudioUtils::resourceImageUrl());
+ rootContext()->setContextProperty(QStringLiteral("_dataInputSelectView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_dataInputSelectModel"), m_model);
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/Inspector/DataInputChooser.qml")));
}
diff --git a/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp b/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp
index 6def1156..3ad659d2 100644
--- a/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp
+++ b/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp
@@ -212,7 +212,7 @@ CCmd *CBasicObjectDropSource::GenerateAssetCommand(qt3dsdm::Qt3DSDMInstanceHandl
CFilePath theResFontFile;
- QDir theResFontDir(resourcePath() + "/Font");
+ QDir theResFontDir(StudioUtils::resourcePath() + QStringLiteral("/Font"));
Q_FOREACH (QFileInfo fontFile, theResFontDir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot)) {
CString ext = CString::fromQString(fontFile.suffix());
if (CDialogs::IsFontFileExtension(ext)) {
diff --git a/src/Authoring/Studio/Palettes/Action/ActionView.cpp b/src/Authoring/Studio/Palettes/Action/ActionView.cpp
index 58cb7b75..d7197285 100644
--- a/src/Authoring/Studio/Palettes/Action/ActionView.cpp
+++ b/src/Authoring/Studio/Palettes/Action/ActionView.cpp
@@ -1015,32 +1015,32 @@ CClientDataModelBridge *ActionView::GetBridge()
void ActionView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_parentView"_L1, this);
- rootContext()->setContextProperty("_resDir"_L1, resourceImageUrl());
- rootContext()->setContextProperty("_tabOrderHandler"_L1, tabOrderHandler());
- rootContext()->setContextProperty("_mouseHelper"_L1, &m_mouseHelper);
+ rootContext()->setContextProperty(QStringLiteral("_parentView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_resDir"), StudioUtils::resourceImageUrl());
+ rootContext()->setContextProperty(QStringLiteral("_tabOrderHandler"), tabOrderHandler());
+ rootContext()->setContextProperty(QStringLiteral("_mouseHelper"), &m_mouseHelper);
QString shiftKey(QStringLiteral("Shift+"));
#ifdef Q_OS_MACOS
shiftKey = "⇧";
#endif
- rootContext()->setContextProperty("_shiftKey"_L1, shiftKey);
+ rootContext()->setContextProperty(QStringLiteral("_shiftKey"), shiftKey);
qmlRegisterUncreatableType<qt3dsdm::HandlerArgumentType>(
"Qt3DStudio", 1, 0, "HandlerArgumentType",
- "HandlerArgumentType is an enum container"_L1);
+ QStringLiteral("HandlerArgumentType is an enum container"));
qmlRegisterUncreatableType<qt3dsdm::DataModelDataType>(
"Qt3DStudio", 1, 0, "DataModelDataType",
- "DataModelDataType is an enum container"_L1);
+ QStringLiteral("DataModelDataType is an enum container"));
qmlRegisterUncreatableType<qt3dsdm::AdditionalMetaDataType>(
"Qt3DStudio", 1, 0, "AdditionalMetaDataType",
- "AdditionalMetaDataType is an enum container"_L1);
+ QStringLiteral("AdditionalMetaDataType is an enum container"));
qmlRegisterUncreatableType<PropertyInfo>(
"Qt3DStudio", 1, 0, "PropertyInfo",
- "PropertyInfo is anot creatable in QML"_L1);
+ QStringLiteral("PropertyInfo is not creatable in QML"));
qmlRegisterUncreatableType<qt3dsdm::CompleteMetaDataType>(
"Qt3DStudio", 1, 0, "CompleteMetaDataType",
- "CompleteMetaDataType is an enum container"_L1);
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/Action/ActionView.qml"_L1));
+ QStringLiteral("CompleteMetaDataType is an enum container"));
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/Action/ActionView.qml")));
}
QStringList ActionView::slideNames()
diff --git a/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp b/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp
index 7dcb682d..891498cc 100644
--- a/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp
+++ b/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp
@@ -96,10 +96,10 @@ void EventsBrowserView::focusOutEvent(QFocusEvent *event)
void EventsBrowserView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_eventsBrowserView"_L1, this);
- rootContext()->setContextProperty("_resDir"_L1,
- resourceImageUrl());
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/Action/EventsBrowser.qml"_L1));
+ rootContext()->setContextProperty(QStringLiteral("_eventsBrowserView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_resDir"),
+ StudioUtils::resourceImageUrl());
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/Action/EventsBrowser.qml")));
}
diff --git a/src/Authoring/Studio/Palettes/Action/EventsModel.cpp b/src/Authoring/Studio/Palettes/Action/EventsModel.cpp
index 6d8e4b19..981ab95a 100644
--- a/src/Authoring/Studio/Palettes/Action/EventsModel.cpp
+++ b/src/Authoring/Studio/Palettes/Action/EventsModel.cpp
@@ -152,9 +152,9 @@ QVariant EventsModel::data(const QModelIndex &index, int role) const
case DescriptionRole:
return isCategory ? category.description: event.description;
case IconRole:
- return isCategory ? resourceImageUrl() + category.icon : "";
+ return isCategory ? StudioUtils::resourceImageUrl() + category.icon : QString();
case HighlightedIconRole:
- return isCategory ? resourceImageUrl() + category.highlightIcon : "";
+ return isCategory ? StudioUtils::resourceImageUrl() + category.highlightIcon : QString();
case ExpandedRole:
return isCategory ? category.expanded : false;
case ParentExpandedRole: {
diff --git a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.cpp b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.cpp
index 867a441b..8694fda7 100644
--- a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.cpp
+++ b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsModel.cpp
@@ -78,7 +78,7 @@ QVariant BasicObjectsModel::data(const QModelIndex &index, int role) const
switch (role) {
case NameRole: return m_ObjectItems.at(row).name();
- case IconRole: return resourceImageUrl() +
+ case IconRole: return StudioUtils::resourceImageUrl() +
m_ObjectItems.at(row).icon();
case ObjectTypeRole: return m_ObjectItems.at(row).objectType();
case PrimitiveTypeRole: return m_ObjectItems.at(row).primitiveType();
diff --git a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp
index e3b35963..e23423fe 100644
--- a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp
+++ b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp
@@ -77,10 +77,10 @@ void BasicObjectsView::mousePressEvent(QMouseEvent *event)
void BasicObjectsView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_basicObjectsModel"_L1, m_ObjectsModel);
- rootContext()->setContextProperty("_basicObjectsView"_L1, this);
- rootContext()->setContextProperty("_resDir"_L1, resourceImageUrl());
+ rootContext()->setContextProperty(QStringLiteral("_basicObjectsModel"), m_ObjectsModel);
+ rootContext()->setContextProperty(QStringLiteral("_basicObjectsView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_resDir"), StudioUtils::resourceImageUrl());
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/BasicObjects/BasicObjectsView.qml"_L1));
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/BasicObjects/BasicObjectsView.qml")));
}
diff --git a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp
index 1457a3c1..3f5583ea 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp
@@ -83,10 +83,12 @@ QVariant ChooserModelBase::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DecorationRole:
- if (!item.iconSource.isEmpty())
- return resourceImageUrl() + item.iconSource;
- else
- return resourceImageUrl() + CStudioObjectTypes::GetNormalIconName(item.iconType);
+ if (!item.iconSource.isEmpty()) {
+ return StudioUtils::resourceImageUrl() + item.iconSource;
+ } else {
+ return StudioUtils::resourceImageUrl()
+ + CStudioObjectTypes::GetNormalIconName(item.iconType);
+ }
case IsExpandableRole:
return false;
@@ -112,7 +114,7 @@ QVariant ChooserModelBase::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DecorationRole: {
QString path = item.index.data(QFileSystemModel::FilePathRole).toString();
- return resourceImageUrl() + getIconName(path);
+ return StudioUtils::resourceImageUrl() + getIconName(path);
}
case IsExpandableRole: {
diff --git a/src/Authoring/Studio/Palettes/Inspector/FileChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/FileChooserView.cpp
index a2d285bf..ab211068 100644
--- a/src/Authoring/Studio/Palettes/Inspector/FileChooserView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/FileChooserView.cpp
@@ -55,12 +55,12 @@ FileChooserView::FileChooserView(QWidget *parent)
void FileChooserView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_resDir"_L1,
- resourceImageUrl());
- rootContext()->setContextProperty("_fileChooserView"_L1, this);
- rootContext()->setContextProperty("_fileChooserModel"_L1, m_model);
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/Inspector/FileChooser.qml"_L1));
+ rootContext()->setContextProperty(QStringLiteral("_resDir"),
+ StudioUtils::resourceImageUrl());
+ rootContext()->setContextProperty(QStringLiteral("_fileChooserView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_fileChooserModel"), m_model);
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/Inspector/FileChooser.qml")));
}
QSize FileChooserView::sizeHint() const
diff --git a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp
index 2863ae5f..b05a77ba 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp
@@ -56,12 +56,12 @@ ImageChooserView::ImageChooserView(QWidget *parent)
void ImageChooserView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_resDir"_L1,
- resourceImageUrl());
- rootContext()->setContextProperty("_imageChooserView"_L1, this);
- rootContext()->setContextProperty("_imageChooserModel"_L1, m_model);
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/Inspector/ImageChooser.qml"_L1));
+ rootContext()->setContextProperty(QStringLiteral("_resDir"),
+ StudioUtils::resourceImageUrl());
+ rootContext()->setContextProperty(QStringLiteral("_imageChooserView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_imageChooserModel"), m_model);
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/Inspector/ImageChooser.qml")));
}
QSize ImageChooserView::sizeHint() const
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
index bf077a4e..abde42ea 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
@@ -217,19 +217,20 @@ void InspectorControlView::mousePressEvent(QMouseEvent *event)
void InspectorControlView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_parentView"_L1, this);
- rootContext()->setContextProperty("_inspectorModel"_L1, m_inspectorControlModel);
- rootContext()->setContextProperty("_resDir"_L1, resourceImageUrl());
- rootContext()->setContextProperty("_tabOrderHandler"_L1, tabOrderHandler());
- rootContext()->setContextProperty("_mouseHelper"_L1, &m_mouseHelper);
-
- qmlRegisterUncreatableType<qt3dsdm::DataModelDataType>("Qt3DStudio", 1, 0, "DataModelDataType",
- "DataModelDataType is an enum container");
+ rootContext()->setContextProperty(QStringLiteral("_parentView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_inspectorModel"), m_inspectorControlModel);
+ rootContext()->setContextProperty(QStringLiteral("_resDir"), StudioUtils::resourceImageUrl());
+ rootContext()->setContextProperty(QStringLiteral("_tabOrderHandler"), tabOrderHandler());
+ rootContext()->setContextProperty(QStringLiteral("_mouseHelper"), &m_mouseHelper);
+
+ qmlRegisterUncreatableType<qt3dsdm::DataModelDataType>(
+ "Qt3DStudio", 1, 0, "DataModelDataType",
+ QStringLiteral("DataModelDataType is an enum container"));
qmlRegisterUncreatableType<qt3dsdm::AdditionalMetaDataType>(
"Qt3DStudio", 1, 0, "AdditionalMetaDataType",
- "AdditionalMetaDataType is an enum container");
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/Inspector/InspectorControlView.qml"_L1));
+ QStringLiteral("AdditionalMetaDataType is an enum container"));
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/Inspector/InspectorControlView.qml")));
}
QAbstractItemModel *InspectorControlView::inspectorControlModel() const
diff --git a/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp
index 28613eeb..b32cd3fa 100644
--- a/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp
@@ -55,13 +55,13 @@ MeshChooserView::MeshChooserView(QWidget *parent)
void MeshChooserView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_resDir"_L1,
- resourceImageUrl());
- rootContext()->setContextProperty("_meshChooserView"_L1, this);
- rootContext()->setContextProperty("_meshChooserModel"_L1, m_model);
+ rootContext()->setContextProperty(QStringLiteral("_resDir"),
+ StudioUtils::resourceImageUrl());
+ rootContext()->setContextProperty(QStringLiteral("_meshChooserView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_meshChooserModel"), m_model);
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/Inspector/MeshChooser.qml"_L1));
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/Inspector/MeshChooser.qml")));
}
QSize MeshChooserView::sizeHint() const
diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp
index e6faa1db..18273ff4 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp
@@ -143,10 +143,11 @@ void ObjectBrowserView::focusOutEvent(QFocusEvent *event)
void ObjectBrowserView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_objectBrowserView"_L1, this);
- rootContext()->setContextProperty("_resDir"_L1, resourceImageUrl());
- qmlRegisterUncreatableType<ObjectBrowserView>("Qt3DStudio", 1, 0, "ObjectBrowserView"
- , tr("Creation of ObjectBrowserView not allowed from QML"));
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/Inspector/ObjectBrowser.qml"_L1));
+ rootContext()->setContextProperty(QStringLiteral("_objectBrowserView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_resDir"), StudioUtils::resourceImageUrl());
+ qmlRegisterUncreatableType<ObjectBrowserView>(
+ "Qt3DStudio", 1, 0, "ObjectBrowserView",
+ QStringLiteral("Creation of ObjectBrowserView not allowed from QML"));
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/Inspector/ObjectBrowser.qml")));
}
diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp
index 51e65e56..46cc501a 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp
@@ -141,7 +141,7 @@ QVariant ObjectListModel::data(const QModelIndex &index,
}
case IconRole: {
auto info = m_objRefHelper->GetInfo(handle);
- return resourceImageUrl() + CStudioObjectTypes::GetNormalIconName(info.m_Type);
+ return StudioUtils::resourceImageUrl() + CStudioObjectTypes::GetNormalIconName(info.m_Type);
}
case TextColorRole: {
auto bridge = m_core->GetDoc()->GetStudioSystem()->GetClientDataModelBridge();
diff --git a/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp
index dda078f2..4ef7242c 100644
--- a/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp
@@ -56,11 +56,11 @@ TextureChooserView::TextureChooserView(QWidget *parent)
void TextureChooserView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_resDir"_L1, resourceImageUrl());
- rootContext()->setContextProperty("_textureChooserView"_L1, this);
- rootContext()->setContextProperty("_textureChooserModel"_L1, m_model);
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/Inspector/TextureChooser.qml"_L1));
+ rootContext()->setContextProperty(QStringLiteral("_resDir"), StudioUtils::resourceImageUrl());
+ rootContext()->setContextProperty(QStringLiteral("_textureChooserView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_textureChooserModel"), m_model);
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/Inspector/TextureChooser.qml")));
}
QSize TextureChooserView::sizeHint() const
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp
index a27f3af9..cb7a7a42 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp
+++ b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp
@@ -85,7 +85,7 @@ QVariant ProjectFileSystemModel::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DecorationRole: {
QString path = item.index.data(QFileSystemModel::FilePathRole).toString();
- return resourceImageUrl() + getIconName(path);
+ return StudioUtils::resourceImageUrl() + getIconName(path);
}
case IsExpandableRole: {
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
index 3337798b..66f73a6d 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
+++ b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
@@ -103,11 +103,11 @@ QSize ProjectView::sizeHint() const
void ProjectView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_resDir"_L1, resourceImageUrl());
- rootContext()->setContextProperty("_parentView"_L1, this);
+ rootContext()->setContextProperty(QStringLiteral("_resDir"), StudioUtils::resourceImageUrl());
+ rootContext()->setContextProperty(QStringLiteral("_parentView"), this);
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/Project/ProjectView.qml"_L1));
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/Project/ProjectView.qml")));
}
void ProjectView::effectAction(int row)
diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
index 19695809..7346ed63 100644
--- a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
+++ b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp
@@ -391,11 +391,11 @@ void SlideView::updateDataInputStatus()
void SlideView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
- rootContext()->setContextProperty("_parentView"_L1, this);
- rootContext()->setContextProperty("_resDir"_L1, resourceImageUrl());
+ rootContext()->setContextProperty(QStringLiteral("_parentView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_resDir"), StudioUtils::resourceImageUrl());
- engine()->addImportPath(qmlImportPath());
- setSource(QUrl("qrc:/Palettes/Slide/SlideView.qml"_L1));
+ engine()->addImportPath(StudioUtils::qmlImportPath());
+ setSource(QUrl(QStringLiteral("qrc:/Palettes/Slide/SlideView.qml")));
const QVector<EDataType> acceptedTypes = { EDataType::DataTypeString };
m_dataInputSelector = new DataInputSelectView(acceptedTypes, this);
diff --git a/src/Authoring/Studio/Render/StudioRenderer.cpp b/src/Authoring/Studio/Render/StudioRenderer.cpp
index 61af4114..8b08a6fe 100644
--- a/src/Authoring/Studio/Render/StudioRenderer.cpp
+++ b/src/Authoring/Studio/Render/StudioRenderer.cpp
@@ -303,7 +303,8 @@ struct SRendererImpl : public IStudioRenderer,
try {
m_RenderContext = std::make_shared<CWGLRenderContext>(inWindow);
- Q3DStudio::CString theResourcePath = Q3DStudio::CString::fromQString(resourcePath());
+ Q3DStudio::CString theResourcePath = Q3DStudio::CString::fromQString(
+ StudioUtils::resourcePath());
NVScopedRefCounted<qt3ds::render::IQt3DSRenderContextCore> theCore =
qt3ds::render::IQt3DSRenderContextCore::Create(
m_RenderContext->GetRenderContext().GetFoundation(),
@@ -353,7 +354,7 @@ struct SRendererImpl : public IStudioRenderer,
m_Rect = inRect;
if (IsInitialized()) {
- m_pixelRatio = devicePixelRatio();
+ m_pixelRatio = StudioUtils::devicePixelRatio();
m_RenderContext->BeginRender();
NVRenderContext &theContext = m_RenderContext->GetRenderContext();
theContext.SetViewport(qt3ds::render::NVRenderRect(0, 0, inRect.width(),
@@ -675,8 +676,9 @@ struct SRendererImpl : public IStudioRenderer,
QString projectPath = g_StudioApp.GetCore()->getProjectFile().getProjectPath();
if (!projectPath.isEmpty()) {
// Add the installed font folders from the res dir.
- Q3DStudio::CString thePath(Q3DStudio::CString::fromQString(
- resourcePath() + QStringLiteral("/Font")));
+ Q3DStudio::CString thePath(
+ Q3DStudio::CString::fromQString(
+ StudioUtils::resourcePath() + QStringLiteral("/Font")));
m_Context->GetTextRenderer()->AddSystemFontDirectory(
m_Context->GetStringTable().RegisterStr(thePath.c_str()));
m_Context->GetTextRenderer()->AddProjectFontDirectory(
diff --git a/src/Authoring/Studio/Render/StudioRotationWidget.cpp b/src/Authoring/Studio/Render/StudioRotationWidget.cpp
index 547039a0..f3e06cd6 100644
--- a/src/Authoring/Studio/Render/StudioRotationWidget.cpp
+++ b/src/Authoring/Studio/Render/StudioRotationWidget.cpp
@@ -250,7 +250,7 @@ struct SRotationWidget : public SStudioWidgetImpl<StudioWidgetTypes::Rotation>
qt3ds::render::NVRenderBlendEquationArgument(
NVRenderBlendEquation::Add, NVRenderBlendEquation::Add));
- float pixelRatio = float(devicePixelRatio());
+ float pixelRatio = float(StudioUtils::devicePixelRatio());
QT3DSF32 theRingRadius = 2 * CStudioPreferences::getSelectorLineLength() * pixelRatio;
QT3DSF32 theRingWidth = CStudioPreferences::getSelectorLineWidth() * pixelRatio;
QT3DSF32 theRingInner = theRingRadius;
diff --git a/src/Authoring/Studio/Render/StudioScaleWidget.cpp b/src/Authoring/Studio/Render/StudioScaleWidget.cpp
index 37fe20ec..9b5eec1f 100644
--- a/src/Authoring/Studio/Render/StudioScaleWidget.cpp
+++ b/src/Authoring/Studio/Render/StudioScaleWidget.cpp
@@ -149,7 +149,7 @@ struct SScaleWidget : public SStudioWidgetImpl<StudioWidgetTypes::Scale>
inRenderContext.SetDepthWriteEnabled(true);
inRenderContext.SetDepthTestEnabled(true);
inRenderContext.Clear(qt3ds::render::NVRenderClearValues::Depth);
- float pixelRatio = float(devicePixelRatio());
+ float pixelRatio = float(StudioUtils::devicePixelRatio());
QT3DSF32 axisWidth = pixelRatio;
QT3DSF32 triWidth = 3 * CStudioPreferences::getSelectorLineWidth() * pixelRatio;
QT3DSF32 axisStart = CStudioPreferences::getSelectorLineLength() / 3.0f * pixelRatio;
diff --git a/src/Authoring/Studio/Render/StudioTranslationWidget.cpp b/src/Authoring/Studio/Render/StudioTranslationWidget.cpp
index 2be81181..0897a866 100644
--- a/src/Authoring/Studio/Render/StudioTranslationWidget.cpp
+++ b/src/Authoring/Studio/Render/StudioTranslationWidget.cpp
@@ -76,7 +76,7 @@ struct STranslationWidget : public SStudioWidgetImpl<StudioWidgetTypes::Translat
inRenderContext.SetDepthTestEnabled(true);
if (m_XAxis == nullptr) {
TBase::SetupRender(inWidgetContext, inRenderContext);
- float pixelRatio = float(devicePixelRatio());
+ float pixelRatio = float(StudioUtils::devicePixelRatio());
QT3DSF32 axisWidth = pixelRatio;
QT3DSF32 triWidth = 4 * CStudioPreferences::getSelectorLineWidth() * pixelRatio;
QT3DSF32 axisStart = CStudioPreferences::getSelectorLineLength() / 3.0f * pixelRatio;
diff --git a/src/Authoring/Studio/Utils/ResourceCache.cpp b/src/Authoring/Studio/Utils/ResourceCache.cpp
index a4d4ea98..c51a01f0 100644
--- a/src/Authoring/Studio/Utils/ResourceCache.cpp
+++ b/src/Authoring/Studio/Utils/ResourceCache.cpp
@@ -80,12 +80,12 @@ QPixmap CResourceCache::GetBitmap(const QString &inName)
if (thePos != m_Images.end()) {
theImage = thePos->second;
} else {
- const QString resPath = QString("%1%2").arg(resourceImagePath(), inName);
- if (theImage.load(resPath)) {
+ const QString resPath = QStringLiteral("%1%2").arg(StudioUtils::resourceImagePath(),
+ inName);
+ if (theImage.load(resPath))
m_Images[inName] = theImage;
- } else {
+ else
qWarning() << Q_FUNC_INFO << "missing image at path:" << resPath;
- }
}
}
return theImage;
diff --git a/src/Authoring/Studio/Utils/StudioUtils.cpp b/src/Authoring/Studio/Utils/StudioUtils.cpp
index 98281e9c..b2c35963 100644
--- a/src/Authoring/Studio/Utils/StudioUtils.cpp
+++ b/src/Authoring/Studio/Utils/StudioUtils.cpp
@@ -32,6 +32,7 @@
#include "StudioPreferences.h"
#include "StudioClipboard.h"
#include "Pt.h"
+#include "StudioUtils.h"
#include <QtWidgets/qapplication.h>
#include <QtWidgets/qdesktopwidget.h>
@@ -40,116 +41,29 @@
#include <QtGui/qwindow.h>
#include <QtCore/qurl.h>
-//==============================================================================
-/**
- * FormatTimeString: Format a time string.
- * @param inTimeMS Time in milliseconds.
- * @return The formatted time string in MM:SS:MS format.
- */
-Q3DStudio::CString FormatTimeString(long inTimeMS)
-{
- BOOL theNegativeFlag = (inTimeMS < 0);
- long theTimeMS = abs(inTimeMS);
- Q3DStudio::CString theTimeString;
- long theMM, theSS;
-
- // Format the time in MM:SS:MS format
-
- // Get the MM value
- theMM = theTimeMS / 60000;
- theTimeMS -= (theMM * 60000);
-
- // Get the SS value
- theSS = theTimeMS / 1000;
- theTimeMS -= (theSS * 1000);
-
- // Remainder is MS value
-
- // Format the string
- theTimeString.Format(_LSTR("%d:%0.2d.%0.2d"), theMM, theSS, theTimeMS / 10);
-
- // If the original time was negative, append the "-" to the front of the time string.
- if (theNegativeFlag) {
- theTimeString.Insert(0, "-");
- }
-
- return theTimeString;
-}
-
-//==============================================================================
-/**
- * Checks a string to determine if it is numeric.
- * @param inString String to check for all numeric characters.
- * @return TRUE if the string is numeric.
- */
-bool IsNumericString(const Q3DStudio::CString &inString)
-{
- Q3DStudio::CString theNumbers = "0123456789";
- long theLoop;
- bool theNumericFlag = true;
-
- // Iterate through the entire string
- for (theLoop = 0; theLoop < inString.Length() && theNumericFlag; theLoop++) {
- // Check each character for being numeric
- if (theNumbers.Find(inString.Extract(theLoop, 1)) == Q3DStudio::CString::ENDOFSTRING)
- theNumericFlag = false;
- }
-
- return theNumericFlag;
-}
-
-long TimeToPos(long inTime, double inTimeRatio)
-{
- return ::dtol(inTime * inTimeRatio) + CStudioPreferences::GUTTER_SIZE;
-}
-
-long TimeToPos(double inTime, double inTimeRatio)
-{
- return ::dtol(inTime * inTimeRatio) + CStudioPreferences::GUTTER_SIZE;
-}
-
-long PosToTime(long inPos, double inTimeRatio)
-{
- return ::dtol((inPos - CStudioPreferences::GUTTER_SIZE) / inTimeRatio);
-}
-
-//=============================================================================
-/**
- * opens the url in the web browser
- *
- * @param inURL
- * the URL to open
- *
- * @return void
- */
-void ShowURLInBrowser(const Q3DStudio::CString &inURL)
-{
- QDesktopServices::openUrl(QUrl(inURL.toQString()));
-}
-
-QString resourcePath()
+QString StudioUtils::resourcePath()
{
return QStringLiteral(":/res");
}
-QString resourceImagePath()
+QString StudioUtils::resourceImagePath()
{
return QStringLiteral(":/images/");
}
-QString resourceImageUrl()
+QString StudioUtils::resourceImageUrl()
{
return QStringLiteral("qrc:/images/");
}
// Returns the qml import path required for binary installations
-QString qmlImportPath()
+QString StudioUtils::qmlImportPath()
{
QString extraImportPath(QStringLiteral("%1/qml"));
return extraImportPath.arg(QApplication::applicationDirPath());
}
-qreal devicePixelRatio()
+qreal StudioUtils::devicePixelRatio()
{
qreal pixelRatio = 1.0;
diff --git a/src/Authoring/Studio/Utils/StudioUtils.h b/src/Authoring/Studio/Utils/StudioUtils.h
index b174e240..9874ecf9 100644
--- a/src/Authoring/Studio/Utils/StudioUtils.h
+++ b/src/Authoring/Studio/Utils/StudioUtils.h
@@ -27,37 +27,21 @@
**
****************************************************************************/
-//==============================================================================
-// Prefix
-//==============================================================================
#ifndef INCLUDED_STUDIO_UTILS_H
-#define INCLUDED_STUDIO_UTILS_H 1
+#define INCLUDED_STUDIO_UTILS_H
-#pragma once
+#include <QtCore/qstring.h>
-#include "Qt3DSString.h"
-#include <QPoint>
-#include <QSize>
+class StudioUtils {
+public:
+ static QString resourceImagePath();
+ static QString resourceImageUrl();
-//==============================================================================
-// Functions
-//==============================================================================
-Q3DStudio::CString FormatTimeString(long inTimeMS);
-bool IsNumericString(Q3DStudio::CString inString);
+ static QString resourcePath();
-long TimeToPos(long inTime, double inTimeRatio);
-long TimeToPos(double inTime, double inTimeRatio);
-long PosToTime(long inPos, double inTimeRatio);
+ static QString qmlImportPath();
-void ShowURLInBrowser(Q3DStudio::CString inURL);
-
-QString resourceImagePath();
-QString resourceImageUrl();
-
-QString resourcePath();
-
-QString qmlImportPath();
-
-qreal devicePixelRatio();
+ static qreal devicePixelRatio();
+};
#endif // INCLUDED_STUDIO_UTILS_H