summaryrefslogtreecommitdiffstats
path: root/src/Authoring
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2018-10-05 15:04:23 +0300
committerMahmoud Badri <mahmoud.badri@qt.io>2018-10-10 10:29:26 +0000
commitfe04c1301a1a6865fc96ee3a561696015ba3a1ae (patch)
tree4206bf178c6add95de590a5cd20248ffc58f9c2b /src/Authoring
parent9b0276d7aba5d93a2619d0f39698c43cdb13c084 (diff)
Change many CStrings to QString
- A lot of CString, CFilePath, and Qt3DSFile occureneces and their relevant code has been removed to save the costy back and forth conversion between CString and QString. - Renovated several classes as part of the process (Preferences classes, recent items, build configuration, probably few more) - Assorted tweaks here and there Task-number: QT3DS-1899 Task-number: QT3DS-2455 Change-Id: Ibbf4c3b7ab0b9fe6e19d8aed822fa29d43b99086 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring')
-rw-r--r--src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp8
-rw-r--r--src/Authoring/Client/Code/Core/Commands/CmdDataModel.h6
-rw-r--r--src/Authoring/Client/Code/Core/Core/Core.cpp93
-rw-r--r--src/Authoring/Client/Code/Core/Core/Core.h8
-rw-r--r--src/Authoring/Client/Code/Core/Core/Dispatch.cpp34
-rw-r--r--src/Authoring/Client/Code/Core/Core/Dispatch.h29
-rw-r--r--src/Authoring/Client/Code/Core/Core/DispatchListeners.h29
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.cpp94
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.h20
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp2
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp41
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Exceptions.h57
-rw-r--r--src/Authoring/Client/Code/Core/Doc/IDoc.h4
-rw-r--r--src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h11
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Qt3DSDMStudioSystem.cpp9
-rw-r--r--src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h1
-rw-r--r--src/Authoring/Client/Code/Core/Utility/BuildConfigParser.cpp65
-rw-r--r--src/Authoring/Client/Code/Core/Utility/BuildConfigParser.h72
-rw-r--r--src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp190
-rw-r--r--src/Authoring/Client/Code/Core/Utility/StudioPreferences.h23
-rw-r--r--src/Authoring/Client/Code/Core/Utility/StudioProjectVariables.cpp281
-rw-r--r--src/Authoring/Client/Code/Core/Utility/StudioProjectVariables.h96
-rw-r--r--src/Authoring/Common/Code/Exceptions/StudioException.h10
-rw-r--r--src/Authoring/Common/Code/Exceptions/XMLException.cpp6
-rw-r--r--src/Authoring/Common/Code/Exceptions/XMLException.h15
-rw-r--r--src/Authoring/Common/Code/IO/BufferedInputStream.cpp2
-rw-r--r--src/Authoring/Common/Code/IO/BufferedInputStream.h6
-rw-r--r--src/Authoring/Common/Code/IO/BufferedOutputStream.cpp4
-rw-r--r--src/Authoring/Common/Code/IO/BufferedOutputStream.h4
-rw-r--r--src/Authoring/Common/Code/IO/FileInputStream.cpp8
-rw-r--r--src/Authoring/Common/Code/IO/FileInputStream.h11
-rw-r--r--src/Authoring/Common/Code/IO/FileOutputStream.cpp9
-rw-r--r--src/Authoring/Common/Code/IO/FileOutputStream.h5
-rw-r--r--src/Authoring/Common/Code/IO/IOLibraryException.h10
-rw-r--r--src/Authoring/Common/Code/IO/IOStreams.cpp4
-rw-r--r--src/Authoring/Common/Code/IO/IOStreams.h8
-rw-r--r--src/Authoring/Common/Code/IO/InputStream.h8
-rw-r--r--src/Authoring/Common/Code/IO/MemInputStream.cpp2
-rw-r--r--src/Authoring/Common/Code/IO/MemInputStream.h6
-rw-r--r--src/Authoring/Common/Code/IO/MemOutputStream.h2
-rw-r--r--src/Authoring/Common/Code/IO/OutputStream.h4
-rw-r--r--src/Authoring/Common/Code/Preferences.h71
-rw-r--r--src/Authoring/Common/Code/Qt3DSFile.h2
-rw-r--r--src/Authoring/Common/Code/Qt3DSFileTools.cpp9
-rw-r--r--src/Authoring/Common/Code/Qt3DSFileTools.h4
-rw-r--r--src/Authoring/Common/Code/Serialize/FormattedInputStream.cpp6
-rw-r--r--src/Authoring/Common/Code/Serialize/FormattedInputStream.h7
-rw-r--r--src/Authoring/Common/Code/Serialize/FormattedOutputStream.cpp2
-rw-r--r--src/Authoring/Common/Code/Serialize/FormattedOutputStream.h2
-rw-r--r--src/Authoring/Common/Code/Serialize/PreferencesSerializer.cpp254
-rw-r--r--src/Authoring/Common/Code/Serialize/PreferencesSerializer.h85
-rw-r--r--src/Authoring/Common/Code/Serialize/ProjectSettingsSerializer.h1
-rw-r--r--src/Authoring/Common/Code/Thread/Thread.cpp2
-rw-r--r--src/Authoring/Common/Code/Thread/ThreadException.h12
-rw-r--r--src/Authoring/Common/Code/_Win32/Preferences.cpp323
-rw-r--r--src/Authoring/Common/Code/_Win32/Qt3DSFile.cpp13
-rw-r--r--src/Authoring/Common/Common.pro1
-rw-r--r--src/Authoring/CoreLib/CoreLib.pro1
-rw-r--r--src/Authoring/Studio/Application/AboutDlg.cpp3
-rw-r--r--src/Authoring/Studio/Application/ProjectFile.cpp26
-rw-r--r--src/Authoring/Studio/Application/ProjectFile.h2
-rw-r--r--src/Authoring/Studio/Application/StudioApp.cpp204
-rw-r--r--src/Authoring/Studio/Application/StudioApp.h28
-rw-r--r--src/Authoring/Studio/MainFrm.cpp35
-rw-r--r--src/Authoring/Studio/MainFrm.h6
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp2
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp5
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp6
-rw-r--r--src/Authoring/Studio/Palettes/Progress/ProgressView.cpp8
-rw-r--r--src/Authoring/Studio/Palettes/Progress/ProgressView.h4
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp8
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectView.cpp12
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectView.h6
-rw-r--r--src/Authoring/Studio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.cpp2
-rw-r--r--src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp8
-rw-r--r--src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp18
-rw-r--r--src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp3
-rw-r--r--src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp5
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp4
-rw-r--r--src/Authoring/Studio/PreviewHelper.cpp96
-rw-r--r--src/Authoring/Studio/PreviewHelper.h7
-rw-r--r--src/Authoring/Studio/Render/StudioRenderer.cpp2
-rw-r--r--src/Authoring/Studio/Render/StudioRendererTranslation.cpp9
-rw-r--r--src/Authoring/Studio/Render/StudioRendererTranslation.h6
-rw-r--r--src/Authoring/Studio/UI/RecentItems.cpp94
-rw-r--r--src/Authoring/Studio/UI/RecentItems.h29
-rw-r--r--src/Authoring/Studio/UI/StartupDlg.cpp13
-rw-r--r--src/Authoring/Studio/UI/StartupDlg.h8
-rw-r--r--src/Authoring/Studio/Workspace/Dialogs.cpp60
-rw-r--r--src/Authoring/Studio/Workspace/Dialogs.h15
90 files changed, 869 insertions, 1957 deletions
diff --git a/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp b/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp
index a2ee19d4..3f3b95b2 100644
--- a/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp
+++ b/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp
@@ -77,11 +77,11 @@ CmdDataModel::~CmdDataModel()
{
}
-void CmdDataModel::SetName(const Q3DStudio::CString &inName)
+void CmdDataModel::SetName(const QString &inName)
{
m_Name = inName;
}
-Q3DStudio::CString CmdDataModel::GetName() const
+QString CmdDataModel::GetName() const
{
return m_Name;
}
@@ -134,7 +134,7 @@ void CmdDataModel::ReleaseConsumer(bool inRunNotifications)
void CmdDataModel::DataModelUndo()
{
if (HasTransactions()) {
- qCInfo(qt3ds::TRACE_INFO) << "Undoing " << m_Name.GetCharStar()
+ qCInfo(qt3ds::TRACE_INFO) << "Undoing " << m_Name
<< " generated from: " << m_File.GetCharStar() << "(" << m_Line << ")";
m_AfterDoAppState.Store(m_Doc);
m_AfterDoAppState.PreNotify(m_BeforeDoAppState, m_Doc);
@@ -155,7 +155,7 @@ void CmdDataModel::RunUndoNotifications()
void CmdDataModel::DataModelRedo()
{
if (HasTransactions()) {
- qCInfo(qt3ds::TRACE_INFO) << "Redoing " << m_Name.GetCharStar()
+ qCInfo(qt3ds::TRACE_INFO) << "Redoing " << m_Name
<< " generated from: " << m_File.GetCharStar() << "(" << m_Line << ")";
m_BeforeDoAppState.Store(m_Doc);
m_BeforeDoAppState.PreNotify(m_AfterDoAppState, m_Doc);
diff --git a/src/Authoring/Client/Code/Core/Commands/CmdDataModel.h b/src/Authoring/Client/Code/Core/Commands/CmdDataModel.h
index 3758f7ed..7d601826 100644
--- a/src/Authoring/Client/Code/Core/Commands/CmdDataModel.h
+++ b/src/Authoring/Client/Code/Core/Commands/CmdDataModel.h
@@ -59,14 +59,14 @@ struct SApplicationState
class CmdDataModel
{
public:
- Q3DStudio::CString m_Name;
+ QString m_Name;
Q3DStudio::CString m_File;
int m_Line;
CmdDataModel(CDoc &inDoc);
~CmdDataModel();
- void SetName(const Q3DStudio::CString &inName);
- Q3DStudio::CString GetName() const;
+ void SetName(const QString &inName);
+ QString GetName() const;
bool HasTransactions() const;
bool ConsumerExists() const;
void SetConsumer();
diff --git a/src/Authoring/Client/Code/Core/Core/Core.cpp b/src/Authoring/Client/Code/Core/Core/Core.cpp
index d4b73a00..f55ebaa4 100644
--- a/src/Authoring/Client/Code/Core/Core/Core.cpp
+++ b/src/Authoring/Client/Code/Core/Core/Core.cpp
@@ -111,21 +111,16 @@ bool CCore::LoadBuildConfigurations()
{
using namespace Q3DStudio;
// See if we can find the build configurations where they are located first
- CFilePath theCurrentPath(Qt3DSFile::GetApplicationDirectory().GetAbsolutePath());
- CFilePath theMainDir = theCurrentPath.GetDirectory()
- .GetDirectory()
- .GetDirectory();
- CFilePath theStudioDir =
- CFilePath::CombineBaseAndRelative(theMainDir,
- CFilePath(L"Studio/Build Configurations"));
- Qt3DSFile theConfigurationDirectory(theStudioDir);
- if (!theStudioDir.IsDirectory())
- theConfigurationDirectory = Qt3DSFile(
- Qt3DSFile::GetApplicationDirectory().GetAbsolutePath(),
- Q3DStudio::CString(L"Build Configurations")); // Installed directory
+ QString configDirPath = QDir::cleanPath(Qt3DSFile::GetApplicationDirectory()
+ + QStringLiteral("/../../../Studio/Build Configurations"));
+
+ if (!QFileInfo(configDirPath).isDir()) {
+ configDirPath = QDir::cleanPath(Qt3DSFile::GetApplicationDirectory()
+ + QStringLiteral("/Build Configurations"));
+ }
Q3DStudio::CBuildConfigParser theParser(m_BuildConfigurations);
- bool theSuccess = theParser.LoadConfigurations(theConfigurationDirectory);
+ bool theSuccess = theParser.LoadConfigurations(configDirPath);
if (!theSuccess) {
m_Dispatch->FireOnBuildConfigurationFileParseFail(theParser.GetErrorMessage());
} else {
@@ -157,8 +152,8 @@ void CCore::InitAndValidateBuildConfiguration()
Q3DStudio::CBuildConfiguration::TConfigProperties::iterator theConfigPropIter;
for (theConfigPropIter = theConfigProperties.begin();
theConfigPropIter != theConfigProperties.end(); ++theConfigPropIter) {
- const Q3DStudio::CString &thePropName = theConfigPropIter->GetName();
- Q3DStudio::CString theStoredValue = CStudioPreferences::GetPreviewProperty(thePropName);
+ const QString &thePropName = theConfigPropIter->GetName();
+ QString theStoredValue = CStudioPreferences::GetPreviewProperty(thePropName);
if (!theConfigPropIter->HasValue(theStoredValue)) {
// add this property in
if (theConfigPropIter->GetAcceptableValues().size())
@@ -192,12 +187,12 @@ void CCore::RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, QWidget
CCore::SetTimebarEnd);
}
-void CCore::GetCreateDirectoryFileName(const Qt3DSFile &inDocument,
+void CCore::GetCreateDirectoryFileName(const QString &inDocument,
Q3DStudio::CFilePath &outFinalDir,
Q3DStudio::CFilePath &outFinalDoc)
{
using namespace Q3DStudio;
- CFilePath theOriginal(inDocument.GetAbsolutePath());
+ CFilePath theOriginal(inDocument);
CFilePath theName(theOriginal.GetFileName());
CString theStem(theOriginal.GetFileStem());
CFilePath theDir = theOriginal.GetDirectory();
@@ -220,39 +215,41 @@ ProjectFile &CCore::getProjectFile()
*
* @return bool creation successful
*/
-bool CCore::OnNewDocument(const Qt3DSFile &inDocument, bool isNewProject, bool silent)
+bool CCore::OnNewDocument(const QString &inDocument, bool isNewProject, bool silent)
{
CDispatchDataModelNotificationScope __dispatchScope(*m_Dispatch);
m_Doc->CloseDocument();
- Q3DStudio::CFilePath theDocument(inDocument.GetAbsolutePath());
+ QString theDocument = inDocument;
if (isNewProject) {
+ QFileInfo info(inDocument);
+ QDir dir(info.absoluteDir());
+ QString projName = info.completeBaseName(); // project name
+ dir.mkdir(projName); // create project directory
+ dir.cd(projName); // go inside project directory
+
// create asset folders
- using namespace Q3DStudio;
- Q3DStudio::CFilePath theFinalDir;
- GetCreateDirectoryFileName(inDocument, theFinalDir, theDocument);
- CFilePath::CombineBaseAndRelative(theFinalDir, CFilePath(L"effects")).CreateDir(true);
- CFilePath::CombineBaseAndRelative(theFinalDir, CFilePath(L"fonts")).CreateDir(true);
- CFilePath::CombineBaseAndRelative(theFinalDir, CFilePath(L"maps")).CreateDir(true);
- CFilePath::CombineBaseAndRelative(theFinalDir, CFilePath(L"materials")).CreateDir(true);
- CFilePath::CombineBaseAndRelative(theFinalDir, CFilePath(L"models")).CreateDir(true);
- CFilePath::CombineBaseAndRelative(theFinalDir, CFilePath(L"presentations")).CreateDir(true);
- CFilePath::CombineBaseAndRelative(theFinalDir, CFilePath(L"qml streams")).CreateDir(true);
- CFilePath::CombineBaseAndRelative(theFinalDir, CFilePath(L"scripts")).CreateDir(true);
+ dir.mkdir(QStringLiteral("effects"));
+ dir.mkdir(QStringLiteral("fonts"));
+ dir.mkdir(QStringLiteral("maps"));
+ dir.mkdir(QStringLiteral("materials"));
+ dir.mkdir(QStringLiteral("models"));
+ dir.mkdir(QStringLiteral("presentations"));
+ dir.mkdir(QStringLiteral("qml streams"));
+ dir.mkdir(QStringLiteral("scripts"));
// create the project .uia file
- m_projectFile.create(theDocument.completeBaseName(), theFinalDir.toQString());
+ QString uiaPath = info.absolutePath() + QStringLiteral("/") + projName
+ + QStringLiteral("/") + projName + QStringLiteral(".uia");
+ m_projectFile.create(uiaPath);
- // set the default uip file path to the presentations folder
- theDocument.setFile(QDir(theDocument.absolutePath() + QStringLiteral("/presentations")),
- theDocument.GetFileName().toQString());
+ // set the default uip file path to be inside the presentations folder
+ theDocument = dir.absolutePath() + QStringLiteral("/presentations/") + info.fileName();
}
- Qt3DSFile fileDocument(theDocument.toCString());
-
- if (!m_Doc->SetDocumentPath(fileDocument)) {
+ if (!m_Doc->SetDocumentPath(theDocument)) {
m_Doc->CreateNewDocument(); // Required to prevent a crash, as the old one is already closed
return false;
}
@@ -260,10 +257,10 @@ bool CCore::OnNewDocument(const Qt3DSFile &inDocument, bool isNewProject, bool s
m_Doc->CreateNewDocument();
// Serialize the new document.
- m_Doc->SaveDocument(fileDocument);
+ m_Doc->SaveDocument(theDocument);
// write a new presentation node to the uia file
- m_projectFile.addPresentationNode(theDocument.absoluteFilePath());
+ m_projectFile.addPresentationNode(theDocument);
m_projectFile.updateDocPresentationId();
m_projectFile.loadSubpresentationsAndDatainputs(g_StudioApp.m_subpresentations,
g_StudioApp.m_dataInputDialogItems);
@@ -281,10 +278,10 @@ bool CCore::OnNewDocument(const Qt3DSFile &inDocument, bool isNewProject, bool s
* This will do all the prompting, directory stuff necessary and perform the
* saving of the document.
*/
-void CCore::OnSaveDocument(const Qt3DSFile &inDocument, bool inSaveCopy /*= false*/)
+void CCore::OnSaveDocument(const QString &inDocument, bool inSaveCopy /*= false*/)
{
m_JustSaved = true;
- GetDispatch()->FireOnSavingPresentation(&inDocument);
+ GetDispatch()->FireOnSavingPresentation(inDocument);
bool isSuccess = false;
try {
OnSaveDocumentCatcher(inDocument, inSaveCopy);
@@ -305,17 +302,17 @@ void CCore::OnSaveDocument(const Qt3DSFile &inDocument, bool inSaveCopy /*= fals
* leave the document in a dirty state and not update it to point to the new
* file path.
*/
-void CCore::OnSaveDocumentCatcher(const Qt3DSFile &inDocument, bool inSaveCopy /*= false*/)
+void CCore::OnSaveDocumentCatcher(const QString &inDocument, bool inSaveCopy /*= false*/)
{
- m_Dispatch->FireOnProgressBegin(Q3DStudio::CString::fromQString(QObject::tr("Saving ")),
- inDocument.GetName());
+ QFileInfo fileInfo(inDocument);
+ m_Dispatch->FireOnProgressBegin(QObject::tr("Saving "), fileInfo.fileName());
bool theDisplaySaveFailDialog = false;
- bool theFileExists = inDocument.Exists();
- Qt3DSFile theTempFile(inDocument);
+ bool theFileExists = fileInfo.exists();
+ Qt3DSFile theTempFile(fileInfo);
// Test for readonly files
- if (theFileExists && inDocument.CanWrite() == false)
+ if (theFileExists && !fileInfo.isWritable())
theDisplaySaveFailDialog = true;
else {
try {
@@ -332,7 +329,7 @@ void CCore::OnSaveDocumentCatcher(const Qt3DSFile &inDocument, bool inSaveCopy /
}
}
- m_Doc->SaveDocument(theTempFile);
+ m_Doc->SaveDocument(theTempFile.GetAbsolutePath().toQString());
// update the original file
if (theFileExists)
diff --git a/src/Authoring/Client/Code/Core/Core/Core.h b/src/Authoring/Client/Code/Core/Core/Core.h
index 15b3c5af..7a820a54 100644
--- a/src/Authoring/Client/Code/Core/Core/Core.h
+++ b/src/Authoring/Client/Code/Core/Core/Core.h
@@ -63,16 +63,16 @@ public:
bool LoadBuildConfigurations();
void RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, QWidget *actionParent);
- bool OnNewDocument(const Qt3DSFile &inDocument, bool isNewProject, bool silent = false);
- void OnSaveDocument(const Qt3DSFile &inDocument, bool inSaveCopy = false);
- void OnSaveDocumentCatcher(const Qt3DSFile &inDocument, bool inSaveCopy = false);
+ bool OnNewDocument(const QString &inDocument, bool isNewProject, bool silent = false);
+ void OnSaveDocument(const QString &inDocument, bool inSaveCopy = false);
+ void OnSaveDocumentCatcher(const QString &inDocument, bool inSaveCopy = false);
void SetCommandStackModifier(ICmdStackModifier *inModifier);
bool ExecuteCommand(CCmd *inCommand, bool inIsSynchronous = true);
void CommitCurrentCommand();
void SetCommandModifiedFlag(bool inModified) override;
void CommandUpdate(unsigned long inUpdateFlags) override;
- void GetCreateDirectoryFileName(const Qt3DSFile &inDocument, Q3DStudio::CFilePath &outFinalDir,
+ void GetCreateDirectoryFileName(const QString &inDocument, Q3DStudio::CFilePath &outFinalDir,
Q3DStudio::CFilePath &outFinalDoc);
// CPresentationListener
diff --git a/src/Authoring/Client/Code/Core/Core/Dispatch.cpp b/src/Authoring/Client/Code/Core/Core/Dispatch.cpp
index 8a53b39e..c445d680 100644
--- a/src/Authoring/Client/Code/Core/Core/Dispatch.cpp
+++ b/src/Authoring/Client/Code/Core/Core/Dispatch.cpp
@@ -31,7 +31,6 @@
#include "Dispatch.h"
#include "DispatchListeners.h"
#include "MasterP.h"
-#include "Qt3DSFile.h"
#include "Cmd.h"
#include "SelectedValueImpl.h"
@@ -133,7 +132,7 @@ void CDispatch::RemoveDocumentBufferCacheListener(IDocumentBufferCacheListener *
{
m_DocumentBufferCacheListeners.RemoveListener(inListener);
}
-void CDispatch::FireDocumentBufferCacheInvalidated(const Q3DStudio::CString &inCache)
+void CDispatch::FireDocumentBufferCacheInvalidated(const QString &inCache)
{
m_DocumentBufferCacheListeners.FireEvent(&IDocumentBufferCacheListener::OnBufferInvalidated,
inCache);
@@ -289,7 +288,7 @@ void CDispatch::FireOnClosingPresentation()
m_PresentationChangeListeners.FireEvent(&CPresentationChangeListener::OnClosingPresentation);
}
-void CDispatch::FireOnSavingPresentation(const Qt3DSFile *inNewPresentationFile)
+void CDispatch::FireOnSavingPresentation(const QString &inNewPresentationFile)
{
m_PresentationChangeListeners.FireEvent(&CPresentationChangeListener::OnSavingPresentation,
inNewPresentationFile);
@@ -361,7 +360,7 @@ void CDispatch::RemoveNavigationListener(CNavigationListener *inListener)
* Fire an event to the navigation listeners to navigate to the URL.
* This is used to update the assistant palette to the specified URL.
*/
-void CDispatch::FireOnNavigate(const Q3DStudio::CString &inURL, bool inForceDisplay)
+void CDispatch::FireOnNavigate(const QString &inURL, bool inForceDisplay)
{
m_NavigationListeners.FireEvent(&CNavigationListener::OnNavigate, inURL, inForceDisplay);
}
@@ -388,7 +387,7 @@ void CDispatch::RemoveFileOpenListener(CFileOpenListener *inListener)
/**
* Fire an event to all the file open listeners that a has been opened.
*/
-void CDispatch::FireOnOpenDocument(const Qt3DSFile &inFile, bool inSucceeded)
+void CDispatch::FireOnOpenDocument(const QString &inFile, bool inSucceeded)
{
m_FileOpenListeners.FireEvent(&CFileOpenListener::OnOpenDocument, inFile, inSucceeded);
}
@@ -397,7 +396,7 @@ void CDispatch::FireOnOpenDocument(const Qt3DSFile &inFile, bool inSucceeded)
/**
* Fire an event to all the file open listeners that a has been saved.
*/
-void CDispatch::FireOnSaveDocument(const Qt3DSFile &inFile, bool inSucceeded, bool inSaveCopy)
+void CDispatch::FireOnSaveDocument(const QString &inFile, bool inSucceeded, bool inSaveCopy)
{
m_FileOpenListeners.FireEvent(&CFileOpenListener::OnSaveDocument, inFile, inSucceeded,
inSaveCopy);
@@ -407,7 +406,7 @@ void CDispatch::FireOnSaveDocument(const Qt3DSFile &inFile, bool inSucceeded, bo
/**
* Fire an event to all the file open listeners that a has been saved.
*/
-void CDispatch::FireOnDocumentPathChanged(const Qt3DSFile &inNewPath)
+void CDispatch::FireOnDocumentPathChanged(const QString &inNewPath)
{
m_FileOpenListeners.FireEvent(&CFileOpenListener::OnDocumentPathChanged, inNewPath);
}
@@ -461,7 +460,7 @@ void CDispatch::RemoveSelectedNodePropChangeListener(CSelectedNodePropChangeList
/**
* Fire an event to all the selected node property change listeners
*/
-void CDispatch::FireOnSelectedNodePropChange(const Q3DStudio::CString &inPropertyName)
+void CDispatch::FireOnSelectedNodePropChange(const QString &inPropertyName)
{
m_SelectedNodePropChangeListeners.FireEvent(
&CSelectedNodePropChangeListener::OnPropValueChanged, inPropertyName);
@@ -571,13 +570,13 @@ void CDispatch::RemoveAppStatusListener(CAppStatusListener *inListener)
m_AppStatusListeners.RemoveListener(inListener);
}
-void CDispatch::FireOnDisplayAppStatus(Q3DStudio::CString &inStatusMsg)
+void CDispatch::FireOnDisplayAppStatus(const QString &inStatusMsg)
{
m_AppStatusListeners.FireEvent(&CAppStatusListener::OnDisplayAppStatus, inStatusMsg);
}
-void CDispatch::FireOnProgressBegin(const Q3DStudio::CString &inActionText,
- const Q3DStudio::CString &inAdditionalText)
+void CDispatch::FireOnProgressBegin(const QString &inActionText,
+ const QString &inAdditionalText)
{
m_AppStatusListeners.FireEvent(&CAppStatusListener::OnProgressBegin, inActionText,
inAdditionalText);
@@ -610,7 +609,7 @@ void CDispatch::FireOnPasteFail()
m_FailListeners.FireEvent(&CFailListener::OnPasteFail);
}
-void CDispatch::FireOnBuildConfigurationFileParseFail(const Q3DStudio::CString &inMessage)
+void CDispatch::FireOnBuildConfigurationFileParseFail(const QString &inMessage)
{
m_FailListeners.FireEvent(&CFailListener::OnBuildconfigurationFileParseFail, inMessage);
}
@@ -620,18 +619,13 @@ void CDispatch::FireOnSaveFail(bool inKnownError)
m_FailListeners.FireEvent(&CFailListener::OnSaveFail, inKnownError);
}
-void CDispatch::FireOnProjectVariableFail(const Q3DStudio::CString &inMessage)
-{
- m_FailListeners.FireEvent(&CFailListener::OnProjectVariableFail, inMessage);
-}
-
-void CDispatch::FireOnErrorFail(const Q3DStudio::CString &inText)
+void CDispatch::FireOnErrorFail(const QString &inText)
{
m_FailListeners.FireEvent(&CFailListener::OnErrorFail, inText);
}
-void CDispatch::FireOnRefreshResourceFail(const Q3DStudio::CString &inResourceName,
- const Q3DStudio::CString &inDescription)
+void CDispatch::FireOnRefreshResourceFail(const QString &inResourceName,
+ const QString &inDescription)
{
m_FailListeners.FireEvent(&CFailListener::OnRefreshResourceFail, inResourceName, inDescription);
}
diff --git a/src/Authoring/Client/Code/Core/Core/Dispatch.h b/src/Authoring/Client/Code/Core/Core/Dispatch.h
index 358031e7..65cd51f9 100644
--- a/src/Authoring/Client/Code/Core/Core/Dispatch.h
+++ b/src/Authoring/Client/Code/Core/Core/Dispatch.h
@@ -51,7 +51,6 @@
class CSceneDragListener;
class CSelectionChangeListener;
class CAsset;
-class Qt3DSFile;
class CURL;
class CPresentationChangeListener;
class CResourceChangeListener;
@@ -110,7 +109,7 @@ public:
void AddDocumentBufferCacheListener(IDocumentBufferCacheListener *inListener);
void RemoveDocumentBufferCacheListener(IDocumentBufferCacheListener *inListener);
- void FireDocumentBufferCacheInvalidated(const Q3DStudio::CString &inCache);
+ void FireDocumentBufferCacheInvalidated(const QString &inCache);
// Scene drag
void AddSceneDragListener(CSceneDragListener *inListener);
@@ -135,7 +134,7 @@ public:
void FireOnLoadedSubPresentation();
void FireOnNewPresentation();
void FireOnClosingPresentation();
- void FireOnSavingPresentation(const Qt3DSFile *inNewPresentationFile = NULL);
+ void FireOnSavingPresentation(const QString &inNewPresentationFile);
void FireOnExportingAsset(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
void FireOnPresentationModifiedExternally();
@@ -147,13 +146,13 @@ public:
void AddNavigationListener(CNavigationListener *inListener);
void RemoveNavigationListener(CNavigationListener *inListener);
- void FireOnNavigate(const Q3DStudio::CString &inURL, bool inForceDisplay);
+ void FireOnNavigate(const QString &inURL, bool inForceDisplay);
void AddFileOpenListener(CFileOpenListener *inListener);
void RemoveFileOpenListener(CFileOpenListener *inListener);
- void FireOnOpenDocument(const Qt3DSFile &inFile, bool inSucceeded);
- void FireOnSaveDocument(const Qt3DSFile &inFile, bool inSucceeded, bool inSaveCopy);
- void FireOnDocumentPathChanged(const Qt3DSFile &inNewPath);
+ void FireOnOpenDocument(const QString &inFile, bool inSucceeded);
+ void FireOnSaveDocument(const QString &inFile, bool inSucceeded, bool inSaveCopy);
+ void FireOnDocumentPathChanged(const QString &inNewPath);
// Toolbar changes
void AddToolbarChangeListener(CToolbarChangeListener *inListener);
@@ -163,7 +162,7 @@ public:
// State Property changes
void AddSelectedNodePropChangeListener(CSelectedNodePropChangeListener *inListener);
void RemoveSelectedNodePropChangeListener(CSelectedNodePropChangeListener *inListener);
- void FireOnSelectedNodePropChange(const Q3DStudio::CString &inPropertyName);
+ void FireOnSelectedNodePropChange(const QString &inPropertyName);
void FireOnMouseDragged(bool inConstrainXAxis, bool inConstrainYAxis);
// Edit Camera changes
@@ -182,9 +181,8 @@ public:
// Cleanly display app status messages
void AddAppStatusListener(CAppStatusListener *inListener);
void RemoveAppStatusListener(CAppStatusListener *inListener);
- void FireOnDisplayAppStatus(Q3DStudio::CString &inStatusMsg);
- void FireOnProgressBegin(const Q3DStudio::CString &inActionText,
- const Q3DStudio::CString &inAdditionalText);
+ void FireOnDisplayAppStatus(const QString &inStatusMsg);
+ void FireOnProgressBegin(const QString &inActionText, const QString &inAdditionalText);
void FireOnProgressEnd();
// Failure notification
@@ -192,12 +190,11 @@ public:
void RemoveFailListener(CFailListener *inListener);
void FireOnAssetDeleteFail();
void FireOnPasteFail();
- void FireOnBuildConfigurationFileParseFail(const Q3DStudio::CString &inMessage);
+ void FireOnBuildConfigurationFileParseFail(const QString &inMessage);
void FireOnSaveFail(bool inKnownError);
- void FireOnProjectVariableFail(const Q3DStudio::CString &inMessage);
- void FireOnErrorFail(const Q3DStudio::CString &inText);
- void FireOnRefreshResourceFail(const Q3DStudio::CString &inResourceName,
- const Q3DStudio::CString &inDescription);
+ void FireOnErrorFail(const QString &inText);
+ void FireOnRefreshResourceFail(const QString &inResourceName,
+ const QString &inDescription);
void FireOnUndefinedDatainputsFail(
const QMultiMap<QString,
QPair<qt3dsdm::Qt3DSDMInstanceHandle,
diff --git a/src/Authoring/Client/Code/Core/Core/DispatchListeners.h b/src/Authoring/Client/Code/Core/Core/DispatchListeners.h
index fdc488c5..36f1d419 100644
--- a/src/Authoring/Client/Code/Core/Core/DispatchListeners.h
+++ b/src/Authoring/Client/Code/Core/Core/DispatchListeners.h
@@ -170,7 +170,7 @@ public:
/**
* The current presentation is being saved.
*/
- virtual void OnSavingPresentation(const Qt3DSFile *inNewPresentationFile)
+ virtual void OnSavingPresentation(const QString &inNewPresentationFile)
{
Q_UNUSED(inNewPresentationFile);
}
@@ -211,21 +211,21 @@ public:
class CNavigationListener
{
public:
- virtual void OnNavigate(const Q3DStudio::CString &inURL, bool inForceDisplay) = 0;
+ virtual void OnNavigate(const QString &inURL, bool inForceDisplay) = 0;
};
class CFileOpenListener
{
public:
- virtual void OnOpenDocument(const Qt3DSFile &inFilename, bool inSucceeded) = 0;
- virtual void OnSaveDocument(const Qt3DSFile &inFilename, bool inSucceeded, bool inSaveCopy) = 0;
- virtual void OnDocumentPathChanged(const Qt3DSFile &inNewPath) = 0;
+ virtual void OnOpenDocument(const QString &inFilename, bool inSucceeded) = 0;
+ virtual void OnSaveDocument(const QString &inFilename, bool inSucceeded, bool inSaveCopy) = 0;
+ virtual void OnDocumentPathChanged(const QString &inNewPath) = 0;
};
class CSelectedNodePropChangeListener
{
public:
- virtual void OnPropValueChanged(const Q3DStudio::CString &inPropertyName) = 0;
+ virtual void OnPropValueChanged(const QString &inPropertyName) = 0;
virtual void OnMouseDragged(bool inConstrainXAxis, bool inConstrainYAxis) = 0;
};
@@ -263,9 +263,9 @@ class CAppStatusListener
{
public:
virtual ~CAppStatusListener() {}
- virtual void OnDisplayAppStatus(Q3DStudio::CString &inStatusMsg) = 0;
- virtual void OnProgressBegin(const Q3DStudio::CString &inActionText,
- const Q3DStudio::CString &inAdditionalText) = 0;
+ virtual void OnDisplayAppStatus(const QString &inStatusMsg) = 0;
+ virtual void OnProgressBegin(const QString &inActionText,
+ const QString &inAdditionalText) = 0;
virtual void OnProgressEnd() = 0;
};
@@ -277,12 +277,11 @@ public:
virtual ~CFailListener() {}
virtual void OnAssetDeleteFail() = 0;
virtual void OnPasteFail() = 0;
- virtual void OnBuildconfigurationFileParseFail(const Q3DStudio::CString &inMessage) = 0;
+ virtual void OnBuildconfigurationFileParseFail(const QString &inMessage) = 0;
virtual void OnSaveFail(bool inKnownError) = 0;
- virtual void OnProjectVariableFail(const Q3DStudio::CString &inMessage) = 0;
- virtual void OnErrorFail(const Q3DStudio::CString &inText) = 0;
- virtual void OnRefreshResourceFail(const Q3DStudio::CString &inResourceName,
- const Q3DStudio::CString &inDescription) = 0;
+ virtual void OnErrorFail(const QString &inText) = 0;
+ virtual void OnRefreshResourceFail(const QString &inResourceName,
+ const QString &inDescription) = 0;
virtual void OnUndefinedDatainputsFail(
const QMultiMap<QString,
QPair<qt3dsdm::Qt3DSDMInstanceHandle,
@@ -319,7 +318,7 @@ class IDocumentBufferCacheListener
public:
virtual ~IDocumentBufferCacheListener() {}
// I can't get reference messages to work with the dispatch system.
- virtual void OnBufferInvalidated(Q3DStudio::CString inString) = 0;
+ virtual void OnBufferInvalidated(const QString &inString) = 0;
};
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.cpp b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
index d982647c..fbe8d2b8 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
@@ -398,11 +398,11 @@ void CDoc::SetInstancePropertyControlled(
// Set the controlledproperty string in the controlled element
// Use same transaction if "batch" is true
if (!batch) {
- Q3DStudio::ScopedDocumentEditor(*this, L"Set controlled", __FILE__, __LINE__)
+ Q3DStudio::ScopedDocumentEditor(*this, QObject::tr("Set controlled"), __FILE__, __LINE__)
->SetInstancePropertyValue(instance, ctrldElemPropHandle, controlledProperty);
} else {
if (!IsTransactionOpened())
- OpenTransaction(L"Set multiple controlled", __FILE__, __LINE__);
+ OpenTransaction(QObject::tr("Set multiple controlled"), __FILE__, __LINE__);
SetInstancePropertyValue(instance, L"controlledproperty", controlledProperty);
}
}
@@ -421,8 +421,8 @@ Q3DStudio::IDocumentReader &CDoc::GetDocumentReader()
return *m_SceneEditor;
}
-Q3DStudio::IDocumentEditor &CDoc::OpenTransaction(const Q3DStudio::CString &inCmdName,
- const char *inFile, int inLine)
+Q3DStudio::IDocumentEditor &CDoc::OpenTransaction(const QString &inCmdName, const char *inFile,
+ int inLine)
{
++m_TransactionDepth;
if (m_TransactionDepth == 1) {
@@ -432,7 +432,7 @@ Q3DStudio::IDocumentEditor &CDoc::OpenTransaction(const Q3DStudio::CString &inCm
m_OpenTransaction->SetConsumer();
m_Core->SetCommandStackModifier(this);
qCInfo(qt3ds::TRACE_INFO) << inFile << "(" << inLine << "): Transaction opened: "
- << inCmdName.toQString();
+ << inCmdName;
m_OpenTransaction->m_File = inFile;
m_OpenTransaction->m_Line = inLine;
CCmdStack *theCommandStack = m_Core->GetCmdStack();
@@ -440,7 +440,7 @@ Q3DStudio::IDocumentEditor &CDoc::OpenTransaction(const Q3DStudio::CString &inCm
theCommandStack->EmptyRedoStack();
} else
qCInfo(qt3ds::TRACE_INFO) << inFile << "(" << inLine << "): Open Transaction: "
- << inCmdName.toQString();
+ << inCmdName;
if (!m_SceneEditor) {
m_SceneEditor = Q3DStudio::IInternalDocumentEditor::CreateEditor(*this);
@@ -448,7 +448,7 @@ Q3DStudio::IDocumentEditor &CDoc::OpenTransaction(const Q3DStudio::CString &inCm
return *m_SceneEditor;
}
-Q3DStudio::IDocumentEditor &CDoc::MaybeOpenTransaction(const Q3DStudio::CString &cmdName,
+Q3DStudio::IDocumentEditor &CDoc::MaybeOpenTransaction(const QString &cmdName,
const char *inFile, int inLine)
{
if (!m_OpenTransaction)
@@ -492,7 +492,7 @@ void CDoc::IKnowWhatIAmDoingForceCloseTransaction()
theTransaction->ReleaseConsumer(false);
if (theTransaction->HasTransactions()) {
SDocTransactionCommand *newCommand = new SDocTransactionCommand(
- theTransaction, theTransaction->GetName().toQString(), *m_Core->GetDispatch());
+ theTransaction, theTransaction->GetName(), *m_Core->GetDispatch());
// Execute the command synchronously. If you are getting crashes due to UI refreshes
// then
// you need to run your entire change system in a postmessage of some sort.
@@ -513,7 +513,6 @@ bool CDoc::PreUndo()
{
if (m_OpenTransaction && m_OpenTransaction->HasTransactions()) {
qCInfo(qt3ds::TRACE_INFO) << "PreUndo begin";
- const Q3DStudio::CString theCommandName(m_OpenTransaction->GetName());
// In this case we want the command to absolutely immediately commit; we don't want it
// to wait until a further post message else the previous command is the one that will get
// undone.
@@ -534,7 +533,7 @@ bool CDoc::IsModified()
bool CDoc::IsValid() const
{
- return !m_DocumentPath.GetPath().IsEmpty();
+ return !m_DocumentPath.isEmpty();
}
//=============================================================================
/**
@@ -847,7 +846,7 @@ void CDoc::CutObject(qt3dsdm::TInstanceHandleList inInstances)
if (!theListOfTargets.IsEmpty()) {
if (m_DeletingReferencedObjectHandler)
- m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets);
+ m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets.toQString());
// theContinueCutFlag = false;
}
}
@@ -944,8 +943,10 @@ void CDoc::DeleteObject(const qt3dsdm::TInstanceHandleList &inInstances)
GetActionDependencies(inInstances[idx], theListOfTargets);
if (!theListOfTargets.IsEmpty()) {
- if (m_DeletingReferencedObjectHandler)
- m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets);
+ if (m_DeletingReferencedObjectHandler) {
+ m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets
+ .toQString());
+ }
}
deletableInstances.push_back(inInstances[idx]);
@@ -1440,7 +1441,8 @@ void CDoc::TruncateTimebar(bool inSetStart, bool inAffectsChildren)
qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance = GetSelectedInstance();
// Cannot change the time bars for a material
if (theSelectedInstance.Valid())
- Q3DStudio::ScopedDocumentEditor(*this, L"Truncate Time Range", __FILE__, __LINE__)
+ Q3DStudio::ScopedDocumentEditor(*this, QObject::tr("Truncate Time Range"),
+ __FILE__, __LINE__)
->TruncateTimeRange(theSelectedInstance, inSetStart, GetCurrentViewTime());
}
@@ -1522,23 +1524,22 @@ Q3DStudio::IDirectoryWatchingSystem *CDoc::GetDirectoryWatchingSystem()
return m_DirectoryWatchingSystem ? m_DirectoryWatchingSystem.get() : NULL;
}
-bool CDoc::SetDocumentPath(const Qt3DSFile &inDocumentPath)
+bool CDoc::SetDocumentPath(const QString &inDocumentPath)
{
- Q3DStudio::CString theDocPath = inDocumentPath.GetName();
// We always need to have a document path.
- if (theDocPath.Length() == 0) {
+ if (inDocumentPath.isEmpty()) {
ASSERT(false); // User should have specified which file.
m_DocumentPath = CreateUntitledDocument();
} else {
m_DocumentPath = inDocumentPath;
- if (!m_DocumentPath.Exists()) {
- // If the file doesn't exist, create it.
- Q3DStudio::CFilePath(m_DocumentPath.GetPath()).Touch();
- }
+ QFile f(m_DocumentPath);
+ if (!f.exists()) // If the file doesn't exist, create it.
+ f.open(QIODevice::ReadWrite);
}
// Document path should always be absolute path and it should exist
- if (Qt3DSFile::IsPathRelative(m_DocumentPath.GetPath()) || !m_DocumentPath.Exists())
+ QFileInfo info(m_DocumentPath);
+ if (info.isRelative() || !info.exists())
return false;
m_Core->GetDispatch()->FireOnDocumentPathChanged(m_DocumentPath);
@@ -1549,21 +1550,20 @@ bool CDoc::SetDocumentPath(const Qt3DSFile &inDocumentPath)
/**
* Create Untitled document in user directory
*/
-Qt3DSFile CDoc::CreateUntitledDocument() const
+QString CDoc::CreateUntitledDocument() const
{
- Q3DStudio::CFilePath theAppDirectory = Q3DStudio::CFilePath::GetUserApplicationDirectory();
- Q3DStudio::CFilePath theDirectory = Q3DStudio::CFilePath::CombineBaseAndRelative(
- theAppDirectory, Q3DStudio::CFilePath(L"Qt3DSComposer/Untitled"));
- theDirectory.CreateDir(true);
- Q3DStudio::CFilePath theFilePath = Q3DStudio::CFilePath::CombineBaseAndRelative(
- theDirectory, Q3DStudio::CFilePath(L"Untitled.uip"));
- // Keep jokers from screwing with our system.
- if (theFilePath.IsDirectory())
- theFilePath.DeleteThisDirectory(true);
+ QString dirPath = QDir::cleanPath(Q3DStudio::CFilePath::GetUserApplicationDirectory()
+ + QStringLiteral("/Qt3DSComposer/Untitled"));
+ QDir dir(dirPath);
+ dir.mkpath(QStringLiteral("."));
+ QString filePath = dirPath + QStringLiteral("/Untitled.uip");
- if (!theFilePath.IsFile())
- theFilePath.Touch();
- return Qt3DSFile(theFilePath);
+ // create the file if doesnt exist
+ if (!QFileInfo(filePath).exists()) {
+ QFile f(filePath);
+ f.open(QIODevice::ReadWrite);
+ }
+ return filePath;
}
void CDoc::SetImportFailedHandler(std::shared_ptr<Q3DStudio::IImportFailedHandler> inHandler)
@@ -1592,7 +1592,8 @@ std::shared_ptr<Q3DStudio::IMoveRenameHandler> CDoc::getMoveRenameHandler()
return m_moveRenameHandler;
}
-Qt3DSFile CDoc::GetDocumentPath() const
+// absolute document path
+QString CDoc::GetDocumentPath() const
{
return m_DocumentPath;
}
@@ -1603,7 +1604,7 @@ Qt3DSFile CDoc::GetDocumentPath() const
QString CDoc::getRelativePath() const
{
return QDir(GetCore()->getProjectFile().getProjectPath())
- .relativeFilePath(m_DocumentPath.GetPath().toQString());
+ .relativeFilePath(m_DocumentPath);
}
void CDoc::setPresentationId(const QString &id)
@@ -1618,7 +1619,7 @@ QString CDoc::getPresentationId() const
Q3DStudio::CString CDoc::GetDocumentDirectory() const
{
- Q3DStudio::CFilePath thePath(m_DocumentPath.GetAbsolutePath());
+ Q3DStudio::CFilePath thePath(m_DocumentPath);
return thePath.GetDirectory();
}
@@ -1649,8 +1650,9 @@ Q3DStudio::CString CDoc::GetRelativePathToDoc(const Q3DStudio::CFilePath &inPath
Q3DStudio::CString CDoc::GetResolvedPathToDoc(const Q3DStudio::CFilePath &inPath)
{
// If it is a relative path, resolve it.
- if (inPath.IsAbsolute() == false) {
- ASSERT(m_DocumentPath.Exists()); // Sanity check that document path has been set properly.
+ if (!inPath.IsAbsolute()) {
+ // Sanity check that document path has been set properly.
+ ASSERT(QFileInfo(m_DocumentPath).exists());
return Q3DStudio::CFilePath::CombineBaseAndRelative(GetDocumentDirectory(), inPath);
}
@@ -1701,12 +1703,12 @@ void CDoc::CloseDocument()
/**
* Called when the core opens a UIP file.
*/
-void CDoc::LoadDocument(const Qt3DSFile &inDocument)
+void CDoc::LoadDocument(const QString &inDocument)
{
ResetData();
- CFileInputStream theFileStream(inDocument.GetAbsolutePosixPath());
- CBufferedInputStream theBufferedStream(&theFileStream, inDocument.Length());
+ CFileInputStream theFileStream(inDocument);
+ CBufferedInputStream theBufferedStream(&theFileStream, QFileInfo(inDocument).size());
SetDocumentPath(inDocument); // SetDocumentPath before LoadPresentation because we need
// DocumentPath to load relative resources such as images
LoadPresentationFile(&theBufferedStream);
@@ -1716,9 +1718,9 @@ void CDoc::LoadDocument(const Qt3DSFile &inDocument)
/**
* Save Document
*/
-void CDoc::SaveDocument(const Qt3DSFile &inDocument)
+void CDoc::SaveDocument(const QString &inDocument)
{
- CFileOutputStream theFileStream(inDocument.GetAbsolutePosixPath());
+ CFileOutputStream theFileStream(inDocument);
// Exceptions here get propagated to the crash dialog.
CBufferedOutputStream theBufferStream(&theFileStream);
SavePresentationFile(&theBufferStream);
@@ -2887,7 +2889,7 @@ void CDoc::CheckActionDependencies(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
if (!theListOfTargets.IsEmpty()) {
if (m_DeletingReferencedObjectHandler)
- m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets);
+ m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets.toQString());
}
}
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.h b/src/Authoring/Client/Code/Core/Doc/Doc.h
index 8fe62f95..0ecd92dd 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.h
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.h
@@ -200,8 +200,8 @@ public:
// The system may be null in the case where we are running without a UI.
Q3DStudio::IDirectoryWatchingSystem *GetDirectoryWatchingSystem();
- bool SetDocumentPath(const Qt3DSFile &inFile);
- Qt3DSFile GetDocumentPath() const;
+ bool SetDocumentPath(const QString &inFile);
+ QString GetDocumentPath() const;
void setPresentationId(const QString &id);
QString getPresentationId() const;
Q3DStudio::CString GetDocumentDirectory() const;
@@ -209,11 +209,11 @@ public:
Q3DStudio::CString GetResolvedPathToDoc(const Q3DStudio::CFilePath &inPath);
QString getRelativePath() const;
- Qt3DSFile CreateUntitledDocument() const;
+ QString CreateUntitledDocument() const;
void CloseDocument();
- void LoadDocument(const Qt3DSFile &inDocument);
- void SaveDocument(const Qt3DSFile &inDocument);
+ void LoadDocument(const QString &inDocument);
+ void SaveDocument(const QString &inDocument);
void CreateNewDocument();
// In outMap, returns datainput names found from element control
// bindings but which are missing from (UIP) datainput list
@@ -343,10 +343,10 @@ public:
qt3dsdm::Qt3DSDMPropertyHandle>> *map) override;
Q3DStudio::IDocumentBufferCache &GetBufferCache() override;
Q3DStudio::IDocumentReader &GetDocumentReader() override;
- Q3DStudio::IDocumentEditor &OpenTransaction(const Q3DStudio::CString &inCmdName,
- const char *inFile, int inLine) override;
- Q3DStudio::IDocumentEditor &MaybeOpenTransaction(const Q3DStudio::CString &cmdName,
- const char *inFile, int inLine) override;
+ Q3DStudio::IDocumentEditor &OpenTransaction(const QString &inCmdName, const char *inFile,
+ int inLine) override;
+ Q3DStudio::IDocumentEditor &MaybeOpenTransaction(const QString &cmdName, const char *inFile,
+ int inLine) override;
bool IsTransactionOpened() const override;
void RollbackTransaction() override;
void CloseTransaction() override;
@@ -487,7 +487,7 @@ protected:
CCore *m_Core;
bool m_IsModified;
bool m_IsTemporary;
- Qt3DSFile m_DocumentPath;
+ QString m_DocumentPath;
CDataManager *m_DataManager; ///< Manager for handling data properties.
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp
index 2835de25..056d0366 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp
@@ -131,7 +131,7 @@ struct SDocBufferCache : public IDocumentBufferCache
if (entry != m_Buffers.end()) {
const_cast<SModelBufferOrImage &>(entry->second).Release();
m_Buffers.erase(entry);
- m_Doc.GetCore()->GetDispatch()->FireDocumentBufferCacheInvalidated(inPath.toCString());
+ m_Doc.GetCore()->GetDispatch()->FireDocumentBufferCacheInvalidated(inPath.toQString());
}
}
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
index 5abf7c75..1e545939 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
@@ -1481,8 +1481,7 @@ public:
TDataStrPtr newValue(get<TDataStrPtr>(value));
- CFilePath docPath =
- CFilePath(m_Doc.GetDocumentPath().GetAbsolutePath());
+ CFilePath docPath(m_Doc.GetDocumentPath());
CFilePath docDir(docPath.GetDirectory());
STranslationLog log;
CFilePath theFullPathToDocument(
@@ -2004,8 +2003,7 @@ public:
}
}
file.write("\t<Property name=\"presentation\">");
- file.write(m_Doc.GetDocumentPath().GetAbsolutePath()
- .toQString().toUtf8().constData());
+ file.write(m_Doc.GetDocumentPath().toUtf8().constData());
file.write("</Property>\n");
const QFileInfo fileInfo(file);
file.write("\t<Property name=\"path\">");
@@ -2998,8 +2996,10 @@ public:
if (!m_Bridge.CheckNameUnique(theParent, theInstance, currName)) {
CString newName = m_Bridge.GetUniqueChildName(theParent, theInstance,
currName);
- if (notifyRename)
- m_Doc.getMoveRenameHandler()->displayMessageBox(currName, newName);
+ if (notifyRename) {
+ m_Doc.getMoveRenameHandler()->displayMessageBox(currName.toQString(),
+ newName.toQString());
+ }
SetName(theInstance, newName);
}
}
@@ -3219,8 +3219,10 @@ public:
if (!m_Bridge.CheckNameUnique(targetComponent, instance, currName)) {
CString newName = m_Bridge.GetUniqueChildName(
targetComponent, instance, currName);
- if (notifyRename)
- m_Doc.getMoveRenameHandler()->displayMessageBox(currName, newName);
+ if (notifyRename) {
+ m_Doc.getMoveRenameHandler()->displayMessageBox(currName.toQString(),
+ newName.toQString());
+ }
SetName(instance, newName);
}
}
@@ -3548,8 +3550,7 @@ public:
CDispatch &theDispatch(*m_Doc.GetCore()->GetDispatch());
CFilePath theDestFile(importToComposer->GetDestImportFile());
try {
- theDispatch.FireOnProgressBegin(Q3DStudio::CString::fromQString(
- QObject::tr("Importing ")), importSrc);
+ theDispatch.FireOnProgressBegin(QObject::tr("Importing "), importSrc.toQString());
SImportResult result = inImportFunction(*importToComposer, theDestFile);
bool forceError = importToComposer->HasError();
if (!forceError)
@@ -3602,8 +3603,7 @@ public:
return 0;
CFilePath theRelativeDAE = m_Doc.GetRelativePathToDoc(importSrc);
- CFilePath docPath =
- CFilePath(m_Doc.GetDocumentPath().GetAbsolutePath());
+ CFilePath docPath(m_Doc.GetDocumentPath());
CFilePath docDir(docPath.GetDirectory());
std::shared_ptr<IImportFailedHandler> theHandler(m_Doc.GetImportFailedHandler());
if (docPath.size() == 0) {
@@ -3651,8 +3651,7 @@ public:
const CPt &inPosition = CPt(), long inStartTime = -1) override
{
ScopedBoolean __ignoredDirs(m_IgnoreDirChange);
- CFilePath docPath =
- CFilePath(m_Doc.GetDocumentPath().GetAbsolutePath());
+ CFilePath docPath(m_Doc.GetDocumentPath());
CFilePath docDir(docPath.GetDirectory());
STranslationLog log;
return DoImport(inFullPathToDocument, inFullPathToDocument, inParent, 0, inSlide, docDir,
@@ -4543,8 +4542,7 @@ public:
{
CDispatch &theDispatch(*m_Doc.GetCore()->GetDispatch());
theDispatch.FireOnProgressBegin(
- Q3DStudio::CString::fromQString(QObject::tr("Refreshing Import ")),
- inOldFile.toCString());
+ QObject::tr("Refreshing Import "), inOldFile.toQString());
ScopedBoolean __ignoredDirs(m_IgnoreDirChange);
try {
m_SourcePathInstanceMap.clear();
@@ -4559,8 +4557,7 @@ public:
{
CDispatch &theDispatch(*m_Doc.GetCore()->GetDispatch());
theDispatch.FireOnProgressBegin(
- Q3DStudio::CString::fromQString(QObject::tr("Old UIP version")),
- Q3DStudio::CString::fromQString(QObject::tr("Cleaning up meshes")));
+ QObject::tr("Old UIP version"), QObject::tr("Cleaning up meshes"));
ScopedBoolean __ignoredDirs(m_IgnoreDirChange);
bool cleanedSome = false;
try {
@@ -4972,7 +4969,7 @@ public:
bool requestRender = false;
if (inList.size() == 1
- && m_Doc.GetDocumentPath().GetName() == inList[0].m_File.GetFileName()
+ && m_Doc.GetDocumentPath().endsWith(inList[0].m_File.GetFileName().toQString())
&& inList[0].m_ModificationType == FileModificationType::Modified) {
if (!m_Doc.GetCore()->HasJustSaved()) {
CDispatch &theDispatch(*m_Doc.GetCore()->GetDispatch());
@@ -4984,7 +4981,7 @@ public:
#define ENSURE_PROGRESS \
if (!hasProgressFired) { \
- theDispatch.FireOnProgressBegin(Q3DStudio::CString::fromQString(QObject::tr("Updating project")), L""); \
+ theDispatch.FireOnProgressBegin(QObject::tr("Updating project"), {}); \
hasProgressFired = true; \
}
@@ -5337,7 +5334,7 @@ IDocumentEditor::ParseCustomMaterialFile(const Q3DStudio::CFilePath &inFullPathT
return theReaderPtr;
}
-ScopedDocumentEditor::ScopedDocumentEditor(IDoc &inDoc, const Q3DStudio::CString &inCommandName,
+ScopedDocumentEditor::ScopedDocumentEditor(IDoc &inDoc, const QString &inCommandName,
const char *inFile, int inLine)
: m_Editor(inDoc.OpenTransaction(inCommandName, inFile, inLine))
{
@@ -5352,7 +5349,7 @@ CUpdateableDocumentEditor::~CUpdateableDocumentEditor()
}
}
-IDocumentEditor &CUpdateableDocumentEditor::EnsureEditor(const wchar_t *inCommandName,
+IDocumentEditor &CUpdateableDocumentEditor::EnsureEditor(const QString &inCommandName,
const char *inFile, int inLine)
{
if (!HasEditor()) {
diff --git a/src/Authoring/Client/Code/Core/Doc/Exceptions.h b/src/Authoring/Client/Code/Core/Doc/Exceptions.h
index 11d68647..5d4b5832 100644
--- a/src/Authoring/Client/Code/Core/Doc/Exceptions.h
+++ b/src/Authoring/Client/Code/Core/Doc/Exceptions.h
@@ -33,24 +33,25 @@
#pragma once
#include "StudioException.h"
-#include "Qt3DSString.h"
+#include <QtCore/qstring.h>
+#include <QtCore/qobject.h>
class CGeneralException : public CStudioException
{
public:
- CGeneralException(const Q3DStudio::CString &inDescription)
+ CGeneralException(const QString &inDescription)
: m_Description(inDescription)
{
}
virtual ~CGeneralException() {}
- const wchar_t *GetDescription() const override
+ QString GetDescription() const override
{
- return static_cast<const wchar_t *>(m_Description);
+ return m_Description;
}
protected:
- Q3DStudio::CString m_Description;
+ QString m_Description;
};
class CNoClientException : public CStudioException
@@ -58,9 +59,9 @@ class CNoClientException : public CStudioException
public:
CNoClientException() {}
virtual ~CNoClientException() {}
- const wchar_t *GetDescription() const override
+ QString GetDescription() const override
{
- return Q3DStudio::CString(_LSTR("Client is not installed"));
+ return QObject::tr("Client is not installed");
}
};
@@ -69,9 +70,9 @@ class CClientCreationException : public CStudioException
public:
CClientCreationException() {}
virtual ~CClientCreationException() {}
- const wchar_t *GetDescription() const override
+ QString GetDescription() const override
{
- return Q3DStudio::CString(_LSTR("Unable to create Client"));
+ return QObject::tr("Unable to create Client");
}
};
@@ -80,9 +81,9 @@ class CInvalidFileFormatException : public CStudioException
public:
CInvalidFileFormatException() {}
virtual ~CInvalidFileFormatException() {}
- const wchar_t *GetDescription() const override
+ QString GetDescription() const override
{
- return Q3DStudio::CString(_LSTR("Invalid file format"));
+ return QObject::tr("Invalid file format");
}
};
@@ -91,9 +92,9 @@ class CUnsupportedFileFormatException : public CStudioException
public:
CUnsupportedFileFormatException() {}
virtual ~CUnsupportedFileFormatException() {}
- const wchar_t *GetDescription() const override
+ QString GetDescription() const override
{
- return Q3DStudio::CString(_LSTR("Unsupported file format"));
+ return QObject::tr("Unsupported file format");
}
};
@@ -102,9 +103,9 @@ class ProjectFileNotFoundException : public CStudioException
public:
ProjectFileNotFoundException() {}
virtual ~ProjectFileNotFoundException() {}
- const wchar_t *GetDescription() const override
+ QString GetDescription() const override
{
- return Q3DStudio::CString(_LSTR("Project file was not found"));
+ return QObject::tr("Project file was not found");
}
};
@@ -113,7 +114,7 @@ class CENotImplException : public CStudioException
public:
CENotImplException() {}
virtual ~CENotImplException() {}
- const wchar_t *GetDescription() const override { return Q3DStudio::CString(_LSTR("ENOTIMPL")); }
+ QString GetDescription() const override { return QObject::tr("ENOTIMPL"); }
};
class CInvalidArgumentsException : public CStudioException
@@ -121,9 +122,9 @@ class CInvalidArgumentsException : public CStudioException
public:
CInvalidArgumentsException() {}
virtual ~CInvalidArgumentsException() {}
- const wchar_t *GetDescription() const override
+ QString GetDescription() const override
{
- return Q3DStudio::CString(_LSTR("Invalid Argument"));
+ return QObject::tr("Invalid Argument");
}
};
@@ -132,9 +133,9 @@ class CNullPointerException : public CStudioException
public:
CNullPointerException() {}
virtual ~CNullPointerException() {}
- const wchar_t *GetDescription() const override
+ QString GetDescription() const override
{
- return Q3DStudio::CString(_LSTR("Null Pointer Error"));
+ return QObject::tr("Null Pointer Error");
}
};
@@ -143,9 +144,9 @@ class CUnexpectedResultException : public CStudioException
public:
CUnexpectedResultException() {}
virtual ~CUnexpectedResultException() {}
- const wchar_t *GetDescription() const override
+ QString GetDescription() const override
{
- return Q3DStudio::CString(_LSTR("Unexpected Result"));
+ return QObject::tr("Unexpected Result");
}
};
@@ -154,9 +155,9 @@ class CClientFailException : public CStudioException
public:
CClientFailException() {}
virtual ~CClientFailException() {}
- const wchar_t *GetDescription() const override
+ QString GetDescription() const override
{
- return Q3DStudio::CString(_LSTR("Client Failure"));
+ return QObject::tr("Client Failure");
}
};
@@ -164,17 +165,17 @@ public:
class CLoadReferencedFileException : public CGeneralException
{
public:
- CLoadReferencedFileException(const wchar_t *inFilePath, const Q3DStudio::CString &inDescription)
+ CLoadReferencedFileException(const QString &inFilePath, const QString &inDescription)
: CGeneralException(inDescription)
{
- if (inFilePath)
+ if (!inFilePath.isEmpty())
m_FilePath = inFilePath;
}
virtual ~CLoadReferencedFileException() {}
- const wchar_t *GetFilePath() const { return static_cast<const wchar_t *>(m_FilePath); }
+ QString GetFilePath() const { return m_FilePath; }
protected:
- Q3DStudio::CString m_FilePath;
+ QString m_FilePath;
};
#endif // INCLUDED_EXCEPTIONS_H
diff --git a/src/Authoring/Client/Code/Core/Doc/IDoc.h b/src/Authoring/Client/Code/Core/Doc/IDoc.h
index 87ae054a..609b91f9 100644
--- a/src/Authoring/Client/Code/Core/Doc/IDoc.h
+++ b/src/Authoring/Client/Code/Core/Doc/IDoc.h
@@ -125,12 +125,12 @@ public:
// then close the transaction and a command will be generated which will
// automatically do most of the work of doing/undoing changes
// to the data model (and the graphs, and the selection state).
- virtual Q3DStudio::IDocumentEditor &OpenTransaction(const Q3DStudio::CString &cmdName,
+ virtual Q3DStudio::IDocumentEditor &OpenTransaction(const QString &cmdName,
const char *inFile, int inLine) = 0;
// Get the document editor if a transaction has already been opened.
// Else open a new transaction.
- virtual Q3DStudio::IDocumentEditor &MaybeOpenTransaction(const Q3DStudio::CString &cmdName,
+ virtual Q3DStudio::IDocumentEditor &MaybeOpenTransaction(const QString &cmdName,
const char *inFile, int inLine) = 0;
virtual bool IsTransactionOpened() const = 0;
// Undo whatever has been done and clear the transaction's
diff --git a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h
index 006db391..0c2cb713 100644
--- a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h
+++ b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h
@@ -90,7 +90,7 @@ protected:
virtual ~IDeletingReferencedObjectHandler() {}
public:
- virtual void DisplayMessageBox(const Q3DStudio::CString &inDescription) = 0;
+ virtual void DisplayMessageBox(const QString &inDescription) = 0;
};
class IMoveRenameHandler
@@ -99,8 +99,7 @@ protected:
virtual ~IMoveRenameHandler() {}
public:
- virtual void displayMessageBox(const Q3DStudio::CString &origName,
- const Q3DStudio::CString &newName) = 0;
+ virtual void displayMessageBox(const QString &origName, const QString &newName) = 0;
};
class IDocumentEditor : public IDocumentReader
@@ -491,13 +490,13 @@ public:
struct ScopedDocumentEditor
{
IDocumentEditor &m_Editor;
- ScopedDocumentEditor(IDoc &inDoc, const Q3DStudio::CString &inCommandName, const char *inFile,
+ ScopedDocumentEditor(IDoc &inDoc, const QString &inCommandName, const char *inFile,
int inLine);
~ScopedDocumentEditor() { m_Editor.Release(); }
IDocumentEditor *operator->() { return &m_Editor; }
};
-#define SCOPED_DOCUMENT_EDITOR(doc, cmdname) ScopedDocumentEditor(doc, Q3DStudio::CString::fromQString(cmdname), __FILE__, __LINE__)
+#define SCOPED_DOCUMENT_EDITOR(doc, cmdname) ScopedDocumentEditor(doc, cmdname, __FILE__, __LINE__)
class CUpdateableDocumentEditor
{
@@ -517,7 +516,7 @@ public:
~CUpdateableDocumentEditor();
IDoc &GetEditorDoc() { return m_EditorIDocDoc; }
bool HasEditor() const;
- IDocumentEditor &EnsureEditor(const wchar_t *inCommandName, const char *inFile, int inLine);
+ IDocumentEditor &EnsureEditor(const QString &inCommandName, const char *inFile, int inLine);
void FireImmediateRefresh(qt3dsdm::Qt3DSDMInstanceHandle *inInstances, long inInstanceCount);
void FireImmediateRefresh(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
{
diff --git a/src/Authoring/Client/Code/Core/Doc/Qt3DSDMStudioSystem.cpp b/src/Authoring/Client/Code/Core/Doc/Qt3DSDMStudioSystem.cpp
index 644675c4..54e925f0 100644
--- a/src/Authoring/Client/Code/Core/Doc/Qt3DSDMStudioSystem.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/Qt3DSDMStudioSystem.cpp
@@ -49,15 +49,6 @@
using namespace std;
namespace qt3dsdm {
-inline std::wstring GetFullPath(Q3DStudio::CString inSource)
-{
-#ifdef Q_OS_MACOS
- if (inSource.Left(4) == "res/" || inSource.Left(4) == "res\\")
- inSource = inSource.Mid(4);
-#endif
- Qt3DSFile theSourcePath(Qt3DSFile::GetApplicationDirectory().GetAbsolutePath() + inSource);
- return std::wstring(theSourcePath.GetAbsolutePath());
-}
CStudioSystem::CStudioSystem(CDoc *inDoc)
: m_Doc(inDoc)
diff --git a/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h b/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h
index 4d1c67a0..71f85d64 100644
--- a/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h
+++ b/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h
@@ -43,7 +43,6 @@
// Forwards
//==============================================================================
class CCore;
-class CStudioProjectVariables;
class CStudioProjectSettings
{
diff --git a/src/Authoring/Client/Code/Core/Utility/BuildConfigParser.cpp b/src/Authoring/Client/Code/Core/Utility/BuildConfigParser.cpp
index 395b7f3f..7330f180 100644
--- a/src/Authoring/Client/Code/Core/Utility/BuildConfigParser.cpp
+++ b/src/Authoring/Client/Code/Core/Utility/BuildConfigParser.cpp
@@ -27,15 +27,11 @@
**
****************************************************************************/
-#include "Qt3DSCommonPrecompile.h"
#include "BuildConfigParser.h"
-#include "Qt3DSFileTools.h"
+#include <QtCore/qdiriterator.h>
namespace Q3DStudio {
-//==============================================================================
-// Constants
-//==============================================================================
const auto STR_TAG_PROJECT = QStringLiteral("project");
const auto STR_TAG_INTEGRATION = QStringLiteral("uic:integration");
const auto STR_TAG_PREVIEW = QStringLiteral("uic:preview");
@@ -47,10 +43,6 @@ const auto STR_PARAM_NAME = QStringLiteral("name");
const auto STR_PARAM_LABEL = QStringLiteral("label");
const auto STR_PARAM_HELP = QStringLiteral("help");
-//===============================================================================
-/**
- * Constructor
- */
CBuildConfigParser::CBuildConfigParser(CBuildConfigurations &inConfigurations)
: m_BuildConfigurations(inConfigurations)
, m_CurrentConfiguration(nullptr)
@@ -59,41 +51,34 @@ CBuildConfigParser::CBuildConfigParser(CBuildConfigurations &inConfigurations)
{
}
-//===============================================================================
-/**
- * Destructor
- */
CBuildConfigParser::~CBuildConfigParser()
{
}
-//===============================================================================
/**
* Load all the build configuration files in the directory.
* @param inDirectory the directory to look for all the configuration files
* @return true if all files parsed successfully, else false
*/
-bool CBuildConfigParser::LoadConfigurations(Qt3DSFile &inDirectory)
+bool CBuildConfigParser::LoadConfigurations(const QString &configDirPath)
{
m_ErrorMessage.clear();
- CFileIterator theFileIter = inDirectory.GetSubItems();
- while (!theFileIter.IsDone()) {
- Qt3DSFile theCurrentFile(theFileIter.GetCurrent());
- m_CurrentFile = theCurrentFile.GetAbsolutePath();
-
- if (theCurrentFile.GetExtension().CompareNoCase(L"build")) {
- m_CurrentConfiguration = new CBuildConfiguration(m_CurrentFile);
- QFile file(theCurrentFile.GetAbsolutePath().toQString());
+ QDirIterator di(configDirPath, QDir::NoDotAndDotDot | QDir::Files);
+ while (di.hasNext()) {
+ QFileInfo fi = di.next();
+ if (fi.suffix() == QLatin1String("build")) {
+ m_CurrentConfiguration = new CBuildConfiguration(fi.absoluteFilePath());
+ QFile file(fi.absoluteFilePath());
file.open(QFile::ReadOnly);
QXmlStreamReader reader(&file);
reader.setNamespaceProcessing(false);
while (!reader.atEnd()) {
QXmlStreamReader::TokenType token = reader.readNext();
if (token == QXmlStreamReader::StartElement)
- StartElement(reader.qualifiedName().toString(),reader.attributes());
+ StartElement(reader.qualifiedName().toString(), reader.attributes());
else if (token == QXmlStreamReader::Characters)
- HandleCharacterData(reader.text().toString(),0);
+ HandleCharacterData(reader.text().toString(), 0);
else if (token == QXmlStreamReader::EndElement)
EndElement(reader.qualifiedName().toString());
}
@@ -106,9 +91,9 @@ bool CBuildConfigParser::LoadConfigurations(Qt3DSFile &inDirectory)
}
file.close();
}
- ++theFileIter;
}
+
// Check the error message to see if parse successful or fail
if (m_ErrorMessage.isEmpty())
return true;
@@ -117,7 +102,6 @@ bool CBuildConfigParser::LoadConfigurations(Qt3DSFile &inDirectory)
}
-//===============================================================================
/**
* Callback when completed the parsing. Add the build configuration loaded to the
* stored list
@@ -130,7 +114,6 @@ void CBuildConfigParser::DocumentFinished()
}
}
-//===============================================================================
/**
* Callback when starting parsing an element
*/
@@ -151,7 +134,6 @@ void CBuildConfigParser::StartElement(const QString &inElementName,
}
}
-//===============================================================================
/**
* Callback after finished parsing an element
*/
@@ -164,17 +146,15 @@ void CBuildConfigParser::EndElement(const QString &inElementName)
m_TagStarted = false;
}
-//===============================================================================
/**
* Callback when handling the value of an element
*/
void CBuildConfigParser::HandleCharacterData(const QString &data, int /*inLen*/)
{
if (m_TagStarted)
- m_ElementData += Q3DStudio::CString::fromQString(data);
+ m_ElementData += data;
}
-//===============================================================================
/**
* Read in all the project related attributes
*/
@@ -186,7 +166,6 @@ void CBuildConfigParser::ParseProjectAttributes(const QXmlStreamAttributes &inAt
}
}
-//===============================================================================
/**
* Read in all the property related attributes
*/
@@ -203,7 +182,6 @@ void CBuildConfigParser::ParsePropertyAttributes(CBuildConfiguration::SConfigPro
}
}
-//===============================================================================
/**
* Read in all the property value related attributes
*/
@@ -212,23 +190,14 @@ void CBuildConfigParser::ParseValueAttributes(const QXmlStreamAttributes &inAttr
CBuildConfiguration::SConfigPropertyValue theValue;
for (const QXmlStreamAttribute &attrib : inAttributes) {
if (attrib.name() == STR_PARAM_NAME)
- theValue.SetName(attrib.value().toUtf8().constData());
+ theValue.SetName(attrib.value().toString());
else if (attrib.name() == STR_PARAM_LABEL)
- theValue.SetLabel(attrib.value().toUtf8().constData());
+ theValue.SetLabel(attrib.value().toString());
}
- using namespace Q3DStudio;
- Q3DStudio::CString thePropertyName = m_CurrentProperty->GetName();
- if (thePropertyName == L"MODE") {
- Q3DStudio::CString theValueName(theValue.GetName());
- if (theValueName == L"Debug") {
- CFilePath theFilePath;
- theFilePath.GetModuleFilePath();
- CFilePath theDir = theFilePath.GetDirectory().GetFileStem();
- // If this isn't a developer build.
- if (theDir.filePath() != "release" || theDir.filePath() != "debug")
- return;
- }
+ if (m_CurrentProperty->GetName() == QLatin1String("MODE")
+ && theValue.GetName() == QLatin1String("Debug")) {
+ return;
}
m_CurrentProperty->AddValue(theValue);
diff --git a/src/Authoring/Client/Code/Core/Utility/BuildConfigParser.h b/src/Authoring/Client/Code/Core/Utility/BuildConfigParser.h
index 47672b18..82f86bbc 100644
--- a/src/Authoring/Client/Code/Core/Utility/BuildConfigParser.h
+++ b/src/Authoring/Client/Code/Core/Utility/BuildConfigParser.h
@@ -57,39 +57,39 @@ public:
struct SConfigPropertyValue
{
protected:
- CString m_Name; ///< name of property value
- CString m_Label; ///< display name of property value
+ QString m_Name; ///< name of property value
+ QString m_Label; ///< display name of property value
public:
- const CString &GetName() { return m_Name; }
- void SetName(const CString &inName) { m_Name = inName; }
+ const QString &GetName() { return m_Name; }
+ void SetName(const QString &inName) { m_Name = inName; }
- const CString &GetLabel() { return m_Label; }
- void SetLabel(const CString &inLabel) { m_Label = inLabel; }
+ const QString &GetLabel() { return m_Label; }
+ void SetLabel(const QString &inLabel) { m_Label = inLabel; }
};
typedef std::vector<SConfigPropertyValue> TConfigPropertyValues; ///< List of property values
struct SConfigProperty
{
protected:
- CString m_Name; ///< name of property
- CString m_Label; ///< display name of property
- CString m_Help; ///< help string of property
+ QString m_Name; ///< name of property
+ QString m_Label; ///< display name of property
+ QString m_Help; ///< help string of property
TConfigPropertyValues m_AcceptableValues; ///< List of acceptable values
public:
- const CString &GetName() { return m_Name; }
- void SetName(const CString &inName) { m_Name = inName; }
+ const QString &GetName() { return m_Name; }
+ void SetName(const QString &inName) { m_Name = inName; }
- const CString &GetLabel() { return m_Label; }
- void SetLabel(const CString &inLabel) { m_Label = inLabel; }
+ const QString &GetLabel() { return m_Label; }
+ void SetLabel(const QString &inLabel) { m_Label = inLabel; }
- const CString &GetHelp() { return m_Help; }
- void SetHelp(const CString &inHelp) { m_Help = inHelp; }
+ const QString &GetHelp() { return m_Help; }
+ void SetHelp(const QString &inHelp) { m_Help = inHelp; }
void AddValue(SConfigPropertyValue &inValue) { m_AcceptableValues.push_back(inValue); }
- bool HasValue(const CString &inPropertyValue)
+ bool HasValue(const QString &inPropertyValue)
{
TConfigPropertyValues::iterator theIter;
for (theIter = m_AcceptableValues.begin(); theIter != m_AcceptableValues.end();
@@ -108,29 +108,29 @@ public:
typedef std::list<SConfigProperty> TConfigProperties; ///< List of properties
protected:
- CString m_Name; ///< Name of this configuration
- CString m_Path; ///< Absolute path of this configuration
- CString m_PreviewApp; ///< preview application syntax
- CString m_DeployApp; ///< delploy application syntax
+ QString m_Name; ///< Name of this configuration
+ QString m_Path; ///< Absolute path of this configuration
+ QString m_PreviewApp; ///< preview application syntax
+ QString m_DeployApp; ///< delploy application syntax
TConfigProperties m_ConfigProperties; ///< List of properties
public:
- CBuildConfiguration(const CString &inPath)
+ CBuildConfiguration(const QString &inPath)
: m_Path(inPath)
{
}
- const CString &GetPath() { return m_Path; }
- void SetPath(const CString &inPath) { m_Path = inPath; }
+ const QString &GetPath() { return m_Path; }
+ void SetPath(const QString &inPath) { m_Path = inPath; }
- const CString &GetName() { return m_Name; }
- void SetName(const CString &inName) { m_Name = inName; }
+ const QString &GetName() { return m_Name; }
+ void SetName(const QString &inName) { m_Name = inName; }
- const CString &GetPreviewApp() { return m_PreviewApp; }
- void SetPreviewApp(const CString &inPreviewApp) { m_PreviewApp = inPreviewApp; }
+ const QString &GetPreviewApp() { return m_PreviewApp; }
+ void SetPreviewApp(const QString &inPreviewApp) { m_PreviewApp = inPreviewApp; }
- const CString &GetDeployApp() { return m_DeployApp; }
- void SetDeployApp(const CString &inDeployApp) { m_DeployApp = inDeployApp; }
+ const QString &GetDeployApp() { return m_DeployApp; }
+ void SetDeployApp(const QString &inDeployApp) { m_DeployApp = inDeployApp; }
SConfigProperty &AddProperty(SConfigProperty &inProperty)
{
@@ -138,7 +138,7 @@ public:
return m_ConfigProperties.back();
}
- SConfigProperty *GetProperty(const CString &inPropertyName)
+ SConfigProperty *GetProperty(const QString &inPropertyName)
{
TConfigProperties::iterator theIter;
for (theIter = m_ConfigProperties.begin(); theIter != m_ConfigProperties.end(); ++theIter) {
@@ -159,7 +159,7 @@ public:
class CBuildConfigurations
{
public:
- typedef std::map<CString, CBuildConfiguration *>
+ typedef std::map<QString, CBuildConfiguration *>
TBuildConfigurations; ///< List of build configurations, sorted by name
public:
@@ -168,7 +168,7 @@ public:
m_BuildConfigurations.insert(std::make_pair(inConfig->GetName(), inConfig));
}
- CBuildConfiguration *GetConfiguration(const CString &inName)
+ CBuildConfiguration *GetConfiguration(const QString &inName)
{
TBuildConfigurations::iterator theFind = m_BuildConfigurations.find(inName);
if (theFind != m_BuildConfigurations.end())
@@ -207,8 +207,8 @@ public:
virtual ~CBuildConfigParser();
public:
- bool LoadConfigurations(Qt3DSFile &inDirectory);
- CString GetErrorMessage() { return CString::fromQString(m_ErrorMessage); }
+ bool LoadConfigurations(const QString &configDirPath);
+ QString GetErrorMessage() { return m_ErrorMessage; }
protected:
void ParseProjectAttributes(const QXmlStreamAttributes &inAttributes);
@@ -227,8 +227,8 @@ protected:
CBuildConfigurations &m_BuildConfigurations; ///< Working list of build configurations
CBuildConfiguration *m_CurrentConfiguration; ///< Current parsing configuration
CBuildConfiguration::SConfigProperty *m_CurrentProperty; ///< Current parsing property
- CString m_CurrentFile; ///< Current Parse file
- CString m_ElementData; ///< Element Data read in
+ QString m_CurrentFile; ///< Current Parse file
+ QString m_ElementData; ///< Element Data read in
QString m_ErrorMessage; ///< Consolidated error messages
bool m_TagStarted; ///< Hacked to signify tag started
};
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp
index 8a1f61ac..63abd7d8 100644
--- a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp
+++ b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp
@@ -88,8 +88,9 @@ static QSize s_browserPopupSize;
#define STRINGIFY(x) STRINGIFY2(x)
#define STRINGIFY2(x) #x
-// Static Consts
+// Statics
const ::CColor CStudioPreferences::EDITVIEW_DEFAULTBGCOLOR = ::CColor("#262829");
+std::unique_ptr<CPreferences> CStudioPreferences::m_preferences = nullptr;
CStudioPreferences::CStudioPreferences()
{
@@ -104,15 +105,20 @@ CStudioPreferences::~CStudioPreferences()
* Loads the default preferences from the registry. Must be called after the
* registry root has been set up, and before calling any of the Get functions.
*/
-void CStudioPreferences::LoadPreferences()
+void CStudioPreferences::LoadPreferences(const QString &filePath)
{
- s_BaseColor = CPreferences::GetUserPreferences("Preferences")
- .GetColorValue("BaseColor", ::CColor("#262829"));
+ if (!m_preferences)
+ m_preferences = std::unique_ptr<CPreferences>(new CPreferences);
- s_NormalColor = CPreferences::GetUserPreferences("Preferences")
- .GetColorValue("NormalColor", ::CColor("#ffffff"));
- s_MasterColor = CPreferences::GetUserPreferences("Preferences")
- .GetColorValue("MasterColor", ::CColor("#5caa15"));
+ m_preferences->SetPreferencesFile(filePath);
+
+ s_BaseColor = m_preferences->GetColorValue(QStringLiteral("BaseColor"), ::CColor("#262829"),
+ QStringLiteral("Preferences"));
+
+ s_NormalColor = m_preferences->GetColorValue(QStringLiteral("NormalColor"), ::CColor("#ffffff"),
+ QStringLiteral("Preferences"));
+ s_MasterColor = m_preferences->GetColorValue(QStringLiteral("MasterColor"), ::CColor("#5caa15"),
+ QStringLiteral("Preferences"));
s_DarkBaseColor = s_BaseColor;
s_DarkBaseColor.SetLuminance(s_DarkBaseColor.GetLuminance() - 0.10f);
@@ -176,7 +182,7 @@ void CStudioPreferences::LoadPreferences()
*/
bool CStudioPreferences::IsTimelineSnappingGridActive()
{
- return CPreferences::GetUserPreferences().GetValue("SnappingGridActive", true);
+ return m_preferences->GetValue(QStringLiteral("SnappingGridActive"), true);
}
//==============================================================================
@@ -186,7 +192,7 @@ bool CStudioPreferences::IsTimelineSnappingGridActive()
*/
void CStudioPreferences::SetTimelineSnappingGridActive(bool inActive)
{
- CPreferences::GetUserPreferences().SetValue("SnappingGridActive", inActive);
+ m_preferences->SetValue(QStringLiteral("SnappingGridActive"), inActive);
}
//==============================================================================
@@ -197,8 +203,8 @@ void CStudioPreferences::SetTimelineSnappingGridActive(bool inActive)
*/
ESnapGridResolution CStudioPreferences::GetTimelineSnappingGridResolution()
{
- return (ESnapGridResolution)CPreferences::GetUserPreferences().GetLongValue(
- "SnappingGridResolution", (long)SNAPGRID_SECONDS);
+ return (ESnapGridResolution)m_preferences->GetLongValue(
+ QStringLiteral("SnappingGridResolution"), (long)SNAPGRID_SECONDS);
}
//==============================================================================
@@ -209,7 +215,7 @@ ESnapGridResolution CStudioPreferences::GetTimelineSnappingGridResolution()
*/
void CStudioPreferences::SetTimelineSnappingGridResolution(ESnapGridResolution inResolution)
{
- CPreferences::GetUserPreferences().SetLongValue("SnappingGridResolution", (long)inResolution);
+ m_preferences->SetLongValue(QStringLiteral("SnappingGridResolution"), (long)inResolution);
}
/**
@@ -218,7 +224,7 @@ void CStudioPreferences::SetTimelineSnappingGridResolution(ESnapGridResolution i
*/
bool CStudioPreferences::GetEditViewFillMode()
{
- return CPreferences::GetUserPreferences().GetValue("EditViewFillMode", true);
+ return m_preferences->GetValue(QStringLiteral("EditViewFillMode"), true);
}
//==============================================================================
@@ -228,7 +234,7 @@ bool CStudioPreferences::GetEditViewFillMode()
*/
void CStudioPreferences::SetEditViewFillMode(bool inRenderAsSolid)
{
- CPreferences::GetUserPreferences().SetValue("EditViewFillMode", inRenderAsSolid);
+ m_preferences->SetValue(QStringLiteral("EditViewFillMode"), inRenderAsSolid);
}
//==============================================================================
@@ -238,8 +244,8 @@ void CStudioPreferences::SetEditViewFillMode(bool inRenderAsSolid)
*/
long CStudioPreferences::GetPreferredStartupView()
{
- return CPreferences::GetUserPreferences().GetLongValue("PreferredStartupView",
- PREFERREDSTARTUP_DEFAULTINDEX);
+ return m_preferences->GetLongValue(QStringLiteral("PreferredStartupView"),
+ PREFERREDSTARTUP_DEFAULTINDEX);
}
//==============================================================================
@@ -250,7 +256,7 @@ long CStudioPreferences::GetPreferredStartupView()
*/
void CStudioPreferences::SetPreferredStartupView(long inStartupView)
{
- CPreferences::GetUserPreferences().SetLongValue("PreferredStartupView", inStartupView);
+ m_preferences->SetLongValue(QStringLiteral("PreferredStartupView"), inStartupView);
}
//==============================================================================
@@ -261,7 +267,7 @@ void CStudioPreferences::SetPreferredStartupView(long inStartupView)
*/
bool CStudioPreferences::IsAutosetKeyframesOn()
{
- return CPreferences::GetUserPreferences().GetValue("AutosetKeyframes", true);
+ return m_preferences->GetValue(QStringLiteral("AutosetKeyframes"), true);
}
//==============================================================================
@@ -272,7 +278,7 @@ bool CStudioPreferences::IsAutosetKeyframesOn()
*/
void CStudioPreferences::SetAutosetKeyframesOn(bool inEnable)
{
- CPreferences::GetUserPreferences().SetValue("AutosetKeyframes", inEnable);
+ m_preferences->SetValue(QStringLiteral("AutosetKeyframes"), inEnable);
}
//==============================================================================
@@ -283,7 +289,7 @@ void CStudioPreferences::SetAutosetKeyframesOn(bool inEnable)
*/
bool CStudioPreferences::IsBoundingBoxesOn()
{
- return CPreferences::GetUserPreferences().GetValue("BoundingBoxes", true);
+ return m_preferences->GetValue(QStringLiteral("BoundingBoxes"), true);
}
//==============================================================================
@@ -294,7 +300,7 @@ bool CStudioPreferences::IsBoundingBoxesOn()
*/
void CStudioPreferences::SetBoundingBoxesOn(bool inEnable)
{
- CPreferences::GetUserPreferences().SetValue("BoundingBoxes", inEnable);
+ m_preferences->SetValue(QStringLiteral("BoundingBoxes"), inEnable);
}
//==============================================================================
@@ -305,7 +311,7 @@ void CStudioPreferences::SetBoundingBoxesOn(bool inEnable)
*/
bool CStudioPreferences::ShouldDisplayPivotPoint()
{
- return CPreferences::GetUserPreferences().GetValue("Display Pivot Point", true);
+ return m_preferences->GetValue(QStringLiteral("Display Pivot Point"), true);
}
//==============================================================================
@@ -316,7 +322,7 @@ bool CStudioPreferences::ShouldDisplayPivotPoint()
*/
void CStudioPreferences::SetDisplayPivotPoint(bool inEnable)
{
- return CPreferences::GetUserPreferences().SetValue("Display Pivot Point", inEnable);
+ return m_preferences->SetValue(QStringLiteral("Display Pivot Point"), inEnable);
}
//==============================================================================
@@ -327,7 +333,7 @@ void CStudioPreferences::SetDisplayPivotPoint(bool inEnable)
*/
bool CStudioPreferences::IsWireframeModeOn()
{
- return CPreferences::GetUserPreferences().GetValue("WireframeMode", true);
+ return m_preferences->GetValue(QStringLiteral("WireframeMode"), true);
}
//==============================================================================
@@ -338,7 +344,7 @@ bool CStudioPreferences::IsWireframeModeOn()
*/
void CStudioPreferences::SetWireframeModeOn(bool inEnable)
{
- CPreferences::GetUserPreferences().SetValue("WireframeMode", inEnable);
+ m_preferences->SetValue(QStringLiteral("WireframeMode"), inEnable);
}
//==============================================================================
@@ -349,7 +355,7 @@ void CStudioPreferences::SetWireframeModeOn(bool inEnable)
*/
bool CStudioPreferences::ShouldShowTooltips()
{
- return CPreferences::GetUserPreferences().GetValue("ShowTooltips", true);
+ return m_preferences->GetValue(QStringLiteral("ShowTooltips"), true);
}
//==============================================================================
@@ -360,7 +366,7 @@ bool CStudioPreferences::ShouldShowTooltips()
*/
void CStudioPreferences::SetShowTooltips(bool inShowTooltips)
{
- CPreferences::GetUserPreferences().SetValue("ShowTooltips", inShowTooltips);
+ m_preferences->SetValue(QStringLiteral("ShowTooltips"), inShowTooltips);
}
//==============================================================================
@@ -369,7 +375,8 @@ void CStudioPreferences::SetShowTooltips(bool inShowTooltips)
*/
long CStudioPreferences::GetTimelineSplitterLocation()
{
- return CPreferences::GetUserPreferences("Timeline").GetLongValue("TimelineSplitterLoc", 250);
+ return m_preferences->GetLongValue(QStringLiteral("TimelineSplitterLoc"), 250,
+ QStringLiteral("Timeline"));
}
//==============================================================================
@@ -379,7 +386,8 @@ long CStudioPreferences::GetTimelineSplitterLocation()
*/
void CStudioPreferences::SetTimelineSplitterLocation(long inLocation)
{
- CPreferences::GetUserPreferences("Timeline").SetLongValue("TimelineSplitterLoc", inLocation);
+ m_preferences->SetLongValue(QStringLiteral("TimelineSplitterLoc"), inLocation,
+ QStringLiteral("Timeline"));
}
//==============================================================================
@@ -391,7 +399,7 @@ void CStudioPreferences::SetTimelineSplitterLocation(long inLocation)
*/
bool CStudioPreferences::GetInterpolation()
{
- return CPreferences::GetUserPreferences().GetValue("InterpolationPreference", true);
+ return m_preferences->GetValue(QStringLiteral("InterpolationPreference"), true);
}
//==============================================================================
@@ -401,7 +409,7 @@ bool CStudioPreferences::GetInterpolation()
*/
void CStudioPreferences::SetInterpolation(bool inSmooth)
{
- CPreferences::GetUserPreferences().SetValue("InterpolationPreference", inSmooth);
+ m_preferences->SetValue(QStringLiteral("InterpolationPreference"), inSmooth);
}
//==============================================================================
@@ -411,7 +419,7 @@ void CStudioPreferences::SetInterpolation(bool inSmooth)
*/
long CStudioPreferences::GetSnapRange()
{
- return CPreferences::GetUserPreferences().GetLongValue("SnapRange", DEFAULT_SNAPRANGE);
+ return m_preferences->GetLongValue(QStringLiteral("SnapRange"), DEFAULT_SNAPRANGE);
}
//==============================================================================
@@ -421,7 +429,7 @@ long CStudioPreferences::GetSnapRange()
*/
void CStudioPreferences::SetSnapRange(long inSnapRange)
{
- CPreferences::GetUserPreferences().SetLongValue("SnapRange", inSnapRange);
+ m_preferences->SetLongValue(QStringLiteral("SnapRange"), inSnapRange);
}
//==============================================================================
@@ -432,8 +440,8 @@ void CStudioPreferences::SetSnapRange(long inSnapRange)
long CStudioPreferences::GetAutoSaveDelay()
{
// default delay is 10 minutes (600 seconds)
- return CPreferences::GetUserPreferences("AutoSave").GetLongValue("Delay",
- DEFAULT_AUTOSAVE_DELAY);
+ return m_preferences->GetLongValue(QStringLiteral("Delay"), DEFAULT_AUTOSAVE_DELAY,
+ QStringLiteral("AutoSave"));
}
//==============================================================================
@@ -443,7 +451,8 @@ long CStudioPreferences::GetAutoSaveDelay()
*/
void CStudioPreferences::SetAutoSaveDelay(long inAutoSaveDelay)
{
- CPreferences::GetUserPreferences("AutoSave").SetLongValue("Delay", inAutoSaveDelay);
+ m_preferences->SetLongValue(QStringLiteral("Delay"), inAutoSaveDelay,
+ QStringLiteral("AutoSave"));
}
//==============================================================================
@@ -455,7 +464,7 @@ void CStudioPreferences::SetAutoSaveDelay(long inAutoSaveDelay)
*/
bool CStudioPreferences::GetAutoSavePreference()
{
- return CPreferences::GetUserPreferences("AutoSave").GetValue("Preference", true);
+ return m_preferences->GetValue(QStringLiteral("Preference"), true, QStringLiteral("AutoSave"));
}
//==============================================================================
@@ -465,7 +474,7 @@ bool CStudioPreferences::GetAutoSavePreference()
*/
void CStudioPreferences::SetAutoSavePreference(bool inActive)
{
- CPreferences::GetUserPreferences("AutoSave").SetValue("Preference", inActive);
+ m_preferences->SetValue(QStringLiteral("Preference"), inActive, QStringLiteral("AutoSave"));
}
//==============================================================================
@@ -478,8 +487,7 @@ void CStudioPreferences::SetAutoSavePreference(bool inActive)
*/
long CStudioPreferences::GetDefaultObjectLifetime()
{
- return CPreferences::GetUserPreferences().GetLongValue("DefaultObjectLifetime",
- DEFAULT_LIFETIME);
+ return m_preferences->GetLongValue(QStringLiteral("DefaultObjectLifetime"), DEFAULT_LIFETIME);
}
//==============================================================================
@@ -492,7 +500,7 @@ long CStudioPreferences::GetDefaultObjectLifetime()
*/
void CStudioPreferences::SetDefaultObjectLifetime(long inLifetime)
{
- CPreferences::GetUserPreferences().SetLongValue("DefaultObjectLifetime", inLifetime);
+ m_preferences->SetLongValue(QStringLiteral("DefaultObjectLifetime"), inLifetime);
}
//==============================================================================
@@ -505,7 +513,7 @@ void CStudioPreferences::SetDefaultObjectLifetime(long inLifetime)
*/
bool CStudioPreferences::GetTimebarDisplayTime()
{
- return CPreferences::GetUserPreferences().GetValue("TimebarSetting", false);
+ return m_preferences->GetValue(QStringLiteral("TimebarSetting"), false);
}
//==============================================================================
@@ -518,7 +526,7 @@ bool CStudioPreferences::GetTimebarDisplayTime()
*/
void CStudioPreferences::SetTimebarDisplayTime(bool inDisplayTime)
{
- CPreferences::GetUserPreferences().SetValue("TimebarSetting", inDisplayTime);
+ m_preferences->SetValue(QStringLiteral("TimebarSetting"), inDisplayTime);
}
//==============================================================================
@@ -531,7 +539,7 @@ void CStudioPreferences::SetTimebarDisplayTime(bool inDisplayTime)
*/
bool CStudioPreferences::GetAdvancePropertyExpandedFlag()
{
- return CPreferences::GetUserPreferences().GetValue("AdvancePropertyFlag", false);
+ return m_preferences->GetValue(QStringLiteral("AdvancePropertyFlag"), false);
}
//==============================================================================
@@ -541,31 +549,30 @@ bool CStudioPreferences::GetAdvancePropertyExpandedFlag()
*/
void CStudioPreferences::SetAdvancePropertyExpandedFlag(bool inAdvancePropertyFlag)
{
- CPreferences::GetUserPreferences().SetValue("AdvancePropertyFlag", inAdvancePropertyFlag);
+ m_preferences->SetValue(QStringLiteral("AdvancePropertyFlag"), inAdvancePropertyFlag);
}
-Q3DStudio::CString CStudioPreferences::GetPreviewConfig()
+QString CStudioPreferences::GetPreviewConfig()
{
- return CPreferences::GetUserPreferences().GetStringValue("Preview.Config", "");
+ return m_preferences->GetStringValue(QStringLiteral("Preview.Config"));
}
-void CStudioPreferences::SetPreviewConfig(const Q3DStudio::CString &inValue)
+void CStudioPreferences::SetPreviewConfig(const QString &inValue)
{
- CPreferences::GetUserPreferences().SetStringValue("Preview.Config", inValue);
+ m_preferences->SetStringValue(QStringLiteral("Preview.Config"), inValue);
}
// Preview Properties at the registry are prepend with Preview.
-Q3DStudio::CString CStudioPreferences::GetPreviewProperty(const Q3DStudio::CString &inName)
+QString CStudioPreferences::GetPreviewProperty(const QString &inName)
{
- Q3DStudio::CString theName = "Preview." + inName;
- return CPreferences::GetUserPreferences().GetStringValue(theName, "");
+ QString theName = QStringLiteral("Preview.") + inName;
+ return m_preferences->GetStringValue(theName);
}
-void CStudioPreferences::SetPreviewProperty(const Q3DStudio::CString &inName,
- const Q3DStudio::CString &inValue)
+void CStudioPreferences::SetPreviewProperty(const QString &inName, const QString &inValue)
{
- Q3DStudio::CString theName = "Preview." + inName;
- CPreferences::GetUserPreferences().SetStringValue(theName, inValue);
+ QString theName = QStringLiteral("Preview.") + inName;
+ m_preferences->SetStringValue(theName, inValue);
}
//=============================================================================
@@ -576,7 +583,7 @@ void CStudioPreferences::SetPreviewProperty(const Q3DStudio::CString &inName,
*/
bool CStudioPreferences::GetDontShowGLVersionDialog()
{
- return CPreferences::GetUserPreferences().GetValue("DontShowGLVersionDialog", false);
+ return m_preferences->GetValue(QStringLiteral("DontShowGLVersionDialog"), false);
}
//=============================================================================
@@ -586,23 +593,43 @@ bool CStudioPreferences::GetDontShowGLVersionDialog()
*/
void CStudioPreferences::SetDontShowGLVersionDialog(bool inValue)
{
- CPreferences::GetUserPreferences().SetValue("DontShowGLVersionDialog", inValue);
+ m_preferences->SetValue(QStringLiteral("DontShowGLVersionDialog"), inValue);
}
CPt CStudioPreferences::GetDefaultClientSize()
{
CPt theSize;
- theSize.x = CPreferences::GetUserPreferences().GetLongValue("DefaultClientWidth",
- DEFAULT_CLIENT_WIDTH);
- theSize.y = CPreferences::GetUserPreferences().GetLongValue("DefaultClientHeight",
- DEFAULT_CLIENT_HEIGHT);
+ theSize.x = m_preferences->GetLongValue(QStringLiteral("DefaultClientWidth"),
+ DEFAULT_CLIENT_WIDTH);
+ theSize.y = m_preferences->GetLongValue(QStringLiteral("DefaultClientHeight"),
+ DEFAULT_CLIENT_HEIGHT);
return theSize;
}
void CStudioPreferences::SetDefaultClientSize(int width, int height)
{
- CPreferences::GetUserPreferences().SetLongValue("DefaultClientWidth", (long)width);
- CPreferences::GetUserPreferences().SetLongValue("DefaultClientHeight", (long)height);
+ m_preferences->SetLongValue(QStringLiteral("DefaultClientWidth"), (long)width);
+ m_preferences->SetLongValue(QStringLiteral("DefaultClientHeight"), (long)height);
+}
+
+int CStudioPreferences::getNumRecentItems()
+{
+ return m_preferences->GetLongValue(QStringLiteral("RecentValid"));
+}
+
+void CStudioPreferences::setNumRecentItems(int n)
+{
+ m_preferences->SetLongValue(QStringLiteral("RecentValid"), n);
+}
+
+QString CStudioPreferences::getRecentItem(int index)
+{
+ return m_preferences->GetStringValue(QStringLiteral("RecentItem") + QString::number(index));
+}
+
+void CStudioPreferences::setRecentItem(int index, const QString &path)
+{
+ m_preferences->SetStringValue(QStringLiteral("RecentItem") + QString::number(index), path);
}
//==============================================================================
@@ -612,7 +639,7 @@ void CStudioPreferences::SetDefaultClientSize(int width, int height)
*/
long CStudioPreferences::GetTimeAdvanceAmount()
{
- return CPreferences::GetUserPreferences().GetLongValue("TimeAdvance", DEFAULT_TIME_ADVANCE);
+ return m_preferences->GetLongValue(QStringLiteral("TimeAdvance"), DEFAULT_TIME_ADVANCE);
}
//==============================================================================
@@ -622,7 +649,7 @@ long CStudioPreferences::GetTimeAdvanceAmount()
*/
void CStudioPreferences::SetTimeAdvanceAmount(long inTime)
{
- CPreferences::GetUserPreferences().SetLongValue("TimeAdvance", inTime);
+ m_preferences->SetLongValue(QStringLiteral("TimeAdvance"), inTime);
}
//==============================================================================
@@ -632,8 +659,7 @@ void CStudioPreferences::SetTimeAdvanceAmount(long inTime)
*/
long CStudioPreferences::GetBigTimeAdvanceAmount()
{
- return CPreferences::GetUserPreferences().GetLongValue("BigTimeAdvance",
- DEFAULT_BIG_TIME_ADVANCE);
+ return m_preferences->GetLongValue(QStringLiteral("BigTimeAdvance"), DEFAULT_BIG_TIME_ADVANCE);
}
//==============================================================================
@@ -643,7 +669,7 @@ long CStudioPreferences::GetBigTimeAdvanceAmount()
*/
void CStudioPreferences::SetBigTimeAdvanceAmount(long inTime)
{
- CPreferences::GetUserPreferences().SetLongValue("BigTimeAdvance", inTime);
+ m_preferences->SetLongValue(QStringLiteral("BigTimeAdvance"), inTime);
}
/**
@@ -765,24 +791,22 @@ QString CStudioPreferences::GetFontFaceName()
float CStudioPreferences::getSelectorLineWidth()
{
- return CPreferences::GetUserPreferences().GetLongValue("SelectorLineWidth",
- DEFAULT_SELECTOR_WIDTH) / 10.0f;
+ return m_preferences->GetLongValue("SelectorLineWidth", DEFAULT_SELECTOR_WIDTH) / 10.0f;
}
void CStudioPreferences::setSelectorLineWidth(float width)
{
- CPreferences::GetUserPreferences().SetLongValue("SelectorLineWidth", int(width * 10.0f));
+ m_preferences->SetLongValue("SelectorLineWidth", int(width * 10.0f));
}
float CStudioPreferences::getSelectorLineLength()
{
- return float(CPreferences::GetUserPreferences().GetLongValue("SelectorLineLength",
- DEFAULT_SELECTOR_LENGTH));
+ return float(m_preferences->GetLongValue("SelectorLineLength", DEFAULT_SELECTOR_LENGTH));
}
void CStudioPreferences::setSelectorLineLength(float length)
{
- CPreferences::GetUserPreferences().SetLongValue("SelectorLineLength", int(length));
+ m_preferences->SetLongValue("SelectorLineLength", int(length));
}
void CStudioPreferences::setQmlContextProperties(QQmlContext *qml)
@@ -985,30 +1009,30 @@ QSize CStudioPreferences::browserPopupSize()
return s_browserPopupSize;
}
-Q3DStudio::CString CStudioPreferences::GetVersionString()
+QString CStudioPreferences::GetVersionString()
{
- Q3DStudio::CString theVersionNumber = STRINGIFY(STUDIO_VERSION);
- theVersionNumber.Replace(",", ".");
+ QString theVersionNumber = STRINGIFY(STUDIO_VERSION);
+ theVersionNumber.replace(QLatin1String(","), QLatin1String("."));
return theVersionNumber;
}
bool CStudioPreferences::showEditModePreview()
{
- return CPreferences::GetUserPreferences().GetValue("showEditModePreview", true);
+ return m_preferences->GetValue("showEditModePreview", true);
}
void CStudioPreferences::setShowEditModePreview(bool show)
{
- CPreferences::GetUserPreferences().SetValue("showEditModePreview", show);
+ m_preferences->SetValue("showEditModePreview", show);
}
bool CStudioPreferences::editModeLightingEnabled()
{
- return CPreferences::GetUserPreferences().GetValue("editModeLightingEnabled", true);
+ return m_preferences->GetValue("editModeLightingEnabled", true);
}
void CStudioPreferences::setEditModeLightingEnabled(bool enabled)
{
- CPreferences::GetUserPreferences().SetValue("editModeLightingEnabled", enabled);
+ m_preferences->SetValue("editModeLightingEnabled", enabled);
}
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h
index bd586629..09dfc6ce 100644
--- a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h
+++ b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h
@@ -36,7 +36,6 @@
#include <QtGui/qbrush.h>
#include "CoreConst.h"
-#include "Qt3DSFile.h"
#include "Preferences.h"
#include "Rct.h"
@@ -48,7 +47,7 @@ class CStudioPreferences
virtual ~CStudioPreferences();
public:
- static void LoadPreferences();
+ static void LoadPreferences(const QString &filePath);
static bool IsTimelineSnappingGridActive();
static void SetTimelineSnappingGridActive(bool inActive);
@@ -104,7 +103,7 @@ public:
static bool GetTimebarDisplayTime();
static void SetTimebarDisplayTime(bool inDisplayTime);
- static Q3DStudio::CString GetVersionString();
+ static QString GetVersionString();
static bool GetDontShowGLVersionDialog();
static void SetDontShowGLVersionDialog(bool inValue);
@@ -117,14 +116,19 @@ public:
static CPt GetDefaultClientSize();
static void SetDefaultClientSize(int width, int height);
+ static int getNumRecentItems();
+ static void setNumRecentItems(int n);
+
+ static QString getRecentItem(int index);
+ static void setRecentItem(int index, const QString &path);
+
static bool GetAdvancePropertyExpandedFlag();
static void SetAdvancePropertyExpandedFlag(bool inAdvancePropertyFlag);
- static Q3DStudio::CString GetPreviewConfig();
- static void SetPreviewConfig(const Q3DStudio::CString &inValue);
- static Q3DStudio::CString GetPreviewProperty(const Q3DStudio::CString &inName);
- static void SetPreviewProperty(const Q3DStudio::CString &inName,
- const Q3DStudio::CString &inValue);
+ static QString GetPreviewConfig();
+ static void SetPreviewConfig(const QString &inValue);
+ static QString GetPreviewProperty(const QString &inName);
+ static void SetPreviewProperty(const QString &inName, const QString &inValue);
static ::CColor GetNormalColor();
static ::CColor GetMasterColor();
@@ -206,5 +210,8 @@ public:
static const long DEFAULT_SELECTOR_WIDTH = 30;
static const long DEFAULT_SELECTOR_LENGTH = 50;
static const long DEFAULT_AUTOSAVE_DELAY = 600;
+
+private:
+ static std::unique_ptr<CPreferences> m_preferences;
};
#endif // INCLUDED_STUDIO_PREFERENCES_H
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioProjectVariables.cpp b/src/Authoring/Client/Code/Core/Utility/StudioProjectVariables.cpp
deleted file mode 100644
index e49d3b41..00000000
--- a/src/Authoring/Client/Code/Core/Utility/StudioProjectVariables.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2005 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSCommonPrecompile.h"
-#include "StudioProjectVariables.h"
-#include "Core.h"
-#include "Dispatch.h"
-
-/**
- * Constructor
- */
-//==============================================================================
-CStudioProjectVariables::CStudioProjectVariables(CCore *inCore)
- : m_Core(inCore)
-{
-}
-
-//==============================================================================
-/**
- * Destructor: Releases the object.
- */
-//==============================================================================
-CStudioProjectVariables::~CStudioProjectVariables()
-{
-}
-
-//==============================================================================
-/**
- * Cleanup all the existing environment variables. It's the responsibility of the
- * listen for the change event to remove themselves. Calling Clear will not remove them
- */
-//==============================================================================
-void CStudioProjectVariables::Clear()
-{
- m_VariablesMap.clear();
-}
-
-//==============================================================================
-/**
- * Forms all the environment into a CString. Each enviroment variable is seperated
- * by a carriage return and a line feed. This is the format expected by the Project
- * Settings UI
- */
-//==============================================================================
-Q3DStudio::CString CStudioProjectVariables::GetProjectVariables() const
-{
- // Formulate the string
- Q3DStudio::CString theString;
- TVariableMap::const_iterator theBegin = m_VariablesMap.begin();
- TVariableMap::const_iterator theEnd = m_VariablesMap.end();
- for (TVariableMap::const_iterator theIterator = theBegin; theIterator != theEnd;
- ++theIterator) {
- if (theIterator != theBegin)
- theString += "\r\n";
-
- theString += theIterator->first;
- theString += " = ";
- theString += theIterator->second;
- }
-
- return theString;
-}
-
-void CStudioProjectVariables::GetProjectVariables(std::list<Q3DStudio::CString> &ioVariables)
-{
- Q3DStudio::CString theString;
- TVariableMap::const_iterator theBegin = m_VariablesMap.begin();
- TVariableMap::const_iterator theEnd = m_VariablesMap.end();
- for (TVariableMap::const_iterator theIterator = theBegin; theIterator != theEnd;
- ++theIterator) {
- theString = theIterator->first;
- theString += " = ";
- theString += theIterator->second;
- ioVariables.push_back(theString);
- }
-}
-
-//==============================================================================
-/**
- * Reset all the enviroment variables with this new set. Each entry in the list
- * is one variable in the format {Variable} = Value.
- */
-//==============================================================================
-bool CStudioProjectVariables::SetProjectVariables(std::list<Q3DStudio::CString> &inVariables)
-{
- // copy the environment variables out
- TVariableMap theOrigMap = m_VariablesMap;
-
- // prepare m_VariablesMap for new settings
- m_VariablesMap.clear();
-
- bool theChangeFlag(false);
- bool theVariableError(false);
- Q3DStudio::CString theErrorMessage;
- std::list<Q3DStudio::CString>::iterator theEnd = inVariables.end();
- std::list<Q3DStudio::CString>::iterator theIterator = inVariables.begin();
- for (; theIterator != theEnd; ++theIterator) {
- // Decode the string into key and value
- long theIndex = theIterator->Find('=');
- if (theIndex != Q3DStudio::CString::ENDOFSTRING) {
- Q3DStudio::CString theKey = theIterator->Left(theIndex);
- theKey.TrimLeft();
- theKey.TrimRight();
- Q3DStudio::CString theValue = theIterator->Extract(theIndex + 1);
- theValue.TrimLeft();
- theValue.TrimRight();
-
- // Strip the key of '{' and '}' if any and store key only as uppercase
- long theBeginIndex = theKey.Find('{');
- if (theBeginIndex != Q3DStudio::CString::ENDOFSTRING) {
- long theEndIndex = theKey.Find('}');
- if (theEndIndex != Q3DStudio::CString::ENDOFSTRING) {
- theKey = theKey.Extract(theBeginIndex + 1, theEndIndex - theBeginIndex - 1);
- }
- }
- theKey.ToUpper();
-
- // find whether it exists
- TVariableMap::iterator theMapIterator = theOrigMap.find(theKey);
- if (theMapIterator == theOrigMap.end()) {
- theChangeFlag = true;
- } else {
- if (theMapIterator->second != theValue) {
- theChangeFlag = true;
- }
- theOrigMap.erase(theMapIterator);
- }
- m_VariablesMap.insert(std::make_pair(theKey, theValue));
- } else {
- Q3DStudio::CString theString = *theIterator;
- theString.TrimLeft();
- if (!theString.IsEmpty()) {
- // Error encountered. Form the error message to be displayed
- if (!theVariableError) {
- theVariableError = true;
- } else
- theErrorMessage += "\n";
- // Format error in this parameters
- theErrorMessage += "\t";
- theErrorMessage += *theIterator;
- }
- }
- }
-
- if (theVariableError) {
- m_Core->GetDispatch()->FireOnProjectVariableFail(theErrorMessage);
- }
-
- if (theChangeFlag || 0 != theOrigMap.size()) // something was deleted
- FireChangeEvent();
-
- return theChangeFlag;
-}
-
-//==============================================================================
-/**
- * Formulate a new string by parsing the input string and replace every instance
- * of environment variable with it's corresponding value. If the environment is not
- * found, it is replace with an empty string. The environement variable is identified
- * by '{' and '}'
- */
-//==============================================================================
-Q3DStudio::CString CStudioProjectVariables::ResolveString(const Q3DStudio::CString &inString)
-{
- Q3DStudio::CString theReturnString;
- long theStart = 0; // start index of string
- long theBeginIndex = 0; // index of '{'
- long theEndIndex = 0; // index of '}'
- while (Q3DStudio::CString::ENDOFSTRING != theEndIndex) {
- theBeginIndex = inString.Find('{', theStart);
- if (Q3DStudio::CString::ENDOFSTRING != theBeginIndex) {
- theReturnString += inString.Extract(theStart, theBeginIndex - theStart);
- // find the corresponding '}'
- theEndIndex = inString.Find('}', theBeginIndex + 1);
- if (Q3DStudio::CString::ENDOFSTRING != theEndIndex) {
- // resolve the string
- Q3DStudio::CString theVariable =
- inString.Extract(theBeginIndex + 1, theEndIndex - theBeginIndex - 1);
- theVariable.ToUpper();
- TVariableMap::const_iterator theMapIter = m_VariablesMap.find(theVariable);
-
- if (m_VariablesMap.end() != theMapIter) {
- theReturnString += theMapIter->second;
- }
- theStart = theEndIndex + 1;
- } else
- theReturnString += inString.Extract(theBeginIndex);
- } else {
- theEndIndex = theBeginIndex;
- theReturnString += inString.Extract(theStart);
- }
- }
-
- return theReturnString;
-}
-
-//==============================================================================
-/**
- * Resolves the passed in variable and write out the resolved value if it exists.
- * @param inVariable the environment to be resolved
- * @param outValue the string to receive the resolved value
- * @return true if the variable exists, else false
- */
-//==============================================================================
-bool CStudioProjectVariables::ResolveVariable(const Q3DStudio::CString &inVariable,
- Q3DStudio::CString &outValue,
- bool inCaseInsensitive /* = true*/)
-{
- // environment variable is wrapped by '{' and '}'
- // so form the inVariable in this syntax before searching
- // Q3DStudio::CString theVariable = "{" + inVariable + "}";
- TVariableMap::const_iterator theMapIter;
- if (inCaseInsensitive) {
- Q3DStudio::CString theUpperInVariable = inVariable;
- theUpperInVariable.ToUpper();
- theMapIter = m_VariablesMap.find(theUpperInVariable);
- } else {
- theMapIter = m_VariablesMap.find(inVariable);
- }
- if (m_VariablesMap.end() != theMapIter) {
- outValue = theMapIter->second;
- return true;
- } else
- return false;
-}
-
-//=============================================================================
-/**
- * Add a listener to the list of objects to be notified on a change.
- * The listener gets told when the any of the environment changes.
- * @param inChangeListener listener who intereste for changes.
- */
-void CStudioProjectVariables::AddChangeListener(IVariableChangeListener *inChangeListener)
-{
- m_ChangeListeners.AddListener(inChangeListener);
-}
-
-//=============================================================================
-/**
- * Remove a listener from the list of objects to be notified on a change.
- * @param inChangeListener the change listener to be removed.
- */
-void CStudioProjectVariables::RemoveChangeListener(IVariableChangeListener *inChangeListener)
-{
- m_ChangeListeners.RemoveListener(inChangeListener);
-}
-
-//=============================================================================
-/**
- * Fire a change event for this object.
- */
-void CStudioProjectVariables::FireChangeEvent()
-{
- m_ChangeListeners.FireEvent(&IVariableChangeListener::OnVariableChanged);
-}
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioProjectVariables.h b/src/Authoring/Client/Code/Core/Utility/StudioProjectVariables.h
deleted file mode 100644
index a0dbe6d2..00000000
--- a/src/Authoring/Client/Code/Core/Utility/StudioProjectVariables.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2002 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef INCLUDED_STUDIO_PROJECT_VARIABLES_H
-#define INCLUDED_STUDIO_PROJECT_VARIABLES_H 1
-
-#pragma once
-
-#include "Multicaster.h"
-#include "Qt3DSCommonPrecompile.h"
-
-class CCore;
-
-class CStudioProjectVariables
-{
- //==============================================================================
- // Internal Classes
- //==============================================================================
-public:
- class IVariableChangeListener
- {
- public:
- virtual void OnVariableChanged() = 0;
- };
-
- //==============================================================================
- // Typedef
- //==============================================================================
-protected:
- typedef std::map<Q3DStudio::CString, Q3DStudio::CString>
- TVariableMap; // change to new coding standard
-
- //==============================================================================
- // Construction
- //==============================================================================
-public:
- CStudioProjectVariables(CCore *inCore);
- virtual ~CStudioProjectVariables();
-
- //==============================================================================
- // Member variables
- //==============================================================================
-protected:
- CCore *m_Core;
- TVariableMap m_VariablesMap;
- CMulticaster<IVariableChangeListener *> m_ChangeListeners;
-
- //==============================================================================
- // Methods
- //==============================================================================
-public:
- Q3DStudio::CString GetProjectVariables() const;
- void GetProjectVariables(std::list<Q3DStudio::CString> &ioVariables);
- bool SetProjectVariables(std::list<Q3DStudio::CString> &inVariables);
- void Clear();
-
- Q3DStudio::CString ResolveString(const Q3DStudio::CString &inString);
- bool ResolveVariable(const Q3DStudio::CString &inVariable, Q3DStudio::CString &outValue,
- bool inCaseInsensitive = true);
-
- // Change listeners
- void AddChangeListener(IVariableChangeListener *inListener);
- void RemoveChangeListener(IVariableChangeListener *inListener);
- virtual void FireChangeEvent();
-
- // Used for serialization *only*
- TVariableMap &UnsafeGetVariablesMap() { return m_VariablesMap; }
-};
-
-#endif // INCLUDED_STUDIO_PROJECT_VARIABLES_H
diff --git a/src/Authoring/Common/Code/Exceptions/StudioException.h b/src/Authoring/Common/Code/Exceptions/StudioException.h
index 2bff6e79..1765186b 100644
--- a/src/Authoring/Common/Code/Exceptions/StudioException.h
+++ b/src/Authoring/Common/Code/Exceptions/StudioException.h
@@ -28,18 +28,14 @@
****************************************************************************/
#ifndef INCLUDED_STUDIO_EXCEPTION_H
-#define INCLUDED_STUDIO_EXCEPTION_H 1
+#define INCLUDED_STUDIO_EXCEPTION_H
-#pragma once
-
-#ifdef WIN32
-#include <wchar.h>
-#endif
+#include <QtCore/qstring.h>
class CStudioException
{
public:
virtual ~CStudioException() {}
- virtual const wchar_t *GetDescription() const = 0;
+ virtual QString GetDescription() const = 0;
};
#endif // INCLUDED_STUDIO_EXCEPTION_H
diff --git a/src/Authoring/Common/Code/Exceptions/XMLException.cpp b/src/Authoring/Common/Code/Exceptions/XMLException.cpp
index da919033..f6bfba73 100644
--- a/src/Authoring/Common/Code/Exceptions/XMLException.cpp
+++ b/src/Authoring/Common/Code/Exceptions/XMLException.cpp
@@ -27,10 +27,10 @@
**
****************************************************************************/
-#include "Qt3DSCommonPrecompile.h"
#include "XMLException.h"
-CXMLException::CXMLException(const wchar_t *inXMLDescription)
+CXMLException::CXMLException(const QString &inXMLDescription)
+ : m_Description(inXMLDescription)
{
- wcscpy(m_Description, inXMLDescription);
+
}
diff --git a/src/Authoring/Common/Code/Exceptions/XMLException.h b/src/Authoring/Common/Code/Exceptions/XMLException.h
index b6e49ef5..04ba705b 100644
--- a/src/Authoring/Common/Code/Exceptions/XMLException.h
+++ b/src/Authoring/Common/Code/Exceptions/XMLException.h
@@ -28,27 +28,20 @@
****************************************************************************/
#ifndef INCLUDED_XML_EXCEPTION_H
-#define INCLUDED_XML_EXCEPTION_H 1
+#define INCLUDED_XML_EXCEPTION_H
-#pragma once
-
-const short XML_DESCRIPTION_LENGTH = 256;
-
-//==============================================================================
-// Includes
-//==============================================================================
#include "StudioException.h"
class CXMLException : public CStudioException
{
public:
- CXMLException(const wchar_t *inXMLDescription);
+ CXMLException(const QString &inXMLDescription);
virtual ~CXMLException() {}
- const wchar_t *GetDescription() const override { return m_Description; }
+ QString GetDescription() const override { return m_Description; }
protected:
- wchar_t m_Description[XML_DESCRIPTION_LENGTH]; ///< A description of the exception
+ QString m_Description; ///< A description of the exception
};
#endif // INCLUDED_XML_EXCEPTION_H
diff --git a/src/Authoring/Common/Code/IO/BufferedInputStream.cpp b/src/Authoring/Common/Code/IO/BufferedInputStream.cpp
index 87d5f33c..55bd56f7 100644
--- a/src/Authoring/Common/Code/IO/BufferedInputStream.cpp
+++ b/src/Authoring/Common/Code/IO/BufferedInputStream.cpp
@@ -97,7 +97,7 @@ void CBufferedInputStream::Close()
m_InputStream->Close();
}
-bool CBufferedInputStream::IsValid()
+bool CBufferedInputStream::IsValid() const
{
if (m_InputStream != NULL)
return m_InputStream->IsValid();
diff --git a/src/Authoring/Common/Code/IO/BufferedInputStream.h b/src/Authoring/Common/Code/IO/BufferedInputStream.h
index e55bf693..9aec09e7 100644
--- a/src/Authoring/Common/Code/IO/BufferedInputStream.h
+++ b/src/Authoring/Common/Code/IO/BufferedInputStream.h
@@ -62,10 +62,10 @@ public:
long Read(void *inBuffer, long inBufferLength) override;
void Close() override;
- bool IsValid() override;
+ bool IsValid() const override;
virtual void InsertIntoBuffer(void *inData, long inDataLength);
- Q3DStudio::CString GetMimeType() override { return L""; }
- Q3DStudio::CString GetSource() override { return L""; }
+ QString GetMimeType() const override { return {}; }
+ QString GetSource() const override { return {}; }
protected:
long FillBuffer();
diff --git a/src/Authoring/Common/Code/IO/BufferedOutputStream.cpp b/src/Authoring/Common/Code/IO/BufferedOutputStream.cpp
index 68b552cb..8fdcb16c 100644
--- a/src/Authoring/Common/Code/IO/BufferedOutputStream.cpp
+++ b/src/Authoring/Common/Code/IO/BufferedOutputStream.cpp
@@ -100,7 +100,7 @@ void CBufferedOutputStream::Close()
m_OutputStream->Close();
}
-bool CBufferedOutputStream::IsValid()
+bool CBufferedOutputStream::IsValid() const
{
if (m_OutputStream != NULL)
return m_OutputStream->IsValid();
@@ -196,7 +196,7 @@ void CBufferedSeekOutputStream::Close()
m_OutputStream->Close();
}
-bool CBufferedSeekOutputStream::IsValid()
+bool CBufferedSeekOutputStream::IsValid() const
{
return m_OutputStream->IsValid();
}
diff --git a/src/Authoring/Common/Code/IO/BufferedOutputStream.h b/src/Authoring/Common/Code/IO/BufferedOutputStream.h
index f65a7979..818152f3 100644
--- a/src/Authoring/Common/Code/IO/BufferedOutputStream.h
+++ b/src/Authoring/Common/Code/IO/BufferedOutputStream.h
@@ -61,7 +61,7 @@ public:
virtual bool Write(std::wostringstream &inStringStream);
void Flush() override;
void Close() override;
- bool IsValid() override;
+ bool IsValid() const override;
};
class CBufferedSeekOutputStream : public CSeekOutputStream
@@ -89,7 +89,7 @@ public:
void Close() override;
- bool IsValid() override;
+ bool IsValid() const override;
// CSeekOutputStream
long Seek(ESeekPosition inPosition, long inOffset) override;
diff --git a/src/Authoring/Common/Code/IO/FileInputStream.cpp b/src/Authoring/Common/Code/IO/FileInputStream.cpp
index 382dba8e..47151f39 100644
--- a/src/Authoring/Common/Code/IO/FileInputStream.cpp
+++ b/src/Authoring/Common/Code/IO/FileInputStream.cpp
@@ -31,11 +31,11 @@
#include "FileInputStream.h"
#include "IOLibraryException.h"
-CFileInputStream::CFileInputStream(const Q3DStudio::CString &inFilename)
+CFileInputStream::CFileInputStream(const QString &inFilename)
: m_FileName(inFilename)
, m_ReadBytesFromCurrentBuffer(0)
, m_AvailableBytesInBuffer(0)
- , m_File(inFilename.toQString())
+ , m_File(inFilename)
{
m_InternalBuffer[0] = '\0';
if (!m_File.open(QFile::ReadOnly))
@@ -178,12 +178,12 @@ void CFileInputStream::Close()
* Does not check for EOF.
* @param outResult true if file is open.
*/
-bool CFileInputStream::IsValid()
+bool CFileInputStream::IsValid() const
{
return m_File.isOpen();
}
-Q3DStudio::CString CFileInputStream::GetSource()
+QString CFileInputStream::GetSource() const
{
return m_FileName;
}
diff --git a/src/Authoring/Common/Code/IO/FileInputStream.h b/src/Authoring/Common/Code/IO/FileInputStream.h
index a01812a5..20506c20 100644
--- a/src/Authoring/Common/Code/IO/FileInputStream.h
+++ b/src/Authoring/Common/Code/IO/FileInputStream.h
@@ -36,7 +36,6 @@
#include <stdio.h>
#include "InputStream.h"
-#include "Qt3DSString.h"
#include <QFile>
@@ -55,7 +54,7 @@ protected:
// Field Members
protected:
- Q3DStudio::CString m_FileName;
+ QString m_FileName;
char m_InternalBuffer[INTERNAL_BUFFER_SIZE];
long m_ReadBytesFromCurrentBuffer;
@@ -64,7 +63,7 @@ protected:
// Construction
public:
- CFileInputStream(const Q3DStudio::CString &inFileName);
+ CFileInputStream(const QString &inFileName);
virtual ~CFileInputStream();
// CInputStream
@@ -72,9 +71,9 @@ public:
long Seek(Q3DStudio::ISeekable::ESeekPosition inSeekPosition, long inOffset) override;
long Read(void *inBuffer, long inBufferLength) override;
void Close() override;
- bool IsValid() override;
- Q3DStudio::CString GetMimeType() override { return L""; }
- Q3DStudio::CString GetSource() override;
+ bool IsValid() const override;
+ QString GetMimeType() const override { return {}; }
+ QString GetSource() const override;
};
#endif // INCLUDED_FILEINPUTSTREAM_H
diff --git a/src/Authoring/Common/Code/IO/FileOutputStream.cpp b/src/Authoring/Common/Code/IO/FileOutputStream.cpp
index c8e25078..a17f7eac 100644
--- a/src/Authoring/Common/Code/IO/FileOutputStream.cpp
+++ b/src/Authoring/Common/Code/IO/FileOutputStream.cpp
@@ -34,12 +34,13 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qstring.h>
-CFileOutputStream::CFileOutputStream(const Q3DStudio::CString &inFilename, bool inAppend /* = false */)
+CFileOutputStream::CFileOutputStream(const QString &inFilename, bool inAppend /* = false */)
: m_Position(0)
, m_Length(0)
{
#ifdef WIN32
- m_File = ::CreateFile(inFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL,
+ m_File = ::CreateFile(Q3DStudio::CString::fromQString(inFilename),
+ GENERIC_WRITE, FILE_SHARE_READ, NULL,
(inAppend) ? OPEN_ALWAYS : CREATE_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL);
if (m_File == INVALID_HANDLE_VALUE)
throw CIOException();
@@ -47,7 +48,7 @@ CFileOutputStream::CFileOutputStream(const Q3DStudio::CString &inFilename, bool
if (inAppend)
::SetFilePointer(m_File, 0, NULL, FILE_END);
#else
- QByteArray theUTFBuffer = inFilename.toQString().toUtf8();
+ QByteArray theUTFBuffer = inFilename.toUtf8();
m_File = ::fopen(theUTFBuffer.constData(), (inAppend) ? "a" : "w");
if (m_File == NULL)
throw CIOException();
@@ -112,7 +113,7 @@ void CFileOutputStream::Close()
/** Check to see if thus stream is valid (opened successfully and still open).
*/
-bool CFileOutputStream::IsValid()
+bool CFileOutputStream::IsValid() const
{
#ifdef WIN32
return (m_File != INVALID_HANDLE_VALUE);
diff --git a/src/Authoring/Common/Code/IO/FileOutputStream.h b/src/Authoring/Common/Code/IO/FileOutputStream.h
index a64ab06f..d6785475 100644
--- a/src/Authoring/Common/Code/IO/FileOutputStream.h
+++ b/src/Authoring/Common/Code/IO/FileOutputStream.h
@@ -35,7 +35,6 @@
#define INCLUDED_FILE_OUTPUT_STREAM_H
#include "OutputStream.h"
-#include "Qt3DSString.h"
#include <stdio.h>
#ifdef WIN32
@@ -62,13 +61,13 @@ protected:
public:
// Construction
- CFileOutputStream(const Q3DStudio::CString &inFilename, bool inAppend = false);
+ CFileOutputStream(const QString &inFilename, bool inAppend = false);
virtual ~CFileOutputStream();
long Write(const void *inBuffer, long inBufferLength) override;
void Flush() override;
void Close() override;
- bool IsValid() override;
+ bool IsValid() const override;
// CSeekOutputStream
long GetCurrentPosition() override;
diff --git a/src/Authoring/Common/Code/IO/IOLibraryException.h b/src/Authoring/Common/Code/IO/IOLibraryException.h
index cf8982ad..2ef7f56e 100644
--- a/src/Authoring/Common/Code/IO/IOLibraryException.h
+++ b/src/Authoring/Common/Code/IO/IOLibraryException.h
@@ -28,14 +28,10 @@
****************************************************************************/
#ifndef INCLUDED_IOLIBRARYEXCEPTION_H
-#define INCLUDED_IOLIBRARYEXCEPTION_H 1
-
-#pragma once
+#define INCLUDED_IOLIBRARYEXCEPTION_H
#include "StudioException.h"
-
-// This string should never be displayed to user, just for brief description.
-static const wchar_t IOLIBRARY_EXCEPTION_DESCRIPTION[] = L"IOLibrary Exception";
+#include <QtCore/qobject.h>
class CIOException : public CStudioException
{
@@ -43,6 +39,6 @@ public:
CIOException() {}
virtual ~CIOException() {}
- const wchar_t *GetDescription() const override { return IOLIBRARY_EXCEPTION_DESCRIPTION; }
+ QString GetDescription() const override { return QObject::tr("IOLibrary Exception"); }
};
#endif // INCLUDED_IOLIBRARYEXCEPTION_H
diff --git a/src/Authoring/Common/Code/IO/IOStreams.cpp b/src/Authoring/Common/Code/IO/IOStreams.cpp
index c82261fa..d20ee704 100644
--- a/src/Authoring/Common/Code/IO/IOStreams.cpp
+++ b/src/Authoring/Common/Code/IO/IOStreams.cpp
@@ -160,7 +160,7 @@ void CInStream::Close()
m_Stream->Close();
}
-bool CInStream::IsValid()
+bool CInStream::IsValid() const
{
return m_Stream->IsValid();
}
@@ -248,7 +248,7 @@ void COutStream::Close()
m_Stream->Close();
}
-bool COutStream::IsValid()
+bool COutStream::IsValid() const
{
return m_Stream->IsValid();
}
diff --git a/src/Authoring/Common/Code/IO/IOStreams.h b/src/Authoring/Common/Code/IO/IOStreams.h
index 2427311f..292e1985 100644
--- a/src/Authoring/Common/Code/IO/IOStreams.h
+++ b/src/Authoring/Common/Code/IO/IOStreams.h
@@ -70,9 +70,9 @@ public:
// CInputStream functions
long Read(void *outBuffer, long inByteCount) override;
void Close() override;
- bool IsValid() override;
- Q3DStudio::CString GetMimeType() override { return L""; }
- Q3DStudio::CString GetSource() override { return L""; }
+ bool IsValid() const override;
+ QString GetMimeType() const override { return {}; }
+ QString GetSource() const override { return {}; }
// Ease of use function
virtual void ReadData(void *inBuffer, long inBufferLength);
@@ -114,7 +114,7 @@ public:
long Write(const void *inBuffer, long inBufferLength) override;
void Flush() override;
void Close() override;
- bool IsValid() override;
+ bool IsValid() const override;
// Ease of use function
virtual void WriteData(const void *inBuffer, long inBufferLength);
diff --git a/src/Authoring/Common/Code/IO/InputStream.h b/src/Authoring/Common/Code/IO/InputStream.h
index b72f4663..92fea5a5 100644
--- a/src/Authoring/Common/Code/IO/InputStream.h
+++ b/src/Authoring/Common/Code/IO/InputStream.h
@@ -36,7 +36,7 @@
// Includes
//==============================================================================
#include "Seekable.h"
-#include "Qt3DSString.h"
+#include <QtCore/qstring.h>
//==============================================================================
// Forwards
@@ -54,9 +54,9 @@ public:
virtual long Read(void *inBuffer, long inBufferLength) = 0;
virtual void Close() = 0;
- virtual bool IsValid() = 0;
- virtual Q3DStudio::CString GetMimeType() = 0;
- virtual Q3DStudio::CString GetSource() = 0;
+ virtual bool IsValid() const = 0;
+ virtual QString GetMimeType() const = 0;
+ virtual QString GetSource() const = 0;
};
#endif // INCLUDED_INPUT_STREAM_H
diff --git a/src/Authoring/Common/Code/IO/MemInputStream.cpp b/src/Authoring/Common/Code/IO/MemInputStream.cpp
index 6c31d41c..613c0831 100644
--- a/src/Authoring/Common/Code/IO/MemInputStream.cpp
+++ b/src/Authoring/Common/Code/IO/MemInputStream.cpp
@@ -61,7 +61,7 @@ void CMemInputStream::Close()
{
}
-bool CMemInputStream::IsValid()
+bool CMemInputStream::IsValid() const
{
return true;
}
diff --git a/src/Authoring/Common/Code/IO/MemInputStream.h b/src/Authoring/Common/Code/IO/MemInputStream.h
index 158edf2d..25301e2d 100644
--- a/src/Authoring/Common/Code/IO/MemInputStream.h
+++ b/src/Authoring/Common/Code/IO/MemInputStream.h
@@ -42,9 +42,9 @@ public:
virtual ~CMemInputStream() = 0;
long Read(void *inBuffer, long inBufferLength) override;
void Close() override;
- bool IsValid() override;
- Q3DStudio::CString GetMimeType() override { return L""; }
- Q3DStudio::CString GetSource() override { return L""; }
+ bool IsValid() const override;
+ QString GetMimeType() const override { return {}; }
+ QString GetSource() const override { return {}; }
//========================================================================
/**
* Returns amount read into buffer, which could be zero.
diff --git a/src/Authoring/Common/Code/IO/MemOutputStream.h b/src/Authoring/Common/Code/IO/MemOutputStream.h
index 2195d203..78186336 100644
--- a/src/Authoring/Common/Code/IO/MemOutputStream.h
+++ b/src/Authoring/Common/Code/IO/MemOutputStream.h
@@ -39,7 +39,7 @@ public:
virtual void Write(const char *inData, unsigned long inLength, unsigned long &outWritten);
long Write(const void *inBuffer, long inBufferLength) override;
void Close() override {}
- bool IsValid() override { return m_Position == m_Length; }
+ bool IsValid() const override { return m_Position == m_Length; }
void Flush() override;
long Seek(ESeekPosition inPosition, long inOffset) override;
long GetCurrentPosition() override;
diff --git a/src/Authoring/Common/Code/IO/OutputStream.h b/src/Authoring/Common/Code/IO/OutputStream.h
index ee349d41..c61f62d5 100644
--- a/src/Authoring/Common/Code/IO/OutputStream.h
+++ b/src/Authoring/Common/Code/IO/OutputStream.h
@@ -41,7 +41,7 @@ public:
virtual long Write(const void *inBuffer, long inBufferLength) = 0;
virtual void Flush() = 0;
virtual void Close() = 0;
- virtual bool IsValid() = 0;
+ virtual bool IsValid() const = 0;
};
class CSeekOutputStream : public COutputStream, public Q3DStudio::ISeekable
@@ -49,4 +49,4 @@ class CSeekOutputStream : public COutputStream, public Q3DStudio::ISeekable
public:
virtual ~CSeekOutputStream() {}
};
-#endif // INCLUDED_OUTPUT_STREAM_H \ No newline at end of file
+#endif // INCLUDED_OUTPUT_STREAM_H
diff --git a/src/Authoring/Common/Code/Preferences.h b/src/Authoring/Common/Code/Preferences.h
index cbbe118b..d694de33 100644
--- a/src/Authoring/Common/Code/Preferences.h
+++ b/src/Authoring/Common/Code/Preferences.h
@@ -28,67 +28,42 @@
****************************************************************************/
#ifndef INCLUDED_PREFERENCES_H
-#define INCLUDED_PREFERENCES_H 1
-
-#pragma once
+#define INCLUDED_PREFERENCES_H
#include "CColor.h"
-
-//==============================================================================
-// Forwards
-//==============================================================================
-class CPreferencesSerializer;
+#include <QtXml/qdom.h>
class CPreferences
{
public:
- CPreferences(const Q3DStudio::CString &inTagPath)
- : m_TagPath(inTagPath)
- {
- }
- virtual ~CPreferences();
-
- CPreferences(const CPreferences &inPreferences);
- CPreferences &operator=(const CPreferences &inRightHandSide);
-
- static CPreferences GetUserPreferences();
- static CPreferences GetUserPreferences(const Q3DStudio::CString &inSubKeyPath);
-
- CPreferences GetPreferences(const Q3DStudio::CString &inPreferencesKey);
-
- void SetStringValue(const Q3DStudio::CString &inKey, const Q3DStudio::CString &inValue);
- Q3DStudio::CString GetStringValue(const Q3DStudio::CString &inKey,
- const Q3DStudio::CString &inDefaultValue);
+ CPreferences();
+ ~CPreferences();
- void SetLongValue(const Q3DStudio::CString &inKey, long inValue);
- long GetLongValue(const Q3DStudio::CString &inKey, long inDefaultValue);
+ void SetStringValue(const QString &key, const QString &value, const QString &group = {});
+ QString GetStringValue(const QString &key, const QString &defaultValue = {},
+ const QString &group = {});
- void SetValue(const Q3DStudio::CString &inKey, bool inValue);
- bool GetValue(const Q3DStudio::CString &inKey, bool inDefaultValue);
+ void SetLongValue(const QString &inKey, long inValue, const QString &group = {});
+ long GetLongValue(const QString &inKey, long inDefaultValue = 0, const QString &group = {});
- void SetValue(const Q3DStudio::CString &inKey, double inValue);
- double GetValue(const Q3DStudio::CString &inKey, double inDefaultValue);
+ void SetValue(const QString &inKey, bool inValue, const QString &group = {});
+ bool GetValue(const QString &inKey, bool inDefaultValue, const QString &group = {});
- void SetColorValue(const Q3DStudio::CString &inKey, ::CColor inValue);
- ::CColor GetColorValue(const Q3DStudio::CString &inKey, ::CColor inDefaultValue);
+ void SetValue(const QString &inKey, double inValue, const QString &group = {});
+ double GetValue(const QString &inKey, double inDefaultValue, const QString &group = {});
- void SetBinaryValue(const Q3DStudio::CString &inKey, const void *inData, long inLength);
- bool GetBinaryValue(const Q3DStudio::CString &inKey, void *outData, long inLength);
+ void SetColorValue(const QString &inKey, ::CColor inValue, const QString &group = {});
+ ::CColor GetColorValue(const QString &inKey, ::CColor inDefaultValue,
+ const QString &group = {});
- void Clear();
-
- long GetItemCount();
-
- void Commit();
-
- void RemoveKey(const Q3DStudio::CString &inKeyName);
-
- bool Exists(const Q3DStudio::CString &inKeyName);
-
- static void SetPreferencesFile(const Q3DStudio::CString &inFileName);
+ void SetPreferencesFile(const QString &inFileName);
+ void save();
private:
- Q3DStudio::CString m_TagPath;
- static CPreferencesSerializer s_PreferencesSerializer;
+ QString getValue(const QString &key, const QString &group = {});
+ void setValue(const QString &key, const QString &value, const QString &group = {});
+
+ QString m_PreferencesFile = {};
+ QDomDocument m_domDoc = {};
};
#endif // INCLUDED_PREFERENCES_H
diff --git a/src/Authoring/Common/Code/Qt3DSFile.h b/src/Authoring/Common/Code/Qt3DSFile.h
index 797bc13a..b6098874 100644
--- a/src/Authoring/Common/Code/Qt3DSFile.h
+++ b/src/Authoring/Common/Code/Qt3DSFile.h
@@ -90,7 +90,7 @@ public:
OSErr SetReadOnly(bool inReadOnlyFlag);
- static Qt3DSFile GetApplicationDirectory();
+ static QString GetApplicationDirectory();
static Qt3DSFile GetTemporaryFile(const Q3DStudio::CString &inExtension);
static Qt3DSFile GetTemporaryFile();
static bool IsPathRelative(const Q3DStudio::CString &inPath);
diff --git a/src/Authoring/Common/Code/Qt3DSFileTools.cpp b/src/Authoring/Common/Code/Qt3DSFileTools.cpp
index f89d2988..0e0056b1 100644
--- a/src/Authoring/Common/Code/Qt3DSFileTools.cpp
+++ b/src/Authoring/Common/Code/Qt3DSFileTools.cpp
@@ -153,11 +153,6 @@ CString CFilePath::GetPathWithIdentifier() const
return CString::fromQString(filePath() + identifierSep + m_identifier);
}
-CString CFilePath::GetModuleFilePath()
-{
- return CString::fromQString(qApp->applicationFilePath());
-}
-
//==============================================================================
/**
* Converts the absolute path this string represents into a relative path.
@@ -352,9 +347,9 @@ SFileData CFilePath::GetFileData() const
return data;
}
-CFilePath CFilePath::GetUserApplicationDirectory()
+QString CFilePath::GetUserApplicationDirectory()
{
- return CFilePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
+ return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
}
SFile::SFile(const QSharedPointer<QFile> &of, const CFilePath &path)
diff --git a/src/Authoring/Common/Code/Qt3DSFileTools.h b/src/Authoring/Common/Code/Qt3DSFileTools.h
index 6ac899a5..53248cbf 100644
--- a/src/Authoring/Common/Code/Qt3DSFileTools.h
+++ b/src/Authoring/Common/Code/Qt3DSFileTools.h
@@ -97,8 +97,6 @@ public:
void SetIdentifier(const CString &identifier)
{ m_identifier = identifier.toQString(); }
- static CString GetModuleFilePath();
-
void ConvertToRelative(const CFilePath &inBaseAbsolute);
static CFilePath GetRelativePathFromBase(const CFilePath &inBase, const CFilePath &inPath)
{
@@ -199,7 +197,7 @@ public:
SFileData GetFileData() const;
// Get the directory where applications can write data.
- static CFilePath GetUserApplicationDirectory();
+ static QString GetUserApplicationDirectory();
private:
void normalizeAndSetPath(const QString& path);
diff --git a/src/Authoring/Common/Code/Serialize/FormattedInputStream.cpp b/src/Authoring/Common/Code/Serialize/FormattedInputStream.cpp
index d7f6a877..fe6d3a12 100644
--- a/src/Authoring/Common/Code/Serialize/FormattedInputStream.cpp
+++ b/src/Authoring/Common/Code/Serialize/FormattedInputStream.cpp
@@ -59,7 +59,7 @@ void CFormattedInputStream::Close()
m_InputStream->Close();
}
-bool CFormattedInputStream::IsValid()
+bool CFormattedInputStream::IsValid() const
{
return m_InputStream->IsValid();
}
@@ -146,9 +146,7 @@ unsigned short CFormattedInputStream::ReadUnsignedShort()
void CFormattedInputStream::CopyToFile(const Qt3DSFile &inFile, long inLength,
bool inCloseStream /*= true */)
{
- Q3DStudio::CString thePath = inFile.GetAbsolutePosixPath();
-
- CFileOutputStream theFileStream(thePath);
+ CFileOutputStream theFileStream(inFile.GetAbsolutePosixPath().toQString());
unsigned long theLength = inLength;
unsigned long theBufferSize = 1024;
diff --git a/src/Authoring/Common/Code/Serialize/FormattedInputStream.h b/src/Authoring/Common/Code/Serialize/FormattedInputStream.h
index 84a34a73..58c66ede 100644
--- a/src/Authoring/Common/Code/Serialize/FormattedInputStream.h
+++ b/src/Authoring/Common/Code/Serialize/FormattedInputStream.h
@@ -33,7 +33,6 @@
#pragma once
#include "Qt3DSFile.h"
-#include "Qt3DSString.h"
#include "InputStream.h"
class CFormattedInputStream : public CInputStream
@@ -44,9 +43,9 @@ public:
long Read(void *inData, long inLength) override;
void Close() override;
- bool IsValid() override;
- Q3DStudio::CString GetMimeType() override { return L""; }
- Q3DStudio::CString GetSource() override { return L""; }
+ bool IsValid() const override;
+ QString GetMimeType() const override { return {}; }
+ QString GetSource() const override { return {}; }
void SetBigEndian(bool inIsBigEndian);
diff --git a/src/Authoring/Common/Code/Serialize/FormattedOutputStream.cpp b/src/Authoring/Common/Code/Serialize/FormattedOutputStream.cpp
index 060fb4e9..c047b0cc 100644
--- a/src/Authoring/Common/Code/Serialize/FormattedOutputStream.cpp
+++ b/src/Authoring/Common/Code/Serialize/FormattedOutputStream.cpp
@@ -56,7 +56,7 @@ void CFormattedOutputStream::Flush()
m_OutputStream->Flush();
}
-bool CFormattedOutputStream::IsValid()
+bool CFormattedOutputStream::IsValid() const
{
return m_OutputStream->IsValid();
}
diff --git a/src/Authoring/Common/Code/Serialize/FormattedOutputStream.h b/src/Authoring/Common/Code/Serialize/FormattedOutputStream.h
index be8513d3..f4dcbf0a 100644
--- a/src/Authoring/Common/Code/Serialize/FormattedOutputStream.h
+++ b/src/Authoring/Common/Code/Serialize/FormattedOutputStream.h
@@ -43,7 +43,7 @@ public:
long Write(const void *inData, long inLength) override;
void Close() override;
- bool IsValid() override;
+ bool IsValid() const override;
void Flush() override;
// CSeekOutputStream
diff --git a/src/Authoring/Common/Code/Serialize/PreferencesSerializer.cpp b/src/Authoring/Common/Code/Serialize/PreferencesSerializer.cpp
deleted file mode 100644
index 7272feeb..00000000
--- a/src/Authoring/Common/Code/Serialize/PreferencesSerializer.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 1993-2009 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "Qt3DSCommonPrecompile.h"
-#include "PreferencesSerializer.h"
-
-#include <QtCore/qdir.h>
-
-CPreferencesSerializer::CPreferencesSerializer()
- : m_FileSet(false)
- , m_PreferencesStrTable(IStringTable::CreateStringTable())
- , m_PreferencesFactory(IDOMFactory::CreateDOMFactory(m_PreferencesStrTable))
-{
-}
-
-CPreferencesSerializer::~CPreferencesSerializer()
-{
- Serialize();
-}
-
-void CPreferencesSerializer::SetPreferencesFile(const Q3DStudio::CString &theFile)
-{
- Q3DStudio::CFilePath fPath(theFile);
-
- if (m_PreferencesFile.filePath() == fPath.filePath())
- return;
-
- Serialize();
-
- m_PreferencesFile = fPath;
-
- SDOMElement *topElement = NULL;
- if (m_PreferencesFile.IsFile()) {
- qt3ds::foundation::CFileSeekableIOStream theInStream(
- m_PreferencesFile.filePath(), qt3ds::foundation::FileReadFlags());
- if (theInStream.IsOpen() == false) {
- QT3DS_ASSERT(false);
- m_FileSet = false;
- return;
- }
-
- topElement = CDOMSerializer::Read(*m_PreferencesFactory, theInStream);
- if (topElement == NULL) {
- QT3DS_ASSERT(false);
- m_FileSet = false;
- return;
- }
- } else {
- topElement = m_PreferencesFactory->NextElement(L"Settings");
- }
-
- m_PreferencesIO =
- IDOMWriter::CreateDOMWriter(m_PreferencesFactory, *topElement, m_PreferencesStrTable);
- m_FileSet = true;
-}
-
-void CPreferencesSerializer::Begin(const Q3DStudio::CString &inTag)
-{
- if (!m_FileSet) {
- return;
- }
- if (!inTag.IsEmpty()) {
- std::shared_ptr<IDOMReader> theReader(m_PreferencesIO.second);
- CStringTokenizer theTokenizer(inTag, L"\\");
- do {
- Q3DStudio::CString theTag = theTokenizer.GetCurrentPartition();
- if (!theReader->MoveToFirstChild(theTag.c_str())) {
- std::shared_ptr<IDOMWriter> theWriter(m_PreferencesIO.first);
- theWriter->Begin(theTag.c_str());
- }
- ++theTokenizer;
- } while (theTokenizer.HasNextPartition());
- }
-}
-
-bool CPreferencesSerializer::GetSubElemValue(const Q3DStudio::CString &inSubElem,
- Q3DStudio::CString &outValue)
-{
- if (!m_FileSet) {
- return false;
- }
-
- std::shared_ptr<IDOMReader> theReader(m_PreferencesIO.second);
- IDOMReader::Scope _readerScoped(*theReader);
- bool hasNext = true;
-
- for (hasNext = theReader->MoveToFirstChild(); hasNext;
- hasNext = theReader->MoveToNextSibling()) {
- TWideXMLCharPtr strValue;
- theReader->Att(L"name", strValue);
- if (inSubElem.CompareNoCase(strValue)) {
- theReader->Att(L"value", strValue);
- outValue.assign(strValue);
- return true;
- }
- }
-
- return false;
-}
-
-void CPreferencesSerializer::SetSubElemValue(const Q3DStudio::CString &inSubElem,
- const Q3DStudio::CString &inValue)
-{
- if (!m_FileSet) {
- return;
- }
-
- std::shared_ptr<IDOMReader> theReader(m_PreferencesIO.second);
- theReader->PushScope();
- bool hasNext = true, hasFind = false;
- TWideXMLCharPtr strValue;
- for (hasNext = theReader->MoveToFirstChild(); hasNext;
- hasNext = theReader->MoveToNextSibling()) {
-
- theReader->Att(L"name", strValue);
- if (inSubElem.CompareNoCase(strValue)) {
- hasFind = true;
- break;
- }
- }
- if (hasFind) {
- std::shared_ptr<IDOMWriter> theWriter(m_PreferencesIO.first);
- theWriter->Att(L"value", inValue.c_str());
- theReader->PopScope();
- } else {
- theReader->PopScope();
- std::shared_ptr<IDOMWriter> theWriter(m_PreferencesIO.first);
- theWriter->Begin(L"Item");
- theWriter->Att(L"Name", inSubElem.c_str());
- theWriter->Att(L"value", inValue.c_str());
- }
-}
-void CPreferencesSerializer::Revert()
-{
- if (!m_FileSet) {
- return;
- }
-
- std::shared_ptr<IDOMReader> theReader(m_PreferencesIO.second);
- theReader->SetScope(theReader->GetTopElement());
-}
-
-void CPreferencesSerializer::Remove(const Q3DStudio::CString &inTag)
-{
- if (!m_FileSet) {
- return;
- }
- if (!inTag.IsEmpty()) {
- std::shared_ptr<IDOMReader> theReader(m_PreferencesIO.second);
- CStringTokenizer theTokenizer(inTag, L"\\");
- Q3DStudio::CString theTag;
- bool bBreak = true;
- do {
- theTag = theTokenizer.GetCurrentPartition();
- bBreak = theReader->MoveToFirstChild(theTag.c_str());
- if (!bBreak)
- break;
- ++theTokenizer;
- } while (theTokenizer.HasNextPartition());
- if (bBreak) {
- std::shared_ptr<IDOMWriter> theWriter(m_PreferencesIO.first);
- theWriter->RemoveCurrent();
- }
- } else {
- std::shared_ptr<IDOMReader> theReader(m_PreferencesIO.second);
- while (theReader->CountChildren() > 0) {
- theReader->MoveToFirstChild();
- std::shared_ptr<IDOMWriter> theWriter(m_PreferencesIO.first);
- theWriter->RemoveCurrent();
- }
- }
-}
-
-long CPreferencesSerializer::CountSubElems() const
-{
- if (!m_FileSet) {
- return 0;
- }
- std::shared_ptr<IDOMReader> theReader(m_PreferencesIO.second);
- return static_cast<long>(theReader->CountChildren());
-}
-
-void CPreferencesSerializer::RemoveSubElem(const Q3DStudio::CString &inSubElem)
-{
- if (!m_FileSet) {
- return;
- }
- std::shared_ptr<IDOMReader> theReader(m_PreferencesIO.second);
- IDOMReader::Scope _readerScoped(*theReader);
- bool hasNext = true;
- TWideXMLCharPtr strValue;
- for (hasNext = theReader->MoveToFirstChild(); hasNext;
- hasNext = theReader->MoveToNextSibling()) {
- theReader->Att(L"name", strValue);
- if (inSubElem.CompareNoCase(strValue)) {
- std::shared_ptr<IDOMWriter> theWriter(m_PreferencesIO.first);
- theWriter->RemoveCurrent();
- break;
- }
- }
-}
-
-bool CPreferencesSerializer::ExistElem(const Q3DStudio::CString &inElemName)
-{
- if (!m_FileSet) {
- return false;
- }
- std::shared_ptr<IDOMReader> theReader(m_PreferencesIO.second);
- IDOMReader::Scope _readerScoped(*theReader);
- return theReader->MoveToFirstChild(inElemName.c_str());
-}
-
-void CPreferencesSerializer::Serialize()
-{
- if (m_FileSet) {
- QString preferencesDir = m_PreferencesFile.dir().path();
- QDir dir(preferencesDir);
- if (!dir.exists()) {
- dir.mkpath(preferencesDir);
- }
-
- // Serialize the preferences in to the XML file
- qt3ds::foundation::CFileSeekableIOStream stream(
- m_PreferencesFile.filePath(), qt3ds::foundation::FileWriteFlags());
- stream.SetPosition(0, qt3ds::foundation::SeekPosition::Begin);
- CDOMSerializer::WriteXMLHeader(stream);
- CDOMSerializer::Write(*m_PreferencesIO.first->GetTopElement(), stream);
- }
-}
diff --git a/src/Authoring/Common/Code/Serialize/PreferencesSerializer.h b/src/Authoring/Common/Code/Serialize/PreferencesSerializer.h
deleted file mode 100644
index bc676fee..00000000
--- a/src/Authoring/Common/Code/Serialize/PreferencesSerializer.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2002 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//==============================================================================
-// Prefix
-//==============================================================================
-#ifndef INCLUDED_PREFERENCES_SERIALIZER_H
-#define INCLUDED_PREFERENCES_SERIALIZER_H 1
-
-#pragma once
-
-//==============================================================================
-// Includes
-//==============================================================================
-#include "Qt3DSDMXML.h"
-#include "StringTokenizer.h"
-#include "Qt3DSFileTools.h"
-
-using namespace qt3dsdm;
-
-class CPreferencesSerializer
-{
-public: // construction
- CPreferencesSerializer();
- ~CPreferencesSerializer();
-
-public: // methods
- void SetPreferencesFile(const Q3DStudio::CString &theFile);
-
- void Begin(const Q3DStudio::CString &inTag);
-
- bool GetSubElemValue(const Q3DStudio::CString &inSubElem, Q3DStudio::CString &outValue);
-
- void Revert();
-
- void Remove(const Q3DStudio::CString &inTag);
-
- void SetSubElemValue(const Q3DStudio::CString &inSubElem, const Q3DStudio::CString &inValue);
-
- long CountSubElems() const;
-
- void RemoveSubElem(const Q3DStudio::CString &inSubElem);
-
- bool ExistElem(const Q3DStudio::CString &inElemName);
-
- bool IsFileSet() const { return m_FileSet; }
-
-private:
- void Serialize();
-
-private:
- bool m_FileSet;
- Q3DStudio::CFilePath m_PreferencesFile;
- TStringTablePtr m_PreferencesStrTable;
- eastl::pair<std::shared_ptr<IDOMWriter>, std::shared_ptr<IDOMReader>> m_PreferencesIO;
- std::shared_ptr<IDOMFactory> m_PreferencesFactory;
-};
-
-#endif // INCLUDED_PREFERENCES_SERIALIZER_H \ No newline at end of file
diff --git a/src/Authoring/Common/Code/Serialize/ProjectSettingsSerializer.h b/src/Authoring/Common/Code/Serialize/ProjectSettingsSerializer.h
index f6624c07..26a8220b 100644
--- a/src/Authoring/Common/Code/Serialize/ProjectSettingsSerializer.h
+++ b/src/Authoring/Common/Code/Serialize/ProjectSettingsSerializer.h
@@ -39,7 +39,6 @@
// Includes
//==============================================================================
#include "StudioProjectSettings.h"
-#include "StudioProjectVariables.h"
#include "Qt3DSDMXML.h"
#include "Qt3DSDMWStrOpsImpl.h"
diff --git a/src/Authoring/Common/Code/Thread/Thread.cpp b/src/Authoring/Common/Code/Thread/Thread.cpp
index bda2eee5..6a14885d 100644
--- a/src/Authoring/Common/Code/Thread/Thread.cpp
+++ b/src/Authoring/Common/Code/Thread/Thread.cpp
@@ -145,7 +145,7 @@ void CThread::Join()
if (m_Thread != nullptr) {
bool nret = m_Thread->wait();
if (nret == false)
- throw CThreadException("Thread.Join: join failed");
+ throw CThreadException(QObject::tr("Thread.Join: join failed"));
}
}
diff --git a/src/Authoring/Common/Code/Thread/ThreadException.h b/src/Authoring/Common/Code/Thread/ThreadException.h
index aa1c7c4b..66f6631b 100644
--- a/src/Authoring/Common/Code/Thread/ThreadException.h
+++ b/src/Authoring/Common/Code/Thread/ThreadException.h
@@ -28,22 +28,20 @@
****************************************************************************/
#ifndef INCLUDED_THREAD_EXCEPTION_H
-#define INCLUDED_THREAD_EXCEPTION_H 1
-
-#pragma once
+#define INCLUDED_THREAD_EXCEPTION_H
#include "StudioException.h"
-#include "Qt3DSString.h"
+#include <QtCore/qstring.h>
class CThreadException : public CStudioException
{
public:
- CThreadException(Q3DStudio::CString inWhat) { m_What = inWhat; }
+ CThreadException(const QString &inWhat) { m_What = inWhat; }
virtual ~CThreadException() {}
- const wchar_t *GetDescription() const override { return m_What; }
+ QString GetDescription() const override { return m_What; }
protected:
- Q3DStudio::CString m_What;
+ QString m_What;
};
#endif // INCLUDED_THREAD_EXCEPTION_H
diff --git a/src/Authoring/Common/Code/_Win32/Preferences.cpp b/src/Authoring/Common/Code/_Win32/Preferences.cpp
index 9cd124c9..0acd77bd 100644
--- a/src/Authoring/Common/Code/_Win32/Preferences.cpp
+++ b/src/Authoring/Common/Code/_Win32/Preferences.cpp
@@ -26,280 +26,175 @@
**
****************************************************************************/
-#include "Qt3DSCommonPrecompile.h"
#include "Preferences.h"
-#include "PreferencesSerializer.h"
-#include "StringTokenizer.h"
+#include <QtCore/qfile.h>
-CPreferencesSerializer CPreferences::s_PreferencesSerializer;
-
-//=============================================================================
-/**
- * Copy constructor.
- */
-CPreferences::CPreferences(const CPreferences &inPrefs)
+CPreferences::CPreferences()
{
- m_TagPath = inPrefs.m_TagPath;
}
CPreferences::~CPreferences()
{
+ save();
}
-CPreferences &CPreferences::operator=(const CPreferences &inPrefs)
+void CPreferences::save()
{
- if (&inPrefs != this) {
- m_TagPath = inPrefs.m_TagPath;
+ if (!m_PreferencesFile.isEmpty()) {
+ QFile file(m_PreferencesFile);
+ file.open(QIODevice::WriteOnly);
+ file.resize(0);
+ file.write(m_domDoc.toByteArray(4));
}
- return *this;
}
-//=============================================================================
/**
- * Sets the preferences serialization file
+ * Sets the preferences file path
* This sets the applications base path for all preferences that are to be
- * loaded. This should be called before any CPreferences are created.
- * @param inFileName preferences serialization file.
+ * loaded. It also creates the preferences file if it doesn't exist. This
+ * should be called before any CPreferences are created.
+ * @param filePath preferences serialization file path.
*/
-void CPreferences::SetPreferencesFile(const Q3DStudio::CString &inFileName)
+void CPreferences::SetPreferencesFile(const QString &filePath)
{
- s_PreferencesSerializer.SetPreferencesFile(inFileName);
-}
+ if (m_PreferencesFile == filePath)
+ return;
-//=============================================================================
-/**
- * Get the User Preferences for this application.
- * This opens the Registry from HKEY_CURRENT_USER with key name set in
- * SetRegistryRoot.
- * Any values are in the user specific area of the registry.
- * @return the user preferences.
- */
-CPreferences CPreferences::GetUserPreferences()
-{
- return CPreferences(L"");
-}
+ m_PreferencesFile = filePath;
-//=============================================================================
-/**
- * Get the User Preferences for this this application.
- * This opens the Registry from HKEY_CURRENT_USER with the key as inLocation
- * appended to the Registry Root.
- * Any values are in the user specific area of the registry.
- * @param inLocation appended to RegistryRoot to get the sub key location.
- * @return the user preferences.
- */
-CPreferences CPreferences::GetUserPreferences(const Q3DStudio::CString &inLocation)
-{
- return CPreferences(inLocation);
+ QFile file(m_PreferencesFile);
+ if (!file.exists()) {
+ m_domDoc.setContent(QStringLiteral("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<Settings>"
+ "</Settings>"));
+
+ file.open(QIODevice::WriteOnly);
+ file.resize(0);
+ file.write(m_domDoc.toByteArray(4));
+ } else {
+ file.open(QIODevice::ReadOnly);
+ m_domDoc.setContent(&file);
+ }
}
-//=============================================================================
-/**
- * Set the value of inKey to inValue.
- * @param inKey the name of the key to set.
- * @param inValue the value for the key.
- */
-void CPreferences::SetStringValue(const Q3DStudio::CString &inKey,
- const Q3DStudio::CString &inValue)
+void CPreferences::SetStringValue(const QString &key, const QString &value,
+ const QString &group)
{
- s_PreferencesSerializer.Revert();
- s_PreferencesSerializer.Begin(m_TagPath);
- s_PreferencesSerializer.SetSubElemValue(inKey, inValue);
+ setValue(key, value, group);
}
-//=============================================================================
-/**
- * Get the value of inKey.
- * @param inKey the name of the key to get.
- * @param inDefaultValue the value to return if inKey's value cannot be gotten.
- * @return the value of inKey or inDefaultValue if an error ocurred.
- */
-Q3DStudio::CString CPreferences::GetStringValue(const Q3DStudio::CString &inKey,
- const Q3DStudio::CString &inDefaultValue)
+QString CPreferences::GetStringValue(const QString &key, const QString &defaultValue,
+ const QString &group)
{
- Q3DStudio::CString theValue;
- s_PreferencesSerializer.Revert();
- s_PreferencesSerializer.Begin(m_TagPath);
- if (!s_PreferencesSerializer.GetSubElemValue(inKey, theValue)) {
- theValue = inDefaultValue;
- }
+ QString value = getValue(key, group);
- return theValue;
+ return value.isEmpty() ? defaultValue : value;
}
-//=============================================================================
-/**
- * Set the value of inKey to inValue.
- * @param inKey the name of the key to set.
- * @param inValue the value for the key.
- */
-void CPreferences::SetLongValue(const Q3DStudio::CString &inKey, long inValue)
+void CPreferences::SetLongValue(const QString &key, long value,
+ const QString &group)
{
- s_PreferencesSerializer.Revert();
- s_PreferencesSerializer.Begin(m_TagPath);
- Q3DStudio::CString theStrValue;
- theStrValue.Format(_LSTR("%ld"), inValue);
-
- s_PreferencesSerializer.SetSubElemValue(inKey, theStrValue);
+ setValue(key, QString::number(value), group);
}
-//=============================================================================
-/**
- * Get the value of inKey.
- * @param inKey the name of the key to get.
- * @param inDefaultValue the value to return if inKey's value cannot be gotten.
- * @return the value of inKey or inDefaultValue if an error occurred.
- */
-long CPreferences::GetLongValue(const Q3DStudio::CString &inKey, long inDefaultValue)
+long CPreferences::GetLongValue(const QString &key, long defaultValue,
+ const QString &group)
{
- long theValue;
- Q3DStudio::CString theStrValue = GetStringValue(inKey, Q3DStudio::CString(""));
- if (theStrValue == "") {
- theValue = inDefaultValue;
- } else {
- theValue = atol(theStrValue.GetCharStar());
- }
+ QString theStrValue = GetStringValue(key, {}, group);
- return theValue;
+ return theStrValue.isEmpty() ? defaultValue : theStrValue.toLong();
}
-//=============================================================================
-/**
- * Set the value of inKey to inValue.
- * @param inKey the name of the key to set.
- * @param inValue the value for the key.
- */
-void CPreferences::SetValue(const Q3DStudio::CString &inKey, bool inValue)
+void CPreferences::SetValue(const QString &key, bool value, const QString &group)
{
- long theRegValue = inValue ? 1 : 0;
+ long theRegValue = value ? 1 : 0;
- SetLongValue(inKey, theRegValue);
+ SetLongValue(key, theRegValue, group);
}
-//=============================================================================
-/**
- * Get the value of inKey.
- * @param inKey the name of the key to get.
- * @param inDefaultValue the value to return if inKey's value cannot be gotten.
- * @return the value of inKey or inDefaultValue if an error occurred.
- */
-bool CPreferences::GetValue(const Q3DStudio::CString &inKey, bool inDefaultValue)
+bool CPreferences::GetValue(const QString &key, bool defaultValue, const QString &group)
{
- long theDefaultValue = inDefaultValue ? 1 : 0;
- long theRegValue = GetLongValue(inKey, theDefaultValue);
+ long theDefaultValue = defaultValue ? 1 : 0;
+ long theRegValue = GetLongValue(key, theDefaultValue, group);
return theRegValue ? true : false;
}
-//=============================================================================
-/**
- * Set the value of inKey to inValue.
- * @param inKey the name of the key to set.
- * @param inValue the value for the key.
- */
-void CPreferences::SetValue(const Q3DStudio::CString &inKey, double inValue)
+void CPreferences::SetValue(const QString &key, double value, const QString &group)
{
- s_PreferencesSerializer.Revert();
- s_PreferencesSerializer.Begin(m_TagPath);
- Q3DStudio::CString theStrValue;
- theStrValue.Format(_LSTR("%20.2f"), inValue);
-
- s_PreferencesSerializer.SetSubElemValue(inKey, theStrValue);
+ setValue(key, QString::number(value), group);
}
-//=============================================================================
-/**
- * Get the value of inKey.
- * @param inKey the name of the key to get.
- * @param inDefaultValue the value to return if inKey's value cannot be gotten.
- * @return the value of inKey or inDefaultValue if an error occurred.
- */
-double CPreferences::GetValue(const Q3DStudio::CString &inKey, double inDefaultValue)
+double CPreferences::GetValue(const QString &key, double defaultValue, const QString &group)
{
- double theValue;
- Q3DStudio::CString theStrValue = GetStringValue(inKey, Q3DStudio::CString(""));
- if (theStrValue == "") {
- theValue = inDefaultValue;
- } else {
- theValue = atof(theStrValue.GetCharStar());
- }
+ QString theStrValue = GetStringValue(key, {}, group);
- return theValue;
+ return theStrValue.isEmpty() ? defaultValue : theStrValue.toDouble();
}
-//=============================================================================
-/**
- * Get the value of inKey as a color.
- * @param inKey the name of the key to get.
- * @param inDefaultColor the value to return if inKey's value cannot be gotten.
- * @return the value of inKey or inDefaultColor if an error occurred.
- */
-CColor CPreferences::GetColorValue(const Q3DStudio::CString &inKey, CColor inDefaultColor)
+CColor CPreferences::GetColorValue(const QString &key, CColor defaultColor, const QString &group)
{
- CColor theRetColor = inDefaultColor;
- Q3DStudio::CString theColorString = GetStringValue(inKey, "");
- if (theColorString != "") {
- CStringTokenizer theTokenizer(theColorString, " ");
- Q3DStudio::CString theR = theTokenizer.GetCurrentPartition();
- ++theTokenizer;
- Q3DStudio::CString theG = theTokenizer.GetCurrentPartition();
- ++theTokenizer;
- Q3DStudio::CString theB = theTokenizer.GetCurrentPartition();
-
- theRetColor =
- ::CColor(atol(theR.GetCharStar()), atol(theG.GetCharStar()), atol(theB.GetCharStar()));
+ QString theColorString = GetStringValue(key, {}, group);
+ if (!theColorString.isEmpty()) {
+ QStringList rgb = theColorString.split(QStringLiteral(" "));
+ return ::CColor(rgb.at(0).toInt(), rgb.at(1).toInt(), rgb.at(2).toInt());
}
- return theRetColor;
-}
-//=============================================================================
-/**
- * Set the value of inKey to inValue.
- * @param inKey the name of the key to set.
- * @param inValue the value for the key.
- */
-void CPreferences::SetColorValue(const Q3DStudio::CString &inKey, CColor inValue)
-{
- s_PreferencesSerializer.Revert();
- s_PreferencesSerializer.Begin(m_TagPath);
- Q3DStudio::CString theStrValue;
- theStrValue.Format(_LSTR("%i %i %i"), inValue.GetRed(), inValue.GetGreen(), inValue.GetBlue());
- s_PreferencesSerializer.SetSubElemValue(inKey, theStrValue);
+ return defaultColor;
}
-void CPreferences::Clear()
+void CPreferences::SetColorValue(const QString &key, CColor value, const QString &group)
{
- s_PreferencesSerializer.Revert();
- s_PreferencesSerializer.Remove(m_TagPath);
+ QString rgbStr = QString("%1 %2 %2").arg(value.red).arg(value.green).arg(value.blue);
+ setValue(key, rgbStr, group);
}
-long CPreferences::GetItemCount()
+QString CPreferences::getValue(const QString &key, const QString &group)
{
- s_PreferencesSerializer.Revert();
- s_PreferencesSerializer.Begin(m_TagPath);
- return s_PreferencesSerializer.CountSubElems();
-}
+ if (m_PreferencesFile.isEmpty())
+ return {};
-//====================================================================
-/**
- * removes the specified sub element
- * @param inKeyName the name of the sub element to be removed
- */
-void CPreferences::RemoveKey(const Q3DStudio::CString &inKeyName)
-{
- s_PreferencesSerializer.Revert();
- s_PreferencesSerializer.Begin(m_TagPath);
- s_PreferencesSerializer.RemoveSubElem(inKeyName);
-}
+ QDomElement parentElem = group.isEmpty() ? m_domDoc.documentElement()
+ : m_domDoc.documentElement().firstChildElement(group);
+ if (!parentElem.isNull()) {
+ QDomNodeList itemNodes = parentElem.elementsByTagName(QStringLiteral("Item"));
+ if (!itemNodes.isEmpty()) {
+ for (int i = 0; i < itemNodes.count(); ++i) {
+ QDomElement itemElem = itemNodes.at(i).toElement();
+ if (itemElem.attribute(QStringLiteral("Name")) == key)
+ return itemElem.attribute(QStringLiteral("value"));
+ }
+ }
+ }
-//====================================================================
-/**
- * Determines if the key exists
- * @param inKeyName the name of the subkey
- */
-bool CPreferences::Exists(const Q3DStudio::CString &inKeyName)
-{
- s_PreferencesSerializer.Revert();
- s_PreferencesSerializer.Begin(m_TagPath);
- return s_PreferencesSerializer.ExistElem(inKeyName);
+ return {};
+}
+
+void CPreferences::setValue(const QString &key, const QString &value,
+ const QString &group)
+{
+ if (m_domDoc.isNull())
+ return;
+
+ QDomElement parentElem = group.isEmpty() ? m_domDoc.documentElement()
+ : m_domDoc.documentElement().firstChildElement(group);
+ if (!parentElem.isNull()) {
+ QDomNodeList itemNodes = parentElem.elementsByTagName(QStringLiteral("Item"));
+ if (!itemNodes.isEmpty()) {
+ for (int i = 0; i < itemNodes.count(); ++i) {
+ QDomElement itemElem = itemNodes.at(i).toElement();
+ if (itemElem.attribute(QStringLiteral("Name")) == key) {
+ // property exist, update it
+ itemElem.setAttribute(QStringLiteral("value"), value);
+ return;
+ }
+ }
+ }
+
+ // if property doesn't exist, create a new one
+ QDomElement elem = m_domDoc.createElement("Item");
+ elem.setAttribute(QStringLiteral("Name"), key);
+ elem.setAttribute(QStringLiteral("value"), value);
+ parentElem.appendChild(elem);
+ }
}
diff --git a/src/Authoring/Common/Code/_Win32/Qt3DSFile.cpp b/src/Authoring/Common/Code/_Win32/Qt3DSFile.cpp
index dfd4ae04..018d44d9 100644
--- a/src/Authoring/Common/Code/_Win32/Qt3DSFile.cpp
+++ b/src/Authoring/Common/Code/_Win32/Qt3DSFile.cpp
@@ -298,17 +298,16 @@ void Qt3DSFile::SetReadOnly(bool inReadOnlyFlag)
/**
* Get the location of where this application resides.
*/
-Qt3DSFile Qt3DSFile::GetApplicationDirectory()
+QString Qt3DSFile::GetApplicationDirectory()
{
#ifdef Q_OS_MACOS
QDir appDir(qApp->applicationDirPath());
- if (appDir.dirName() == "MacOS") {
- appDir.cdUp();
- appDir.cd("Resources");
- }
- return Qt3DSFile(Q3DStudio::CString::fromQString(appDir.absolutePath()));
+ if (appDir.dirName() == QLatin1String("MacOS"))
+ appDir.cd("../Resources");
+
+ return appDir.absolutePath();
#else
- return Qt3DSFile(Q3DStudio::CString::fromQString(qApp->applicationDirPath()));
+ return qApp->applicationDirPath();
#endif
}
diff --git a/src/Authoring/Common/Common.pro b/src/Authoring/Common/Common.pro
index 2231563a..9ab644c3 100644
--- a/src/Authoring/Common/Common.pro
+++ b/src/Authoring/Common/Common.pro
@@ -78,6 +78,5 @@ SOURCES += \
Code/Memory/MemoryObject.cpp \
Code/Serialize/FormattedInputStream.cpp \
Code/Serialize/FormattedOutputStream.cpp \
- Code/Serialize/PreferencesSerializer.cpp \
HEADERS = Code/Literals.h
diff --git a/src/Authoring/CoreLib/CoreLib.pro b/src/Authoring/CoreLib/CoreLib.pro
index db315208..f67a78c6 100644
--- a/src/Authoring/CoreLib/CoreLib.pro
+++ b/src/Authoring/CoreLib/CoreLib.pro
@@ -92,7 +92,6 @@ SOURCES += \
../Client/Code/Core/Utility/StudioClipboard.cpp \
../Client/Code/Core/Utility/StudioObjectTypes.cpp \
../Client/Code/Core/Utility/StudioPreferences.cpp \
- ../Client/Code/Core/Utility/StudioProjectVariables.cpp \
../Client/Code/Core/Utility/TestCmdUtils.cpp \
../Client/Code/Core/Commands/Cmd.cpp \
../Client/Code/Core/Commands/CmdActivateSlide.cpp \
diff --git a/src/Authoring/Studio/Application/AboutDlg.cpp b/src/Authoring/Studio/Application/AboutDlg.cpp
index 17d1ca63..818c3556 100644
--- a/src/Authoring/Studio/Application/AboutDlg.cpp
+++ b/src/Authoring/Studio/Application/AboutDlg.cpp
@@ -109,8 +109,7 @@ static QString compilerString()
void CAboutDlg::OnInitDialog()
{
// Set the Studio version
- m_ProductVersionStr = QStringLiteral("Qt 3D Studio v")
- + CStudioPreferences::GetVersionString().toQString();
+ m_ProductVersionStr = QStringLiteral("Qt 3D Studio v") + CStudioPreferences::GetVersionString();
// Set the copyright string
m_CopyrightStr = QObject::tr("Copyright (C) %1 The Qt Company. All rights reserved.").arg(
diff --git a/src/Authoring/Studio/Application/ProjectFile.cpp b/src/Authoring/Studio/Application/ProjectFile.cpp
index 9dd51f2a..b4650a03 100644
--- a/src/Authoring/Studio/Application/ProjectFile.cpp
+++ b/src/Authoring/Studio/Application/ProjectFile.cpp
@@ -50,14 +50,14 @@ ProjectFile::ProjectFile()
void ProjectFile::ensureProjectFile()
{
if (!m_fileInfo.exists()) {
- QFileInfo uipFile(g_StudioApp.GetCore()->GetDoc()
- ->GetDocumentPath().GetAbsolutePath().toQString());
- QString uiaPath(PresentationFile::findProjectFile(uipFile.absoluteFilePath()));
+ QFileInfo uipInfo(g_StudioApp.GetCore()->GetDoc()->GetDocumentPath());
+ QString uiaPath(PresentationFile::findProjectFile(uipInfo.absoluteFilePath()));
if (uiaPath.isEmpty()) {
- // .uia not found, create new project .uia file. Creation sets info.
- create(uipFile.completeBaseName(), uipFile.absolutePath());
- addPresentationNode(uipFile.absoluteFilePath());
+ // .uia not found, create a new one in the same uip filder. Creation sets file info.
+ create(uipInfo.absoluteFilePath().replace(QLatin1String(".uip"),
+ QLatin1String(".uia")));
+ addPresentationNode(uipInfo.absoluteFilePath());
updateDocPresentationId();
} else {
// .uia found, set project file info
@@ -350,7 +350,7 @@ QString ProjectFile::getPresentationId(const QString &src) const
}
// create the project .uia file
-void ProjectFile::create(const QString &projectName, const QString &projectPath)
+void ProjectFile::create(const QString &uiaPath)
{
QDomDocument doc;
doc.setContent(QStringLiteral("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
@@ -366,8 +366,6 @@ void ProjectFile::create(const QString &projectName, const QString &projectPath)
"</statemachine>"
"</application>"));
- QString uiaPath = projectPath + QStringLiteral("/") + projectName + QStringLiteral(".uia");
-
QFile file(uiaPath);
file.open(QIODevice::WriteOnly);
file.resize(0);
@@ -387,7 +385,7 @@ void ProjectFile::create(const QString &projectName, const QString &projectPath)
QString ProjectFile::createPreview()
{
CDoc *doc = g_StudioApp.GetCore()->GetDoc();
- QString uipPrvPath = doc->GetDocumentPath().GetAbsolutePath().toQString();
+ QString uipPrvPath = doc->GetDocumentPath();
// create a preview uip if doc modified
if (doc->IsModified()) {
uipPrvPath.replace(QLatin1String(".uip"), QLatin1String("_@preview@.uip"));
@@ -567,12 +565,10 @@ QString ProjectFile::ensureUniquePresentationId(const QString &id) const
// Get the path to the project root. If .uia doesn't exist, return path to current presentation.
QString ProjectFile::getProjectPath() const
{
- if (m_fileInfo.exists()) {
+ if (m_fileInfo.exists())
return m_fileInfo.path();
- } else {
- return QFileInfo(g_StudioApp.GetCore()->GetDoc()
- ->GetDocumentPath().GetAbsolutePath().toQString()).absolutePath();
- }
+ else
+ return QFileInfo(g_StudioApp.GetCore()->GetDoc()->GetDocumentPath()).absolutePath();
}
// Get the path to the project's .uia file. If .uia doesn't exist, return empty string.
diff --git a/src/Authoring/Studio/Application/ProjectFile.h b/src/Authoring/Studio/Application/ProjectFile.h
index 8dddd923..34093bb3 100644
--- a/src/Authoring/Studio/Application/ProjectFile.h
+++ b/src/Authoring/Studio/Application/ProjectFile.h
@@ -45,7 +45,7 @@ class ProjectFile : public QObject
public:
ProjectFile();
- void create(const QString &projectName, const QString &projectPath);
+ void create(const QString &uiaPath);
void ensureProjectFile();
void initProjectFile(const QString &presPath);
void loadSubpresentationsAndDatainputs(
diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp
index 1d6c07b1..77b0f271 100644
--- a/src/Authoring/Studio/Application/StudioApp.cpp
+++ b/src/Authoring/Studio/Application/StudioApp.cpp
@@ -196,7 +196,6 @@ int main(int argc, char *argv[])
#include "Qt3DSDMDataCore.h"
#include "IDirectoryWatchingSystem.h"
#include "ITickTock.h"
-#include "Qt3DSFileTools.h"
#include "foundation/Qt3DSLogging.h"
CStudioApp g_StudioApp;
@@ -299,28 +298,23 @@ bool CStudioApp::initInstance(const QCommandLineParser &parser)
QApplication::setOrganizationName("The Qt Company");
QApplication::setOrganizationDomain("qt.io");
QApplication::setApplicationName("Qt 3D Studio");
- QApplication::setApplicationVersion(
- QString::fromWCharArray(CStudioPreferences::GetVersionString().c_str()));
+ QApplication::setApplicationVersion(CStudioPreferences::GetVersionString());
qCInfo(qt3ds::TRACE_INFO) << "Studio: " << QApplication::applicationFilePath();
- qCInfo(qt3ds::TRACE_INFO) << "Version: "
- << CStudioPreferences::GetVersionString().GetCharStar();
+ qCInfo(qt3ds::TRACE_INFO) << "Version: " << CStudioPreferences::GetVersionString();
// Silent is ignored for everything but create
m_isSilent = parser.isSet("silent") && parser.isSet("create");
- CFilePath thePreferencesPath = CFilePath::GetUserApplicationDirectory();
- thePreferencesPath = CFilePath::CombineBaseAndRelative(
- thePreferencesPath, CFilePath(L"Qt3DSComposer\\Preferences.setting"));
- CPreferences::SetPreferencesFile(thePreferencesPath);
-
// Initialize help file paths
- m_helpFilePath = Qt3DSFile::GetApplicationDirectory().GetPath().toQString() +
- QStringLiteral("/../doc/qt3dstudio/qt3dstudio-index.html");
- m_gettingStartedFilePath = Qt3DSFile::GetApplicationDirectory().GetPath().toQString() +
- QStringLiteral("/../doc/qt3dstudio/getting-started.html");
+ m_helpFilePath = Qt3DSFile::GetApplicationDirectory()
+ + QStringLiteral("/../doc/qt3dstudio/qt3dstudio-index.html");
+ m_gettingStartedFilePath = Qt3DSFile::GetApplicationDirectory()
+ + QStringLiteral("/../doc/qt3dstudio/getting-started.html");
- CStudioPreferences::LoadPreferences();
+ QString thePreferencesPath = CFilePath::GetUserApplicationDirectory()
+ + QStringLiteral("/Qt3DSComposer/Preferences.setting");
+ CStudioPreferences::LoadPreferences(thePreferencesPath);
m_dialogs = new CDialogs(!m_isSilent);
@@ -403,8 +397,8 @@ bool CStudioApp::handleWelcomeRes(int res, bool recursive)
switch (res) {
case StudioTutorialWidget::createNewResult: {
if (PerformSavePrompt()) {
- Qt3DSFile theFile(m_dialogs->GetNewDocumentChoice(getMostRecentProjectParentDir()));
- if (theFile.GetPath() != "") {
+ QString theFile(m_dialogs->GetNewDocumentChoice(getMostRecentProjectParentDir()));
+ if (!theFile.isEmpty()) {
if (!m_core->OnNewDocument(theFile, true)) {
// Invalid filename, show a message box and the startup dialog
showInvalidFilenameWarning();
@@ -431,19 +425,19 @@ bool CStudioApp::handleWelcomeRes(int res, bool recursive)
QString theFile(QStringLiteral("."));
#ifndef Q_OS_MACOS
- filePath.setFile(Qt3DSFile::GetApplicationDirectory().GetPath().toQString() +
- QStringLiteral("/../examples/studio3d/SampleProject"));
+ filePath.setFile(Qt3DSFile::GetApplicationDirectory() +
+ QStringLiteral("/../examples/studio3d/SampleProject"));
if (!filePath.exists()) {
- filePath.setFile(Qt3DSFile::GetApplicationDirectory().GetPath().toQString() +
- QStringLiteral("/../examples/studio3d"));
+ filePath.setFile(Qt3DSFile::GetApplicationDirectory()
+ + QStringLiteral("/../examples/studio3d"));
#else
- filePath.setFile(Qt3DSFile::GetApplicationDirectory().GetPath().toQString() +
- QStringLiteral("/../../../../examples/studio3d/SampleProject"));
+ filePath.setFile(Qt3DSFile::GetApplicationDirectory()
+ + QStringLiteral("/../../../../examples/studio3d/SampleProject"));
if (!filePath.exists()) {
- filePath.setFile(Qt3DSFile::GetApplicationDirectory().GetPath().toQString() +
- QStringLiteral("/../../../../examples/studio3d"));
+ filePath.setFile(Qt3DSFile::GetApplicationDirectory()
+ + QStringLiteral("/../../../../examples/studio3d"));
#endif
if (!filePath.exists()) {
filePath.setFile(QStandardPaths::writableLocation(
@@ -564,8 +558,8 @@ bool CStudioApp::showStartupDialog()
break;
case CStartupDlg::EStartupChoice_NewDoc: {
- Qt3DSFile theFile = m_dialogs->GetNewDocumentChoice(getMostRecentProjectParentDir());
- if (theFile.GetPath() != "") {
+ QString theFile = m_dialogs->GetNewDocumentChoice(getMostRecentProjectParentDir());
+ if (!theFile.isEmpty()) {
if (!m_core->OnNewDocument(theFile, true)) {
// Invalid filename, show a message box and the dialog again
showInvalidFilenameWarning();
@@ -578,8 +572,8 @@ bool CStudioApp::showStartupDialog()
} break;
case CStartupDlg::EStartupChoice_OpenDoc: {
- Qt3DSFile theFile = m_dialogs->GetFileOpenChoice(getMostRecentDirectory());
- if (theFile.GetPath() != "") {
+ QString theFile = m_dialogs->GetFileOpenChoice(getMostRecentDirectory());
+ if (!theFile.isEmpty()) {
OnLoadDocument(theFile);
theReturn = true;
} else {
@@ -589,8 +583,8 @@ bool CStudioApp::showStartupDialog()
} break;
case CStartupDlg::EStartupChoice_OpenRecent: {
- Qt3DSFile theFile = theStartupDlg.GetRecentDoc();
- if (theFile.GetPath() != "") {
+ QString theFile = theStartupDlg.GetRecentDoc();
+ if (!theFile.isEmpty()) {
OnLoadDocument(theFile);
theReturn = true;
} else {
@@ -615,7 +609,7 @@ void CStudioApp::openApplication(const QString &inFilename)
{
m_fileOpenEvent = true;
QString loadFile = resolvePresentationFile(inFilename);
- OnLoadDocument(CString::fromQString(loadFile), true);
+ OnLoadDocument(loadFile, true);
}
#endif
@@ -664,7 +658,7 @@ bool CStudioApp::openAndRunApplication(const QString &inFilename)
bool theSuccess = false;
initCore();
// Load document. Upon failure, don't show startup dialog but exit immediately.
- if (OnLoadDocument(CString::fromQString(loadFile), false))
+ if (OnLoadDocument(loadFile, false))
theSuccess = runApplication();
return theSuccess;
}
@@ -676,13 +670,17 @@ bool CStudioApp::createAndRunApplication(const QString &filename, const QString
initCore();
// Append .uip if it is not included in the filename
QString actualFilename = filename;
- if (!actualFilename.endsWith(QStringLiteral(".uip")))
- actualFilename.append(QStringLiteral(".uip"));
+ if (!actualFilename.endsWith(QLatin1String(".uip")))
+ actualFilename.append(QLatin1String(".uip"));
+
+ QString actualFolder = folder;
+ if (!actualFolder.endsWith(QLatin1String("/")))
+ actualFilename.append(QLatin1String("/"));
+
// Create presentation
- Qt3DSFile theFile = Qt3DSFile(CString::fromQString(folder),
- CString::fromQString(actualFilename));
- if (theFile.GetPath() != "") {
- theSuccess = m_core->OnNewDocument(theFile, isNewProject, m_isSilent);
+ QString filePath = actualFolder + actualFilename;
+ if (!filePath.isEmpty()) {
+ theSuccess = m_core->OnNewDocument(filePath, isNewProject, m_isSilent);
if (!theSuccess)
return false;
@@ -731,8 +729,8 @@ struct SIImportFailedHandler : public Q3DStudio::IImportFailedHandler
: m_Dialogs(dialogs)
{
}
- void DisplayImportFailed(const QString &inDocumentPath,
- const QString &inDescription, bool inWarningsOnly) override
+ void DisplayImportFailed(const QString &inDocumentPath, const QString &inDescription,
+ bool inWarningsOnly) override
{
m_Dialogs.DisplayImportFailed(QUrl(inDocumentPath), inDescription, inWarningsOnly);
}
@@ -747,12 +745,12 @@ struct SIDeletingReferencedObjectHandler : public Q3DStudio::IDeletingReferenced
{
}
- void DisplayMessageBox(const Q3DStudio::CString &inDescription) override
+ void DisplayMessageBox(const QString &inDescription) override
{
QString theTitle = QObject::tr("Warning");
QString theMessage = QObject::tr("The following objects have action(s) that reference this "
"object and/or its descendants:\n%1\nPlease fix the "
- "action(s) accordingly.").arg(inDescription.toQString());
+ "action(s) accordingly.").arg(inDescription);
m_Dialogs.DisplayMessageBox(theTitle, theMessage, Qt3DSMessageBox::ICON_WARNING, false);
}
@@ -767,11 +765,9 @@ struct SIMoveRenameHandler : public Q3DStudio::IMoveRenameHandler
{
}
- void displayMessageBox(const Q3DStudio::CString &origName,
- const Q3DStudio::CString &newName) override
+ void displayMessageBox(const QString &origName, const QString &newName) override
{
- g_StudioApp.GetDialogs()->DisplayObjectRenamed(
- origName.toQString(), newName.toQString());
+ g_StudioApp.GetDialogs()->DisplayObjectRenamed(origName, newName);
}
};
@@ -817,7 +813,7 @@ void CStudioApp::handleMessageReceived(const QString &message, QObject *socket)
QFileInfo checkFile(checkPath);
QString docPath;
if (m_core)
- docPath = m_core->GetDoc()->GetDocumentPath().GetAbsolutePath().toQString();
+ docPath = m_core->GetDoc()->GetDocumentPath();
QFileInfo openFile(docPath);
if (!checkPath.isEmpty() && checkFile == openFile) {
lsocket->write(SharedTools::QtLocalPeer::acceptReply(),
@@ -1230,7 +1226,7 @@ bool CStudioApp::IsPlaying()
void CStudioApp::OnRevert()
{
if (!m_core->GetDoc()->IsModified() || m_dialogs->ConfirmRevert()) {
- Qt3DSFile theCurrentDoc = m_core->GetDoc()->GetDocumentPath();
+ QString theCurrentDoc = m_core->GetDoc()->GetDocumentPath();
OnLoadDocument(theCurrentDoc);
}
}
@@ -1239,16 +1235,16 @@ void CStudioApp::OnRevert()
/**
* Check to see if it is possible to perform a revert.
*/
-bool CStudioApp::CanRevert()
+bool CStudioApp::CanRevert() const
{
- return m_core->GetDoc()->IsModified() && m_core->GetDoc()->GetDocumentPath().GetPath() != "";
+ return m_core->GetDoc()->IsModified() && m_core->GetDoc()->IsValid();
}
//==============================================================================
/**
* Handles the recent list.
*/
-void CStudioApp::OnFileOpenRecent(const Qt3DSFile &inDocument)
+void CStudioApp::OnFileOpenRecent(const QString &inDocument)
{
if (PerformSavePrompt())
OnLoadDocument(inDocument);
@@ -1545,14 +1541,14 @@ bool CStudioApp::OnSave(bool autosave)
} else {
// Compose autosave filename (insert _autosave before extension)
QString autosaveFile = theCurrentDoc.GetPath().toQString();
- int insertionPoint = autosaveFile.lastIndexOf(QStringLiteral(".uip"));
+ int insertionPoint = autosaveFile.lastIndexOf(QLatin1String(".uip"));
autosaveFile.insert(insertionPoint, QStringLiteral("_autosave"));
if (autosave) {
// Set the copy flag to avoid changing actual document name & history
- m_core->OnSaveDocument(Qt3DSFile(CString::fromQString(autosaveFile)), true);
+ m_core->OnSaveDocument(autosaveFile, true);
} else {
- m_core->OnSaveDocument(theCurrentDoc);
+ m_core->OnSaveDocument(theCurrentDoc.GetAbsolutePath().toQString());
// Delete previous autosave file
QFile::remove(autosaveFile);
}
@@ -1570,8 +1566,8 @@ bool CStudioApp::OnSave(bool autosave)
*/
bool CStudioApp::OnSaveAs()
{
- Qt3DSFile theFile = m_dialogs->GetSaveAsChoice();
- if (theFile.GetPath() != "") {
+ QString theFile = m_dialogs->GetSaveAsChoice();
+ if (!theFile.isEmpty()) {
m_core->OnSaveDocument(theFile);
return true;
}
@@ -1587,8 +1583,8 @@ bool CStudioApp::OnSaveAs()
*/
bool CStudioApp::OnSaveCopy()
{
- Qt3DSFile theFile = m_dialogs->GetSaveAsChoice();
- if (theFile.GetPath() != "") {
+ QString theFile = m_dialogs->GetSaveAsChoice();
+ if (!theFile.isEmpty()) {
// Send in a "true" to the save function to indicate this is a copy
m_core->OnSaveDocument(theFile, true);
return true;
@@ -1617,25 +1613,24 @@ void CStudioApp::SetAutosaveInterval(int interval)
* @param inShowStartupDialogOnError true to show startup dialog if loading document is error
* @return true if loading was successful
*/
-bool CStudioApp::OnLoadDocument(const Qt3DSFile &inDocument, bool inShowStartupDialogOnError)
+bool CStudioApp::OnLoadDocument(const QString &inDocument, bool inShowStartupDialogOnError)
{
bool theLoadResult = false;
QString theLoadErrorParameter;
QString theErrorText;
- QString loadFile = resolvePresentationFile(inDocument.GetPath().toQString());
- Qt3DSFile loadDocument(CString::fromQString(loadFile));
+ QString loadFile = resolvePresentationFile(inDocument);
+ QFileInfo loadFileInfo(loadFile);
- m_core->GetDispatch()->FireOnProgressBegin(CString::fromQString(QObject::tr("Loading ")),
- loadDocument.GetName());
+ m_core->GetDispatch()->FireOnProgressBegin(QObject::tr("Loading "), inDocument);
// Make sure scene is visible
if (m_views)
m_views->getMainFrame()->showScene();
try {
- m_core->getProjectFile().initProjectFile(loadDocument.GetAbsolutePath().toQString());
- OnLoadDocumentCatcher(loadDocument);
- m_core->GetDispatch()->FireOnOpenDocument(loadDocument, true);
+ m_core->getProjectFile().initProjectFile(loadFile);
+ OnLoadDocumentCatcher(loadFile);
+ m_core->GetDispatch()->FireOnOpenDocument(loadFile, true);
// Loading was successful
theLoadResult = true;
} catch (ProjectFileNotFoundException &) {
@@ -1651,16 +1646,14 @@ bool CStudioApp::OnLoadDocument(const Qt3DSFile &inDocument, bool inShowStartupD
} catch (CLoadReferencedFileException &inError) {
// referenced files (e.g. Data Files) failed to load
theErrorText = tr("%1 failed to load due to invalid referenced file: %2.").arg(
- loadDocument.GetName().toQString(),
- Q3DStudio::CString(inError.GetFilePath()).toQString());
- const wchar_t *theDesc = inError.GetDescription();
- if (theDesc && wcslen(theDesc) > 0) {
+ loadFileInfo.completeBaseName(), inError.GetFilePath());
+ const QString theDesc = inError.GetDescription();
+ if (!theDesc.isEmpty()) {
// append any description is provided
- theErrorText += QStringLiteral("\n")
- + Q3DStudio::CString(inError.GetDescription()).toQString();
+ theErrorText += QStringLiteral("\n") + inError.GetDescription();
}
} catch (CIOException &) { // provide specific error message if possible
- if (loadDocument.Exists() == false)
+ if (!loadFileInfo.exists())
theLoadErrorParameter = tr(" does not exist.");
qCCritical(qt3ds::INTERNAL_ERROR)
<< "Failed to load document, IO error (file may be unreadable or nonexistent)";
@@ -1684,9 +1677,9 @@ bool CStudioApp::OnLoadDocument(const Qt3DSFile &inDocument, bool inShowStartupD
if (!theErrorText.isEmpty())
m_dialogs->DisplayKnownErrorDialog(theErrorText);
else
- m_dialogs->DisplayLoadingPresentationFailed(loadDocument, theLoadErrorParameter);
+ m_dialogs->DisplayLoadingPresentationFailed(loadFileInfo, theLoadErrorParameter);
- m_core->GetDispatch()->FireOnOpenDocument(loadDocument, false);
+ m_core->GetDispatch()->FireOnOpenDocument(loadFile, false);
// Show startup dialog
if (inShowStartupDialogOnError) {
@@ -1694,7 +1687,7 @@ bool CStudioApp::OnLoadDocument(const Qt3DSFile &inDocument, bool inShowStartupD
qApp->quit();
}
} else {
- m_dialogs->ResetSettings(loadDocument.GetPath());
+ m_dialogs->ResetSettings(loadFile);
m_core->getProjectFile().updateDocPresentationId();
m_core->getProjectFile().loadSubpresentationsAndDatainputs(m_subpresentations,
m_dataInputDialogItems);
@@ -1775,7 +1768,7 @@ QString CStudioApp::getMostRecentDirectory() const
CRecentItems *recentItems = m_views->getMainFrame()->GetRecentItems();
if (recentItems->GetItemCount() > 0) {
mostRecentDirectory
- = QFileInfo(recentItems->GetItem(0).GetAbsolutePath().toQString()).path();
+ = QFileInfo(recentItems->GetItem(0)).path();
}
}
return mostRecentDirectory.absoluteFilePath();
@@ -1787,7 +1780,7 @@ QString CStudioApp::getMostRecentProjectParentDir() const
if (m_views) {
CRecentItems *recentItems = m_views->getMainFrame()->GetRecentItems();
if (recentItems->GetItemCount() > 0) {
- QString mostRecentPresentation = recentItems->GetItem(0).GetAbsolutePath().toQString();
+ QString mostRecentPresentation = recentItems->GetItem(0);
QFileInfo projectFile(PresentationFile::findProjectFile(mostRecentPresentation));
if (!projectFile.exists())
projectFile.setFile(mostRecentPresentation);
@@ -1830,7 +1823,7 @@ bool CStudioApp::isQmlStream(const QString &fileName)
* Because of the nature of the error reporting, OnLoadDocument has to have
* a certain structure that limits it (C type variables, no object destructors).
*/
-void CStudioApp::OnLoadDocumentCatcher(const Qt3DSFile &inDocument)
+void CStudioApp::OnLoadDocumentCatcher(const QString &inDocument)
{
{
CDispatchDataModelNotificationScope __scope(*m_core->GetDispatch());
@@ -1846,8 +1839,8 @@ void CStudioApp::OnLoadDocumentCatcher(const Qt3DSFile &inDocument)
void CStudioApp::OnFileOpen()
{
if (PerformSavePrompt()) {
- Qt3DSFile theFile = m_dialogs->GetFileOpenChoice(getMostRecentDirectory());
- if (theFile.GetPath() != "")
+ QString theFile = m_dialogs->GetFileOpenChoice(getMostRecentDirectory());
+ if (!theFile.isEmpty())
OnLoadDocument(theFile);
}
}
@@ -1859,15 +1852,13 @@ void CStudioApp::OnFileOpen()
QString CStudioApp::OnProjectNew()
{
if (PerformSavePrompt()) {
- Qt3DSFile theFile = m_dialogs->GetNewDocumentChoice(getMostRecentProjectParentDir(), true);
- if (theFile.GetPath() != "") {
+ QString theFile = m_dialogs->GetNewDocumentChoice(getMostRecentProjectParentDir(), true);
+ if (!theFile.isEmpty()) {
if (!m_core->OnNewDocument(theFile, true))
showInvalidFilenameWarning();
- } else {
- return theFile.GetName().toQString();
}
}
- return QString();
+ return {};
}
/**
@@ -1877,8 +1868,8 @@ QString CStudioApp::OnProjectNew()
void CStudioApp::OnFileNew()
{
if (PerformSavePrompt()) {
- Qt3DSFile theFile = m_dialogs->GetNewDocumentChoice(getMostRecentDirectory(), false);
- if (!theFile.GetPath().IsEmpty() && !m_core->OnNewDocument(theFile, false))
+ QString theFile = m_dialogs->GetNewDocumentChoice(getMostRecentDirectory(), false);
+ if (!theFile.isEmpty() && !m_core->OnNewDocument(theFile, false))
showInvalidFilenameWarning();
}
}
@@ -1909,13 +1900,13 @@ void CStudioApp::OnAsynchronousCommand(CCmd *inCmd)
CMsgRouter::GetInstance()->SendCommand(inCmd, m_core);
}
-void CStudioApp::OnDisplayAppStatus(Q3DStudio::CString &inStatusMsg)
+void CStudioApp::OnDisplayAppStatus(const QString &inStatusMsg)
{
// Do nothing, it was used to show this in the status bar
}
-void CStudioApp::OnProgressBegin(const Q3DStudio::CString &inActionText,
- const Q3DStudio::CString &inAdditionalText)
+void CStudioApp::OnProgressBegin(const QString &inActionText,
+ const QString &inAdditionalText)
{
m_isOnProgress = true;
m_dialogs->DisplayProgressScreen(inActionText, inAdditionalText);
@@ -1939,9 +1930,9 @@ void CStudioApp::OnPasteFail()
m_dialogs->DisplayPasteFailed();
}
-void CStudioApp::OnBuildconfigurationFileParseFail(const Q3DStudio::CString &inMessage)
+void CStudioApp::OnBuildconfigurationFileParseFail(const QString &inMessage)
{
- m_dialogs->DisplayMessageBox(tr("Build Configurations Error"), inMessage.toQString(),
+ m_dialogs->DisplayMessageBox(tr("Build Configurations Error"), inMessage,
Qt3DSMessageBox::ICON_ERROR, false);
}
@@ -1955,24 +1946,17 @@ void CStudioApp::OnSaveFail(bool inKnownError)
m_dialogs->DisplayKnownErrorDialog(tr("Unknown error encountered while saving."));
}
-void CStudioApp::OnProjectVariableFail(const Q3DStudio::CString &inMessage)
+void CStudioApp::OnErrorFail(const QString &inText)
{
- m_dialogs->DisplayEnvironmentVariablesError(inMessage);
-}
-
-void CStudioApp::OnErrorFail(const Q3DStudio::CString &inText)
-{
- qCCritical(qt3ds::INTERNAL_ERROR) << inText.GetCharStar();
- m_dialogs->DisplayMessageBox(tr("Qt 3D Studio"), inText.toQString(),
- Qt3DSMessageBox::ICON_ERROR, false);
+ qCCritical(qt3ds::INTERNAL_ERROR) << inText;
+ m_dialogs->DisplayMessageBox(tr("Qt 3D Studio"), inText, Qt3DSMessageBox::ICON_ERROR, false);
}
-void CStudioApp::OnRefreshResourceFail(const Q3DStudio::CString &inResourceName,
- const Q3DStudio::CString &inDescription)
+void CStudioApp::OnRefreshResourceFail(const QString &inResourceName, const QString &inDescription)
{
qCCritical(qt3ds::INTERNAL_ERROR) << "Failed to refresh resource: "
- << inResourceName.GetCharStar();
- qCCritical(qt3ds::INTERNAL_ERROR) << inDescription.GetCharStar();
+ << inResourceName;
+ qCCritical(qt3ds::INTERNAL_ERROR) << inDescription;
m_dialogs->DisplayRefreshResourceFailed(inResourceName, inDescription);
}
@@ -1981,7 +1965,7 @@ void CStudioApp::OnNewPresentation()
m_core->GetDoc()->GetStudioSystem()->GetAnimationSystem()->SetAutoKeyframe(
CStudioPreferences::IsAutosetKeyframesOn());
qCInfo(qt3ds::TRACE_INFO) << "New Presentation: "
- << m_core->GetDoc()->GetDocumentPath().GetAbsolutePath().GetCharStar();
+ << m_core->GetDoc()->GetDocumentPath();
}
void CStudioApp::OnPresentationModifiedExternally()
@@ -1991,7 +1975,7 @@ void CStudioApp::OnPresentationModifiedExternally()
tr("This project has changed on disk. Do you want to reload it?"),
Qt3DSMessageBox::ICON_WARNING);
if (theUserChoice == IDYES) {
- Qt3DSFile theCurrentDoc = m_core->GetDoc()->GetDocumentPath();
+ QString theCurrentDoc = m_core->GetDoc()->GetDocumentPath();
OnLoadDocument(theCurrentDoc);
}
}
@@ -2008,7 +1992,7 @@ QString CStudioApp::getRenderableId(const QString &filePath) const
if (fi.isAbsolute()) {
renderablePath = filePath.mid(index);
} else {
- QFileInfo presFile(m_core->GetDoc()->GetDocumentPath().GetAbsolutePath().toQString());
+ QFileInfo presFile(m_core->GetDoc()->GetDocumentPath());
QDir presDir(presFile.absoluteDir());
QString checkFile = QDir::cleanPath(presDir.absoluteFilePath(filePath));
if (!QFileInfo(checkFile).exists()) {
diff --git a/src/Authoring/Studio/Application/StudioApp.h b/src/Authoring/Studio/Application/StudioApp.h
index 0af9bcdb..44187995 100644
--- a/src/Authoring/Studio/Application/StudioApp.h
+++ b/src/Authoring/Studio/Application/StudioApp.h
@@ -28,16 +28,13 @@
****************************************************************************/
#ifndef INCLUDED_STUDIO_APP_H
-#define INCLUDED_STUDIO_APP_H 1
-
-#pragma once
+#define INCLUDED_STUDIO_APP_H
#include "StudioObjectTypes.h"
#include "Qt3DSImportComposerTypes.h"
#include "Qt3DSDMComposerTypeDefinitions.h"
#include "DispatchListeners.h"
#include "Qt3DSDMHandles.h"
-#include "Qt3DSFileTools.h"
#include <QtWidgets/qapplication.h>
namespace Q3DStudio {
@@ -191,8 +188,8 @@ public:
void PlaybackRewind();
bool IsPlaying();
void OnRevert();
- bool CanRevert();
- void OnFileOpenRecent(const Qt3DSFile &inDocument);
+ bool CanRevert() const;
+ void OnFileOpenRecent(const QString &inDocument);
bool PerformSavePrompt();
void PlaybackStop();
bool isPlaybackPreviewOn() const;
@@ -207,8 +204,8 @@ public:
bool OnSave(bool autosave = false);
bool OnSaveAs();
bool OnSaveCopy();
- bool OnLoadDocument(const Qt3DSFile &inDocument, bool inShowStartupDialogOnError = true);
- void OnLoadDocumentCatcher(const Qt3DSFile &inLocation);
+ bool OnLoadDocument(const QString &inDocument, bool inShowStartupDialogOnError = true);
+ void OnLoadDocumentCatcher(const QString &inLocation);
void OnFileOpen();
QString OnProjectNew();
void OnFileNew();
@@ -231,20 +228,19 @@ public:
void OnAsynchronousCommand(CCmd *inCmd) override;
// CAppStatusListener
- void OnDisplayAppStatus(Q3DStudio::CString &inStatusMsg) override;
- void OnProgressBegin(const Q3DStudio::CString &inActionText,
- const Q3DStudio::CString &inAdditionalText) override;
+ void OnDisplayAppStatus(const QString &inStatusMsg) override;
+ void OnProgressBegin(const QString &inActionText,
+ const QString &inAdditionalText) override;
void OnProgressEnd() override;
// CFailListener
void OnAssetDeleteFail() override;
void OnPasteFail() override;
- void OnBuildconfigurationFileParseFail(const Q3DStudio::CString &inMessage) override;
+ void OnBuildconfigurationFileParseFail(const QString &inMessage) override;
void OnSaveFail(bool inKnownError) override;
- void OnProjectVariableFail(const Q3DStudio::CString &inMessage) override;
- void OnErrorFail(const Q3DStudio::CString &inText) override;
- void OnRefreshResourceFail(const Q3DStudio::CString &inResourceName,
- const Q3DStudio::CString &inDescription) override;
+ void OnErrorFail(const QString &inText) override;
+ void OnRefreshResourceFail(const QString &inResourceName,
+ const QString &inDescription) override;
void OnUndefinedDatainputsFail(
const QMultiMap<QString,
QPair<qt3dsdm::Qt3DSDMInstanceHandle,
diff --git a/src/Authoring/Studio/MainFrm.cpp b/src/Authoring/Studio/MainFrm.cpp
index 91e2186f..280cca70 100644
--- a/src/Authoring/Studio/MainFrm.cpp
+++ b/src/Authoring/Studio/MainFrm.cpp
@@ -113,7 +113,7 @@ CMainFrame::CMainFrame()
connect(m_ui->actionData_Inputs, &QAction::triggered, this, &CMainFrame::OnFileDataInputs);
connect(m_ui->action_Connect_to_Device, &QAction::triggered, this,
&CMainFrame::OnFileConnectToDevice);
- m_recentItems.reset(new CRecentItems(m_ui->menuRecent_Projects, 0));
+ m_recentItems.reset(new CRecentItems(m_ui->menuRecent_Projects));
connect(m_recentItems.data(), &CRecentItems::openRecent, this, &CMainFrame::OnFileOpenRecent);
connect(m_ui->action_Exit, &QAction::triggered, this, &CMainFrame::close);
@@ -355,11 +355,11 @@ void CMainFrame::OnCreate()
CDialogs *theDialogs = g_StudioApp.GetDialogs();
// this must NOT be in 'command line' mode
if (theDialogs) {
- Q3DStudio::CString theMostRecentOpen;
+ QString theMostRecentOpen;
if (m_recentItems && m_recentItems->GetItemCount() > 0)
- theMostRecentOpen = m_recentItems->GetItem(0).GetPath();
- if (theMostRecentOpen.IsEmpty()) // default to exe
- theMostRecentOpen = Qt3DSFile::GetApplicationDirectory().GetPath();
+ theMostRecentOpen = m_recentItems->GetItem(0);
+ if (theMostRecentOpen.isEmpty()) // default to exe
+ theMostRecentOpen = Qt3DSFile::GetApplicationDirectory();
theDialogs->ResetSettings(theMostRecentOpen);
}
@@ -1020,8 +1020,7 @@ void CMainFrame::OnPlaybackPreview(const QString &viewerExeName, bool remote)
{
if (remote && m_remoteDeploymentSender->isConnected()) {
g_StudioApp.GetCore()->GetDispatch()->FireOnProgressBegin(
- Q3DStudio::CString::fromQString(QObject::tr("Deploying to remote device...")),
- "");
+ QObject::tr("Deploying to remote device..."), {});
CPreviewHelper::OnDeploy(*m_remoteDeploymentSender);
g_StudioApp.GetCore()->GetDispatch()->FireOnProgressEnd();
} else {
@@ -1775,15 +1774,13 @@ void CMainFrame::OnFileConnectToDevice()
{
if (m_remoteDeploymentSender->isConnected()) {
g_StudioApp.GetCore()->GetDispatch()->FireOnProgressBegin(
- Q3DStudio::CString::fromQString(
- QObject::tr("Disconnecting from remote device...")), "");
+ QObject::tr("Disconnecting from remote device..."), {});
m_remoteDeploymentSender->disconnect();
} else {
QPair<QString, int> info = m_remoteDeploymentSender->initConnection();
if (!info.first.isEmpty()) {
g_StudioApp.GetCore()->GetDispatch()->FireOnProgressBegin(
- Q3DStudio::CString::fromQString(
- QObject::tr("Connecting to remote device...")), "");
+ QObject::tr("Connecting to remote device..."), {});
m_remoteDeploymentSender->connect(info);
} else {
m_ui->action_Connect_to_Device->setChecked(false);
@@ -1813,7 +1810,7 @@ void CMainFrame::RecheckSizingMode()
/**
* Callback when a Core is opened or fails to open.
*/
-void CMainFrame::OnOpenDocument(const Qt3DSFile &inFilename, bool inSucceeded)
+void CMainFrame::OnOpenDocument(const QString &inFilename, bool inSucceeded)
{
if (inSucceeded)
m_recentItems->AddRecentItem(inFilename);
@@ -1825,7 +1822,7 @@ void CMainFrame::OnOpenDocument(const Qt3DSFile &inFilename, bool inSucceeded)
/**
* Callback when a Core is saved or fails to save.
*/
-void CMainFrame::OnSaveDocument(const Qt3DSFile &inFilename, bool inSucceeded, bool inSaveCopy)
+void CMainFrame::OnSaveDocument(const QString &inFilename, bool inSucceeded, bool inSaveCopy)
{
if (!inSaveCopy)
OnOpenDocument(inFilename, inSucceeded);
@@ -1835,18 +1832,19 @@ void CMainFrame::OnSaveDocument(const Qt3DSFile &inFilename, bool inSucceeded, b
/**
* Callback for when a the doc gets a new path
*/
-void CMainFrame::OnDocumentPathChanged(const Qt3DSFile &inNewPath)
+void CMainFrame::OnDocumentPathChanged(const QString &inNewPath)
{
- QString theTitle = inNewPath.GetName().toQString();
+ QFileInfo info(inNewPath);
+ QString theTitle = info.fileName();
if (theTitle.isEmpty())
theTitle = QObject::tr("Untitled");
- theTitle = theTitle + " - " + QObject::tr("Qt 3D Studio");
+ theTitle.append(QStringLiteral(" - ") + QObject::tr("Qt 3D Studio"));
// TODO: Move this whole pile to the studio app
setWindowTitle(theTitle);
- if (inNewPath.Exists())
+ if (info.exists())
m_recentItems->AddRecentItem(inNewPath);
}
@@ -1972,8 +1970,7 @@ void CMainFrame::handleGeometryAndState(bool save)
void CMainFrame::handleRestart()
{
- QStringList presentationFile = QStringList(g_StudioApp.GetCore()->GetDoc()
- ->GetDocumentPath().GetAbsolutePath().toQString());
+ QStringList presentationFile = QStringList(g_StudioApp.GetCore()->GetDoc()->GetDocumentPath());
close();
QProcess::startDetached(qApp->arguments()[0], presentationFile);
}
diff --git a/src/Authoring/Studio/MainFrm.h b/src/Authoring/Studio/MainFrm.h
index b9e8dcf8..a51b4620 100644
--- a/src/Authoring/Studio/MainFrm.h
+++ b/src/Authoring/Studio/MainFrm.h
@@ -84,9 +84,9 @@ public:
void OnClosingPresentation() override;
// CFileOpenListener
- void OnOpenDocument(const Qt3DSFile &inFilename, bool inSucceeded) override;
- void OnSaveDocument(const Qt3DSFile &inFilename, bool inSucceeded, bool inSaveCopy) override;
- void OnDocumentPathChanged(const Qt3DSFile &inNewPath) override;
+ void OnOpenDocument(const QString &inFilename, bool inSucceeded) override;
+ void OnSaveDocument(const QString &inFilename, bool inSucceeded, bool inSaveCopy) override;
+ void OnDocumentPathChanged(const QString &inNewPath) override;
void RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, QWidget *actionParent);
void RecheckSizingMode();
diff --git a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp
index 82d14319..01b0f25d 100644
--- a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp
@@ -309,7 +309,7 @@ qt3dsdm::SValue SGuideInspectableImpl::GetWidth()
Q3DStudio::IDocumentEditor &SGuideInspectableImpl::Editor()
{
- return m_Editor.EnsureEditor(L"Set Property", __FILE__, __LINE__);
+ return m_Editor.EnsureEditor(QObject::tr("Set Property"), __FILE__, __LINE__);
}
void SGuideInspectableImpl::Commit()
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
index 3e884694..1f5a7d0c 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
@@ -362,8 +362,7 @@ void InspectorControlModel::setMatDatas(std::vector<Q3DStudio::CFilePath> &matDa
if (values.contains(QStringLiteral("presentation"))
&& values.contains(QStringLiteral("path"))
&& values.contains(QStringLiteral("filename"))) {
- if (values[QStringLiteral("presentation")]
- == doc->GetDocumentPath().GetAbsolutePath().toQString()) {
+ if (values[QStringLiteral("presentation")] == doc->GetDocumentPath()) {
if (!QFileInfo(values["path"]).exists()) {
const auto instance = sceneEditor->getMaterial(
Q3DStudio::CString::fromQString(
@@ -1554,7 +1553,7 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV
Q3DStudio::IStudioRenderer &theRenderer(g_StudioApp.getRenderer());
theRenderer.MakeContextCurrent();
- m_UpdatableEditor.EnsureEditor(L"Set Property", __FILE__, __LINE__)
+ m_UpdatableEditor.EnsureEditor(QObject::tr("Set Property"), __FILE__, __LINE__)
.SetInstancePropertyValue(instance, handle, v);
theRenderer.ReleaseContext();
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
index 7e93f2d9..153e2447 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
@@ -393,7 +393,7 @@ void InspectorControlView::showContextMenu(int x, int y, int handle, int instanc
void InspectorControlView::toggleMasterLink()
{
Q3DStudio::ScopedDocumentEditor editor(*g_StudioApp.GetCore()->GetDoc(),
- L"Link Property", __FILE__, __LINE__);
+ QObject::tr("Link Property"), __FILE__, __LINE__);
bool wasLinked = editor->IsPropertyLinked(m_instance, m_handle);
if (wasLinked)
@@ -650,10 +650,10 @@ bool InspectorControlView::toolTipsEnabled()
QString InspectorControlView::convertPathToProjectRoot(const QString &presentationPath)
{
QDir projDir(g_StudioApp.GetCore()->getProjectFile().getProjectPath());
- QFileInfo presentationFile(g_StudioApp.GetCore()->GetDoc()->GetDocumentPath()
- .GetAbsolutePath().toQString());
+ QFileInfo presentationFile(g_StudioApp.GetCore()->GetDoc()->GetDocumentPath());
QDir presentationDir(presentationFile.absolutePath());
QString absPath = presentationDir.absoluteFilePath(presentationPath);
+
return projDir.relativeFilePath(absPath);
}
diff --git a/src/Authoring/Studio/Palettes/Progress/ProgressView.cpp b/src/Authoring/Studio/Palettes/Progress/ProgressView.cpp
index a5ea681b..e6f57687 100644
--- a/src/Authoring/Studio/Palettes/Progress/ProgressView.cpp
+++ b/src/Authoring/Studio/Palettes/Progress/ProgressView.cpp
@@ -54,12 +54,12 @@ CProgressView::~CProgressView()
delete m_ui;
}
-void CProgressView::SetActionText(const Q3DStudio::CString &inActionText)
+void CProgressView::SetActionText(const QString &inActionText)
{
- m_ui->progressActionText->setText(inActionText.toQString());
+ m_ui->progressActionText->setText(inActionText);
}
-void CProgressView::SetAdditionalText(const Q3DStudio::CString &inAdditionalText)
+void CProgressView::SetAdditionalText(const QString &inAdditionalText)
{
- m_ui->progressAdditionalText->setText(inAdditionalText.toQString());
+ m_ui->progressAdditionalText->setText(inAdditionalText);
}
diff --git a/src/Authoring/Studio/Palettes/Progress/ProgressView.h b/src/Authoring/Studio/Palettes/Progress/ProgressView.h
index 5e3fe24c..384c72d7 100644
--- a/src/Authoring/Studio/Palettes/Progress/ProgressView.h
+++ b/src/Authoring/Studio/Palettes/Progress/ProgressView.h
@@ -55,8 +55,8 @@ public:
CProgressView(QWidget *parent = nullptr);
virtual ~CProgressView();
- void SetActionText(const Q3DStudio::CString &inActionText);
- void SetAdditionalText(const Q3DStudio::CString &inAdditionalText);
+ void SetActionText(const QString &inActionText);
+ void SetAdditionalText(const QString &inAdditionalText);
protected:
Ui::ProgressDlg *m_ui;
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp
index 218dc8df..6d35cd09 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp
+++ b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp
@@ -180,9 +180,8 @@ void ProjectFileSystemModel::updateReferences()
// Add current presentation to renderables list
renderableList.insert(doc->getPresentationId());
subpresentationRecord.push_back(
- SubPresentationRecord(
- QString(), doc->getPresentationId(),
- projectDir.relativeFilePath(doc->GetDocumentPath().GetPath().toQString())));
+ SubPresentationRecord({}, doc->getPresentationId(),
+ projectDir.relativeFilePath(doc->GetDocumentPath())));
auto addReferencesPresentation = [this, doc, &projectPath](const Q3DStudio::CString &str) {
addPathsToReferences(projectPath, doc->GetResolvedPathToDoc(str).toQString());
@@ -995,8 +994,7 @@ void ProjectFileSystemModel::asyncUpdateReferences()
bool ProjectFileSystemModel::isCurrentPresentation(const QString &path) const
{
- return path == g_StudioApp.GetCore()->GetDoc()->GetDocumentPath().GetPath().toQString()
- .replace(QLatin1String("\\"), QLatin1String("/"));
+ return path == g_StudioApp.GetCore()->GetDoc()->GetDocumentPath();
}
bool ProjectFileSystemModel::isInitialPresentation(const QString &path) const
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
index 15f0e4f4..bb1cac97 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
+++ b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
@@ -55,8 +55,7 @@ ProjectView::ProjectView(const QSize &preferredSize, QWidget *parent) : QQuickWi
, m_ProjectModel(new ProjectFileSystemModel(this))
, m_preferredSize(preferredSize)
{
- const QString theApplicationPath =
- Qt3DSFile::GetApplicationDirectory().GetPath().toQString();
+ const QString theApplicationPath = Qt3DSFile::GetApplicationDirectory();
m_defaultBehaviorDir = theApplicationPath + QStringLiteral("/Content/Behavior Library");
m_defaultEffectDir = theApplicationPath + QStringLiteral("/Content/Effect Library");
@@ -215,13 +214,13 @@ void ProjectView::OnNewPresentation()
rebuild();
}
-void ProjectView::OnOpenDocument(const Qt3DSFile &inFilename, bool inSucceeded)
+void ProjectView::OnOpenDocument(const QString &inFilename, bool inSucceeded)
{
Q_UNUSED(inFilename)
Q_UNUSED(inSucceeded)
}
-void ProjectView::OnSaveDocument(const Qt3DSFile &inFilename, bool inSucceeded, bool inSaveCopy)
+void ProjectView::OnSaveDocument(const QString &inFilename, bool inSucceeded, bool inSaveCopy)
{
Q_UNUSED(inFilename)
Q_UNUSED(inSucceeded)
@@ -229,7 +228,7 @@ void ProjectView::OnSaveDocument(const Qt3DSFile &inFilename, bool inSucceeded,
m_ProjectModel->asyncUpdateReferences();
}
-void ProjectView::OnDocumentPathChanged(const Qt3DSFile &inNewPath)
+void ProjectView::OnDocumentPathChanged(const QString &inNewPath)
{
Q_UNUSED(inNewPath)
}
@@ -285,8 +284,7 @@ void ProjectView::openPresentation(int row)
{
if (g_StudioApp.PerformSavePrompt()) {
const QString path = m_ProjectModel->filePath(row);
- const Qt3DSFile file(Q3DStudio::CString::fromQString(path));
- g_StudioApp.OnLoadDocument(file);
+ g_StudioApp.OnLoadDocument(path);
}
}
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.h b/src/Authoring/Studio/Palettes/Project/ProjectView.h
index fbd8ec10..96e170b5 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectView.h
+++ b/src/Authoring/Studio/Palettes/Project/ProjectView.h
@@ -98,9 +98,9 @@ public:
// CPresentationChangeListener
void OnNewPresentation() override;
// CFileOpenListener
- void OnOpenDocument(const Qt3DSFile &inFilename, bool inSucceeded) override;
- void OnSaveDocument(const Qt3DSFile &inFilename, bool inSucceeded, bool inSaveCopy) override;
- void OnDocumentPathChanged(const Qt3DSFile &inNewPath) override;
+ void OnOpenDocument(const QString &inFilename, bool inSucceeded) override;
+ void OnSaveDocument(const QString &inFilename, bool inSucceeded, bool inSaveCopy) override;
+ void OnDocumentPathChanged(const QString &inNewPath) override;
// IDataModelListener
void OnBeginDataModelNotifications() override;
void OnEndDataModelNotifications() override;
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.cpp
index 6525cce9..a0c4ee99 100644
--- a/src/Authoring/Studio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.cpp
+++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.cpp
@@ -56,7 +56,7 @@ void COffsetKeyframesCommandHelper::SetCommandTime(qt3dsdm::Qt3DSDMKeyframeHandl
long inTime)
{
// The DataModel system will take care of merging these under the hood.
- ENSURE_EDITOR(L"Set Keyframe Time").SetKeyframeTime(inKeyframe, inTime);
+ ENSURE_EDITOR(QObject::tr("Set Keyframe Time")).SetKeyframeTime(inKeyframe, inTime);
}
// equivalent to commit (onmouseup)
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp
index 9581265f..f646415d 100644
--- a/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp
+++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp
@@ -39,8 +39,8 @@ bool CPathTimelineItemBinding::IsExternalizeable()
void CPathTimelineItemBinding::Externalize()
{
- Q3DStudio::ScopedDocumentEditor(*m_TransMgr->GetDoc(), L"Externalize Path Buffer", __FILE__,
- __LINE__)
+ Q3DStudio::ScopedDocumentEditor(*m_TransMgr->GetDoc(), QObject::tr("Externalize Path Buffer"),
+ __FILE__, __LINE__)
->ExternalizePath(GetInstance());
}
@@ -52,7 +52,7 @@ bool CPathTimelineItemBinding::IsInternalizeable()
void CPathTimelineItemBinding::Internalize()
{
- Q3DStudio::ScopedDocumentEditor(*m_TransMgr->GetDoc(), L"Internalize Path Buffer", __FILE__,
- __LINE__)
+ Q3DStudio::ScopedDocumentEditor(*m_TransMgr->GetDoc(), QObject::tr("Internalize Path Buffer"),
+ __FILE__, __LINE__)
->InternalizePath(GetInstance());
}
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
index e4c7ce78..7fa26eaa 100644
--- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
+++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
@@ -195,7 +195,8 @@ void ToggleChildrenLock(Q3DStudio::ScopedDocumentEditor &scopedDocEditor,
void Qt3DSDMTimelineItemBinding::SetLocked(bool inLocked)
{
CDoc *theDoc = dynamic_cast<CDoc *>(g_StudioApp.GetCore()->GetDoc());
- Q3DStudio::ScopedDocumentEditor scopedDocEditor(*theDoc, L"SetLock", __FILE__, __LINE__);
+ Q3DStudio::ScopedDocumentEditor scopedDocEditor(*theDoc, QObject::tr("SetLock"), __FILE__,
+ __LINE__);
SDataModelSceneAsset sceneAsset = m_StudioSystem->GetClientDataModelBridge()->GetSceneAsset();
ToggleChildrenLock(scopedDocEditor, this, sceneAsset, inLocked);
@@ -767,8 +768,8 @@ void Qt3DSDMTimelineItemBinding::InsertKeyframe()
return;
TPropertyBindingMap::const_iterator theIter = m_PropertyBindingMap.begin();
- ScopedDocumentEditor editor(*g_StudioApp.GetCore()->GetDoc(), L"Insert Keyframe", __FILE__,
- __LINE__);
+ ScopedDocumentEditor editor(*g_StudioApp.GetCore()->GetDoc(), QObject::tr("Insert Keyframe"),
+ __FILE__, __LINE__);
for (; theIter != m_PropertyBindingMap.end(); ++theIter)
editor->KeyframeProperty(m_DataHandle, theIter->first, false);
}
@@ -779,13 +780,10 @@ void Qt3DSDMTimelineItemBinding::DeleteAllChannelKeyframes()
return;
CDoc *theDoc = m_TransMgr->GetDoc();
- Q3DStudio::ScopedDocumentEditor editor(*theDoc, L"Delete Channel Keyframes", __FILE__,
- __LINE__);
- for (TPropertyBindingMap::iterator theIter = m_PropertyBindingMap.begin(),
- theEnd = m_PropertyBindingMap.end();
- theIter != theEnd; ++theIter) {
- theIter->second->DeleteAllKeys();
- }
+ Q3DStudio::ScopedDocumentEditor editor(*theDoc, QObject::tr("Delete Channel Keyframes"),
+ __FILE__, __LINE__);
+ for (auto &kv : m_PropertyBindingMap)
+ kv.second->DeleteAllKeys();
}
IKeyframe *Qt3DSDMTimelineItemBinding::GetKeyframeByTime(long inTime) const
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp
index e241913d..73a7bb7d 100644
--- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp
+++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp
@@ -232,7 +232,8 @@ void Qt3DSDMTimelineItemProperty::DeleteAllKeys()
using namespace Q3DStudio;
- ScopedDocumentEditor editor(*m_TransMgr->GetDoc(), L"Delete All Keyframes", __FILE__, __LINE__);
+ ScopedDocumentEditor editor(*m_TransMgr->GetDoc(), QObject::tr("Delete All Keyframes"),
+ __FILE__, __LINE__);
for (size_t idx = 0, end = m_AnimationHandles.size(); idx < end; ++idx)
editor->DeleteAllKeyframes(m_AnimationHandles[idx]);
}
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp
index a4f27f6e..8c76046c 100644
--- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp
+++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp
@@ -174,7 +174,7 @@ void Qt3DSDMTimelineTimebar::OnBeginDrag()
void Qt3DSDMTimelineTimebar::OffsetTime(long inDiff)
{
if (m_DataHandle.Valid()) {
- ENSURE_EDITOR(L"Time Bar Move").OffsetTimeRange(m_DataHandle, inDiff);
+ ENSURE_EDITOR(QObject::tr("Time Bar Move")).OffsetTimeRange(m_DataHandle, inDiff);
m_TimelineTranslationManager->GetDoc()
->GetCore()
->GetDispatch()
@@ -185,7 +185,8 @@ void Qt3DSDMTimelineTimebar::OffsetTime(long inDiff)
void Qt3DSDMTimelineTimebar::ChangeTime(long inTime, bool inSetStart)
{
if (m_DataHandle.Valid()) {
- ENSURE_EDITOR(L"Time Bar Resize").ResizeTimeRange(m_DataHandle, inTime, inSetStart);
+ ENSURE_EDITOR(QObject::tr("Time Bar Resize")).ResizeTimeRange(m_DataHandle, inTime,
+ inSetStart);
m_TimelineTranslationManager->GetDoc()
->GetCore()
->GetDispatch()
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
index 13908be2..9dd937d5 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
@@ -554,7 +554,7 @@ void KeyframeManager::SetKeyframeInterpolation()
if (g_StudioApp.GetDialogs()->PromptForKeyframeInterpolation(theEaseIn, theEaseOut)) {
// Note: Having "editor" variable here is important as its destructor
// creates proper transaction
- Q3DStudio::ScopedDocumentEditor editor(*theDoc, L"Set Keyframe Interpolation",
+ Q3DStudio::ScopedDocumentEditor editor(*theDoc, QObject::tr("Set Keyframe Interpolation"),
__FILE__, __LINE__);
for (Keyframe *keyframe : qAsConst(m_selectedKeyframes)) {
Qt3DSDMTimelineKeyframe *theTimelineKeyframe = keyframe->binding;
@@ -586,7 +586,7 @@ void KeyframeManager::SetChangedKeyframes()
qt3dsdm::Qt3DSDMInstanceHandle selectedInstance = theDoc->GetSelectedInstance();
if (selectedInstance.Valid()) {
using namespace Q3DStudio;
- Q3DStudio::ScopedDocumentEditor editor(*theDoc, L"Set Changed Keyframes",
+ Q3DStudio::ScopedDocumentEditor editor(*theDoc, QObject::tr("Set Changed Keyframes"),
__FILE__, __LINE__);
CStudioSystem *theStudioSystem = theDoc->GetStudioSystem();
// Get all animated properties.
diff --git a/src/Authoring/Studio/PreviewHelper.cpp b/src/Authoring/Studio/PreviewHelper.cpp
index 852bb2a7..18bc6223 100644
--- a/src/Authoring/Studio/PreviewHelper.cpp
+++ b/src/Authoring/Studio/PreviewHelper.cpp
@@ -35,7 +35,6 @@
#include "Doc.h"
#include "StudioPreferences.h"
#include "StudioProjectSettings.h"
-#include "StudioProjectVariables.h"
#include "Core.h"
#include "Qt3DSFileTools.h"
@@ -100,7 +99,7 @@ void CPreviewHelper::PreviewViaConfig(Q3DStudio::CBuildConfiguration *inSelected
QString CPreviewHelper::getViewerFilePath(const QString &exeName)
{
using namespace Q3DStudio;
- CFilePath currentPath(Qt3DSFile::GetApplicationDirectory().GetAbsolutePath());
+ CFilePath currentPath(Qt3DSFile::GetApplicationDirectory());
CFilePath viewerDir(QApplication::applicationDirPath());
QString viewerFile;
@@ -159,7 +158,7 @@ void CPreviewHelper::cleanupProcess(QProcess *p, QString *docPath)
p->disconnect();
if (docPath->endsWith(QLatin1String("_@preview@.uia"))) {
QString uipPreviewPath = g_StudioApp.GetCore()->GetDoc()->GetDocumentPath()
- .GetAbsolutePath().toQString().replace(".uip", "_@preview@.uip");
+ .replace(QLatin1String(".uip"), QLatin1String("_@preview@.uip"));
QFile(uipPreviewPath).remove(); // remove uip preview (if exists)
QFile(*docPath).remove(); // remove uia preview
} else if (docPath->endsWith(QLatin1String("_@preview@.uip"))) {
@@ -215,94 +214,3 @@ void CPreviewHelper::DoPreviewViaConfig(Q3DStudio::CBuildConfiguration * /*inSel
}
}
}
-
-bool CPreviewHelper::viewerExists(const QString &exeName)
-{
- return QFileInfo(getViewerFilePath(exeName)).exists();
-}
-
-//=============================================================================
-/**
- * Interpret the string by resolving the variables.
- * @param inSourceString String to be interpreted
- */
-Q3DStudio::CString CPreviewHelper::InterpretString(Q3DStudio::CBuildConfiguration *inSelectedConfig,
- const Q3DStudio::CString &inDocumentFile,
- const Q3DStudio::CString &inSourceString)
-{
- Q3DStudio::CString theReturnString;
- long theStart = 0; // start index of string
- long theBeginIndex = 0; // index of '%'
- long theEndIndex = 0; // index of '%'
- while (Q3DStudio::CString::ENDOFSTRING != theEndIndex) {
- theBeginIndex = inSourceString.Find('%', theStart);
- if (Q3DStudio::CString::ENDOFSTRING != theBeginIndex) {
- theReturnString += inSourceString.Extract(theStart, theBeginIndex - theStart);
- // find the corresponding '%'
- theEndIndex = inSourceString.Find('%', theBeginIndex + 1);
- if (Q3DStudio::CString::ENDOFSTRING != theEndIndex) {
- // first, resolve the variable by the toolbar selection
- Q3DStudio::CString theVariable =
- inSourceString.Extract(theBeginIndex + 1, theEndIndex - theBeginIndex - 1);
- Q3DStudio::CString theResolvedVariable;
- bool theHasResolved = ResolveVariable(inSelectedConfig, inDocumentFile, theVariable,
- theResolvedVariable);
-
- if (theHasResolved) {
- theReturnString += theResolvedVariable;
- } else {
- theReturnString += "_NULL_";
- }
- theStart = theEndIndex + 1;
- } else
- theReturnString += inSourceString.Extract(theBeginIndex);
- } else {
- theEndIndex = theBeginIndex;
- theReturnString += inSourceString.Extract(theStart);
- }
- }
-
- return theReturnString;
-}
-
-//==============================================================================
-/**
- * Resolves the passed in variable and write out the resolved value if it exists
- * in the current selected build configuration.
- * @param inVariable the environment to be resolved
- * @param outValue the string to receive the resolved value
- * @return true if the variable exists, else false
- */
-//==============================================================================
-bool CPreviewHelper::ResolveVariable(Q3DStudio::CBuildConfiguration *inSelectedConfig,
- const Q3DStudio::CString &inDocumentFile,
- const Q3DStudio::CString &inVariable,
- Q3DStudio::CString &outValue)
-{
- Q3DStudio::CString theReturnStr;
- bool theHasResolved = false;
-
- // Handle special variable
- if (inVariable == "BUILDFILE") {
- if (inSelectedConfig) {
- theReturnStr = inSelectedConfig->GetPath();
- theHasResolved = true;
- }
- } else if (inVariable == "UIPFILE") {
- theReturnStr = inDocumentFile;
- theHasResolved = true;
- }
-
- if (!theHasResolved) {
- Q3DStudio::CString theValue = CStudioPreferences::GetPreviewProperty(inVariable);
- if (theValue != "") {
- theReturnStr = theValue;
- theHasResolved = true;
- }
- }
-
- if (theHasResolved)
- outValue = InterpretString(inSelectedConfig, inDocumentFile, theReturnStr);
-
- return theHasResolved;
-}
diff --git a/src/Authoring/Studio/PreviewHelper.h b/src/Authoring/Studio/PreviewHelper.h
index 19d23cb0..0424da91 100644
--- a/src/Authoring/Studio/PreviewHelper.h
+++ b/src/Authoring/Studio/PreviewHelper.h
@@ -72,15 +72,8 @@ public:
const QString &inDocumentFile,
EExecMode inMode, const QString &viewerExeName,
RemoteDeploymentSender *project = 0);
- static bool viewerExists(const QString &exeName);
protected:
- static Q3DStudio::CString InterpretString(Q3DStudio::CBuildConfiguration *inSelectedConfig,
- const Q3DStudio::CString &inDocumentFile,
- const Q3DStudio::CString &inSourceString);
- static bool ResolveVariable(Q3DStudio::CBuildConfiguration *inSelectedConfig,
- const Q3DStudio::CString &inDocumentFile,
- const Q3DStudio::CString &inVariable, Q3DStudio::CString &outValue);
static QString getViewerFilePath(const QString &exeName);
static void cleanupProcess(QProcess *p, QString *docPath);
};
diff --git a/src/Authoring/Studio/Render/StudioRenderer.cpp b/src/Authoring/Studio/Render/StudioRenderer.cpp
index 1f78f2bc..61af4114 100644
--- a/src/Authoring/Studio/Render/StudioRenderer.cpp
+++ b/src/Authoring/Studio/Render/StudioRenderer.cpp
@@ -783,7 +783,7 @@ struct SRendererImpl : public IStudioRenderer,
m_Translation->PickRulers(inPoint);
if (pickResult.hasValue()) {
Q3DStudio::IDocumentEditor &docEditor(
- m_UpdatableEditor.EnsureEditor(L"Create Guide",
+ m_UpdatableEditor.EnsureEditor(QObject::tr("Create Guide"),
__FILE__, __LINE__));
Qt3DSDMGuideHandle newGuide = docEditor.CreateGuide(*pickResult);
m_PickResult = SStudioPickValue(newGuide);
diff --git a/src/Authoring/Studio/Render/StudioRendererTranslation.cpp b/src/Authoring/Studio/Render/StudioRendererTranslation.cpp
index c214dfea..81d0d736 100644
--- a/src/Authoring/Studio/Render/StudioRendererTranslation.cpp
+++ b/src/Authoring/Studio/Render/StudioRendererTranslation.cpp
@@ -3812,7 +3812,8 @@ void STranslation::PerformGuideDrag(Qt3DSDMGuideHandle inGuide, CPt inPoint,
break;
break;
}
- inEditor.EnsureEditor(L"Drag Guide", __FILE__, __LINE__).UpdateGuide(inGuide, theInfo);
+ inEditor.EnsureEditor(QObject::tr("Drag Guide"), __FILE__, __LINE__).UpdateGuide(inGuide,
+ theInfo);
inEditor.FireImmediateRefresh(qt3dsdm::Qt3DSDMInstanceHandle());
}
@@ -3835,7 +3836,7 @@ void STranslation::CheckGuideInPresentationRect(Qt3DSDMGuideHandle inGuide,
}
if (!inPresentation)
- inEditor.EnsureEditor(L"Delete Guide", __FILE__, __LINE__).DeleteGuide(inGuide);
+ inEditor.EnsureEditor(QObject::tr("Delete Guide"), __FILE__, __LINE__).DeleteGuide(inGuide);
}
void STranslation::PerformPathDrag(qt3ds::studio::SPathPick &inPathPick, CPt inOriginalCoords,
@@ -3910,8 +3911,8 @@ void STranslation::PerformPathDrag(qt3ds::studio::SPathPick &inPathPick, CPt inO
}
theCurrentValue[0] += theDiff.x;
theCurrentValue[1] += theDiff.y;
- Q3DStudio::IDocumentEditor &theEditor =
- inEditor.EnsureEditor(L"Anchor Point Drag", __FILE__, __LINE__);
+ Q3DStudio::IDocumentEditor &theEditor = inEditor.EnsureEditor(
+ QObject::tr("Anchor Point Drag"), __FILE__, __LINE__);
switch (inPathPick.m_Property) {
case SPathPick::Anchor:
theEditor.SetInstancePropertyValue(theAnchorHandle, thePosProperty,
diff --git a/src/Authoring/Studio/Render/StudioRendererTranslation.h b/src/Authoring/Studio/Render/StudioRendererTranslation.h
index 9bace2e9..c59c5480 100644
--- a/src/Authoring/Studio/Render/StudioRendererTranslation.h
+++ b/src/Authoring/Studio/Render/StudioRendererTranslation.h
@@ -555,7 +555,7 @@ namespace studio {
void SetPosition(const QT3DSVec3 &inPosition, CUpdateableDocumentEditor &inEditor)
{
- inEditor.EnsureEditor(L"Set Position", __FILE__, __LINE__)
+ inEditor.EnsureEditor(QObject::tr("Set Position"), __FILE__, __LINE__)
.SetInstancePropertyValue(m_Doc.GetSelectedInstance(),
m_ObjectDefinitions.m_Node.m_Position,
ToDataModel(inPosition));
@@ -563,7 +563,7 @@ namespace studio {
}
void SetRotation(const QT3DSVec3 &inRotation, CUpdateableDocumentEditor &inEditor)
{
- inEditor.EnsureEditor(L"Set Rotation", __FILE__, __LINE__)
+ inEditor.EnsureEditor(QObject::tr("Set Rotation"), __FILE__, __LINE__)
.SetInstancePropertyValue(m_Doc.GetSelectedInstance(),
m_ObjectDefinitions.m_Node.m_Rotation,
ToDataModelRotation(inRotation));
@@ -571,7 +571,7 @@ namespace studio {
}
void SetScale(const QT3DSVec3 &inScale, CUpdateableDocumentEditor &inEditor)
{
- inEditor.EnsureEditor(L"Set Scale", __FILE__, __LINE__)
+ inEditor.EnsureEditor(QObject::tr("Set Scale"), __FILE__, __LINE__)
.SetInstancePropertyValue(m_Doc.GetSelectedInstance(),
m_ObjectDefinitions.m_Node.m_Scale, ToDataModel(inScale));
inEditor.FireImmediateRefresh(m_Doc.GetSelectedInstance());
diff --git a/src/Authoring/Studio/UI/RecentItems.cpp b/src/Authoring/Studio/UI/RecentItems.cpp
index ef6546f4..d0983f32 100644
--- a/src/Authoring/Studio/UI/RecentItems.cpp
+++ b/src/Authoring/Studio/UI/RecentItems.cpp
@@ -27,26 +27,17 @@
**
****************************************************************************/
-#include "Qt3DSCommonPrecompile.h"
-
#include "RecentItems.h"
-#include "Preferences.h"
+#include "StudioPreferences.h"
#include <QtWidgets/qmenu.h>
+#include <QtCore/qfileinfo.h>
-const Q3DStudio::CString CRecentItems::RECENTITEM_KEY = "RecentItem";
-const Q3DStudio::CString CRecentItems::RECENTIMPORT_KEY = "RecentImport";
-const Q3DStudio::CString CRecentItems::RECENTITEM_VALID = "RecentValid";
+const int CRecentItems::MAX_ITEMS = 10; // maximum allowed number of recent items
-CRecentItems::CRecentItems(QMenu *inMenuID, long inCommandID, Q3DStudio::CString inPreferenceKey)
+CRecentItems::CRecentItems(QMenu *inMenuID)
{
- Q_UNUSED(inCommandID)
-
m_Menu = inMenuID;
- m_ValidItems = 10;
- m_PreferenceKey = inPreferenceKey;
-
- connect(m_Menu, &QMenu::aboutToShow, this, &CRecentItems::handleAboutToShow);
ReconstructList();
}
@@ -55,86 +46,67 @@ CRecentItems::~CRecentItems()
{
}
-void CRecentItems::AddRecentItem(const Qt3DSFile &inItem)
+void CRecentItems::AddRecentItem(const QString &inItem)
{
- RemoveRecentItem(inItem);
+ RemoveRecentItem(inItem, false);
m_RecentItems.insert(m_RecentItems.begin(), inItem);
- while (m_RecentItems.size() > 10)
+ while (m_RecentItems.size() > MAX_ITEMS)
m_RecentItems.pop_back();
RebuildList();
}
-void CRecentItems::RemoveRecentItem(const Qt3DSFile &inItem)
+void CRecentItems::RemoveRecentItem(const QString &inItem, bool rebuild)
{
- TFileList::iterator thePos = m_RecentItems.begin();
+ auto thePos = m_RecentItems.begin();
for (; thePos != m_RecentItems.end(); ++thePos) {
- if ((*thePos) == inItem) {
+ if (*thePos == inItem) {
m_RecentItems.erase(thePos);
break;
}
}
- RebuildList();
+ if (rebuild)
+ RebuildList();
}
+// load the recent items from the preferences file to m_RecentItems
void CRecentItems::ReconstructList()
{
- ClearMenu();
+ m_Menu->clear();
m_RecentItems.clear();
- CPreferences thePrefs = CPreferences::GetUserPreferences();
+ int numRecentItems = CStudioPreferences::getNumRecentItems();
+ if (numRecentItems > MAX_ITEMS)
+ numRecentItems = MAX_ITEMS;
- m_ValidItems = thePrefs.GetLongValue(RECENTITEM_VALID, m_ValidItems);
-
- for (long theIndex = 0; theIndex < (m_ValidItems > 10 ? 10 : m_ValidItems); ++theIndex) {
- Q3DStudio::CString theKey;
- theKey.Format(_LSTR("%ls%d"), static_cast<const wchar_t *>(m_PreferenceKey), theIndex);
-
- Q3DStudio::CString theFilename = thePrefs.GetStringValue(theKey, "");
- if (theFilename != "") {
- Qt3DSFile theFile(theFilename);
- if (theFile.Exists())
- m_RecentItems.push_back(theFile);
- }
+ for (int i = 0; i < numRecentItems; ++i) {
+ QString theFile = CStudioPreferences::getRecentItem(i);
+ if (!theFile.isEmpty() && QFileInfo(theFile).exists())
+ m_RecentItems.push_back(theFile);
}
}
+// save the recent items from m_RecentItems to the preferences file. Also recreate the menu.
void CRecentItems::RebuildList()
{
- ClearMenu();
-
- CPreferences thePrefs = CPreferences::GetUserPreferences();
- thePrefs.SetLongValue(RECENTITEM_VALID, GetItemCount());
- TFileList::iterator thePos = m_RecentItems.begin();
- for (long theIndex = 0; thePos != m_RecentItems.end(); ++thePos, ++theIndex) {
- Qt3DSFile theFile = *thePos;
- if (theFile.Exists()) {
- QAction *act = m_Menu->addAction(theFile.GetName().toQString(),
- this, &CRecentItems::onTriggerRecent);
- act->setData(static_cast<int>(theIndex));
-
- Q3DStudio::CString theKey;
- theKey.Format(_LSTR("%ls%d"), static_cast<const wchar_t *>(m_PreferenceKey), theIndex);
-
- thePrefs.SetStringValue(theKey, (*thePos).GetAbsolutePath());
- }
- }
-}
+ m_Menu->clear();
-void CRecentItems::handleAboutToShow()
-{
- RebuildList();
-}
+ CStudioPreferences::setNumRecentItems(GetItemCount());
-void CRecentItems::ClearMenu()
-{
- m_Menu->clear();
+ for (int i = 0; i < m_RecentItems.size(); ++i) {
+ const QString &item_i = m_RecentItems.at(i);
+ if (QFileInfo(item_i).exists()) {
+ QAction *act = m_Menu->addAction(item_i, this, &CRecentItems::onTriggerRecent);
+ act->setData(i);
+ CStudioPreferences::setRecentItem(i, item_i);
+ }
+ }
}
-Qt3DSFile CRecentItems::GetItem(long inIndex)
+QString CRecentItems::GetItem(long inIndex) const
{
return m_RecentItems.at(inIndex);
}
diff --git a/src/Authoring/Studio/UI/RecentItems.h b/src/Authoring/Studio/UI/RecentItems.h
index db4d62f5..9557353f 100644
--- a/src/Authoring/Studio/UI/RecentItems.h
+++ b/src/Authoring/Studio/UI/RecentItems.h
@@ -33,53 +33,36 @@
#pragma once
#include <QObject>
-
-#include "Qt3DSString.h"
-#include "Qt3DSFile.h"
-
#include <vector>
-class Qt3DSFile;
-
QT_FORWARD_DECLARE_CLASS(QMenu)
class CRecentItems : public QObject
{
Q_OBJECT
- typedef std::vector<Qt3DSFile> TFileList;
-
public:
- static const Q3DStudio::CString RECENTITEM_KEY;
- static const Q3DStudio::CString RECENTIMPORT_KEY;
- static const Q3DStudio::CString RECENTITEM_VALID;
+ static const int MAX_ITEMS;
Q_SIGNALS:
void openRecent(int index);
public:
- CRecentItems(QMenu *inMenu, long inCommandID,
- Q3DStudio::CString inPreferenceKey = RECENTITEM_KEY);
+ CRecentItems(QMenu *inMenu);
virtual ~CRecentItems();
- void AddRecentItem(const Qt3DSFile &inItem);
- void RemoveRecentItem(const Qt3DSFile &inItem);
+ void AddRecentItem(const QString &inItem);
+ void RemoveRecentItem(const QString &inItem, bool rebuild = true);
- Qt3DSFile GetItem(long inIndex);
+ QString GetItem(long inIndex) const;
long GetItemCount() const { return (long)m_RecentItems.size(); }
protected:
- void ClearMenu();
void ReconstructList();
void RebuildList();
- void SaveRecentList();
- void handleAboutToShow();
- TFileList m_RecentItems;
+ std::vector<QString> m_RecentItems;
- long m_CommandID;
- long m_ValidItems;
QMenu *m_Menu;
- Q3DStudio::CString m_PreferenceKey;
private Q_SLOTS:
void onTriggerRecent();
diff --git a/src/Authoring/Studio/UI/StartupDlg.cpp b/src/Authoring/Studio/UI/StartupDlg.cpp
index 53ccd6f7..c5cc4c47 100644
--- a/src/Authoring/Studio/UI/StartupDlg.cpp
+++ b/src/Authoring/Studio/UI/StartupDlg.cpp
@@ -44,7 +44,6 @@
CStartupDlg::CStartupDlg(QWidget *pParent)
: QDialog(pParent, Qt::MSWindowsFixedSizeDialogHint)
, m_Choice(EStartupChoice_Invalid)
- , m_RecentDocSelected("")
, m_ui(new Ui::StartupDlg)
, m_palette(nullptr)
{
@@ -97,8 +96,7 @@ void CStartupDlg::OnInitDialog()
connect(m_ui->openDocument, &ClickableLabel::clicked, this, &CStartupDlg::OnOpenDocClicked);
// Load the product version
- m_ProductVersionStr = QStringLiteral("Qt 3D Studio v")
- + CStudioPreferences::GetVersionString().toQString();
+ m_ProductVersionStr = QStringLiteral("Qt 3D Studio v") + CStudioPreferences::GetVersionString();
m_ui->versionStr->setText(m_ProductVersionStr);
// Populate the recent document list
@@ -111,10 +109,9 @@ void CStartupDlg::OnInitDialog()
if (m_RecentDocs.size() > theIndex) {
// Set the name
- recent->setText(m_RecentDocs[theIndex].GetName().toQString());
+ recent->setText(QFileInfo(m_RecentDocs[theIndex]).fileName());
// Set path and date to tooltip
- QFileInfo thePath(m_RecentDocs[theIndex].GetAbsolutePath().toQString());
- QString toolTip = thePath.absoluteDir().path();
+ QString toolTip = m_RecentDocs[theIndex];
toolTip.append(QStringLiteral("\n"));
toolTip.append(GetFileTimeReadable(m_RecentDocs[theIndex]));
recent->setToolTip(toolTip);
@@ -125,7 +122,7 @@ void CStartupDlg::OnInitDialog()
}
}
-void CStartupDlg::AddRecentItem(const Qt3DSFile &inRecentItem)
+void CStartupDlg::AddRecentItem(const QString &inRecentItem)
{
m_RecentDocs.push_back(inRecentItem);
}
@@ -135,7 +132,7 @@ CStartupDlg::EStartupChoice CStartupDlg::GetChoice()
return m_Choice;
}
-Qt3DSFile CStartupDlg::GetRecentDoc() const
+QString CStartupDlg::GetRecentDoc() const
{
return m_RecentDocSelected;
}
diff --git a/src/Authoring/Studio/UI/StartupDlg.h b/src/Authoring/Studio/UI/StartupDlg.h
index bab905c2..ceb38e7b 100644
--- a/src/Authoring/Studio/UI/StartupDlg.h
+++ b/src/Authoring/Studio/UI/StartupDlg.h
@@ -99,14 +99,14 @@ private:
EStartupChoice m_Choice = EStartupChoice_Invalid;
// Recent Docs
- std::vector<Qt3DSFile> m_RecentDocs;
- Qt3DSFile m_RecentDocSelected;
+ std::vector<QString> m_RecentDocs;
+ QString m_RecentDocSelected = {};
public:
void OnInitDialog();
- void AddRecentItem(const Qt3DSFile &inRecentItem);
+ void AddRecentItem(const QString &inRecentItem);
EStartupChoice GetChoice();
- Qt3DSFile GetRecentDoc() const;
+ QString GetRecentDoc() const;
private:
QScopedPointer<Ui::StartupDlg> m_ui;
diff --git a/src/Authoring/Studio/Workspace/Dialogs.cpp b/src/Authoring/Studio/Workspace/Dialogs.cpp
index 1b2b374e..e1737fb4 100644
--- a/src/Authoring/Studio/Workspace/Dialogs.cpp
+++ b/src/Authoring/Studio/Workspace/Dialogs.cpp
@@ -299,15 +299,15 @@ Qt3DSFile CDialogs::GetExportChoice(const Q3DStudio::CString &, const Q3DStudio:
/**
* Notify that we are unable to refresh the resource.
*/
-void CDialogs::DisplayRefreshResourceFailed(const Q3DStudio::CString &inResourceName,
- const Q3DStudio::CString &inDescription)
+void CDialogs::DisplayRefreshResourceFailed(const QString &inResourceName,
+ const QString &inDescription)
{
QString theTitle = QObject::tr("Refresh File Error");
QString theText = QObject::tr("Studio was unable to refresh the resource '%1'.\n")
- .arg(inResourceName.toQString());
+ .arg(inResourceName);
- if (!inDescription.IsEmpty())
- theText += inDescription.toQString();
+ if (!inDescription.isEmpty())
+ theText += inDescription;
if (m_ShowGUI) {
Qt3DSMessageBox::Show(theTitle, theText, Qt3DSMessageBox::ICON_WARNING, false,
@@ -498,8 +498,7 @@ QList<QUrl> CDialogs::SelectAssets(QString &outPath,
files = fd.selectedUrls();
QString newOutPath = fd.directory().absolutePath();
QString contentPath = QDir::fromNativeSeparators(
- Qt3DSFile::GetApplicationDirectory().GetPath().toQString()
- + QStringLiteral("/Content"));
+ Qt3DSFile::GetApplicationDirectory() + QStringLiteral("/Content"));
if (assetType != Q3DStudio::DocumentEditorFileType::Unknown
|| (assetType == Q3DStudio::DocumentEditorFileType::Unknown
@@ -527,20 +526,20 @@ QString CDialogs::defaultDirForUrl(const QUrl &url)
return defaultDir;
}
-//==============================================================================
/**
- * Notify the user that the presentation we tried to load has failed.
- * @param inPresentation The AKFile that we failed to load.
+ * Notify the user that the presentation we tried to load has failed.
+ * @param loadFileInfo QFileInfo for the failing file
+ * @param errrorText error message
*/
-void CDialogs::DisplayLoadingPresentationFailed(const Qt3DSFile &inPresentation,
- const QString &inErrorText)
+void CDialogs::DisplayLoadingPresentationFailed(const QFileInfo &loadFileInfo,
+ const QString &errorText)
{
- QString theErrorMessage = inPresentation.GetName().toQString();
+ QString theErrorMessage = loadFileInfo.fileName();
- if (inErrorText.isEmpty())
+ if (errorText.isEmpty())
theErrorMessage += QObject::tr(" failed to load.");
else
- theErrorMessage += inErrorText;
+ theErrorMessage += errorText;
QString theErrorTitle = QObject::tr("Open File Error");
@@ -1020,17 +1019,14 @@ CDialogs::ESavePromptResult CDialogs::PromptForSave()
*/
QString CDialogs::GetSaveAsChoice(const QString &inDialogTitle, bool isProject)
{
- QFileInfo theFile;
- QString theFileExt;
QString projPath(QDir::cleanPath(g_StudioApp.GetCore()->getProjectFile().getProjectPath()));
- QString theFilename
- = g_StudioApp.GetCore()->GetDoc()->GetDocumentPath().GetAbsolutePath().toQString();
+ QString theFilename = g_StudioApp.GetCore()->GetDoc()->GetDocumentPath();
if (theFilename.isEmpty() || isProject)
theFilename = QObject::tr("Untitled");
- theFileExt = QStringLiteral(".uip");
+ QString theFileExt = QStringLiteral(".uip");
QFileDialog theFileDlg;
theFileDlg.setOption(QFileDialog::DontConfirmOverwrite);
@@ -1063,7 +1059,7 @@ QString CDialogs::GetSaveAsChoice(const QString &inDialogTitle, bool isProject)
}
bool theShowDialog = true;
-
+ QString theFile = {};
while (theShowDialog && theFileDlg.exec()) {
theShowDialog = false;
QString selectedName = theFileDlg.selectedFiles().front();
@@ -1081,15 +1077,15 @@ QString CDialogs::GetSaveAsChoice(const QString &inDialogTitle, bool isProject)
selectedName = projPath + QStringLiteral("/presentations/") + fi.fileName();
}
- theFile = QFileInfo(selectedName);
-
- m_LastSaveFile = theFile.absoluteFilePath();
+ theFile = selectedName;
+ m_LastSaveFile = selectedName;
// New directory is only created when creating a new project. When doing a "save as"
// or "save copy", a new directory is not created.
if (isProject) {
Q3DStudio::CFilePath theFinalDir;
Q3DStudio::CFilePath theFinalDoc;
- g_StudioApp.GetCore()->GetCreateDirectoryFileName(theFile, theFinalDir, theFinalDoc);
+ g_StudioApp.GetCore()->GetCreateDirectoryFileName(selectedName,
+ theFinalDir, theFinalDoc);
// Update last save file to final doc
m_LastSaveFile = theFinalDoc.absoluteFilePath();
@@ -1103,7 +1099,7 @@ QString CDialogs::GetSaveAsChoice(const QString &inDialogTitle, bool isProject)
auto result = QMessageBox::question(nullptr, theTitle, theString);
if (result != QMessageBox::Yes) {
// Reset the file and show the file dialog again
- theFile = QFileInfo();
+ theFile.clear();
theShowDialog = true;
continue;
}
@@ -1111,7 +1107,7 @@ QString CDialogs::GetSaveAsChoice(const QString &inDialogTitle, bool isProject)
}
}
- return theFile.absoluteFilePath();
+ return theFile;
}
//==============================================================================
@@ -1191,8 +1187,8 @@ bool CDialogs::ConfirmRevert()
* @param inActionText text to be displayed as the action
* @param inAdditionalText additional text, for example a file name
*/
-void CDialogs::DisplayProgressScreen(const Q3DStudio::CString &inActionText,
- const Q3DStudio::CString &inAdditionalText)
+void CDialogs::DisplayProgressScreen(const QString &inActionText,
+ const QString &inAdditionalText)
{
if (m_ShowGUI && !m_ProgressPalette) {
m_ProgressPalette = new CProgressView(g_StudioApp.m_pMainWnd);
@@ -1245,12 +1241,12 @@ void CDialogs::DisplayEnvironmentVariablesError(const Q3DStudio::CString &inErro
* @param inCurrentDocPath the current document path, if any. Application directory if
*there is none.
*/
-void CDialogs::ResetSettings(const Q3DStudio::CString &inCurrentDocPath)
+void CDialogs::ResetSettings(const QString &inCurrentDocPath)
{
// Initialize the default dir/paths to the current document path if specified, otherwise leave
// everything as it is.
- if (!inCurrentDocPath.IsEmpty())
- m_LastSaveFile = inCurrentDocPath.toQString();
+ if (!inCurrentDocPath.isEmpty())
+ m_LastSaveFile = inCurrentDocPath;
}
bool CDialogs::DisplayResetKeyframeValuesDlg()
diff --git a/src/Authoring/Studio/Workspace/Dialogs.h b/src/Authoring/Studio/Workspace/Dialogs.h
index d5a85bf0..f1e93ef6 100644
--- a/src/Authoring/Studio/Workspace/Dialogs.h
+++ b/src/Authoring/Studio/Workspace/Dialogs.h
@@ -70,8 +70,7 @@ public:
virtual ~CDialogs();
void DisplayAssetDeleteFailed();
- void DisplayRefreshResourceFailed(const Q3DStudio::CString &inResourceName,
- const Q3DStudio::CString &inDescription);
+ void DisplayRefreshResourceFailed(const QString &inResourceName, const QString &inDescription);
QString ConfirmRefreshModelFile(const QString &inOriginalPath);
QList<QUrl> SelectAssets(QString &outPath, Q3DStudio::DocumentEditorFileType::Enum assetType);
@@ -134,10 +133,8 @@ public:
QString GetNewDocumentChoice(const QString &inInitialDirectory = {}, bool isProject = true);
QString GetFileOpenChoice(const QString &inInitialDirectory = {});
- void DisplayImportFailed(const QUrl &inURL, const QString &inDescription,
- bool inWarningsOnly);
- void DisplayLoadingPresentationFailed(const Qt3DSFile &inPresentation,
- const QString &inErrorText);
+ void DisplayImportFailed(const QUrl &inURL, const QString &inDescription, bool inWarningsOnly);
+ void DisplayLoadingPresentationFailed(const QFileInfo &loadFileInfo, const QString &errorText);
void DisplaySavingPresentationFailed();
void DisplaySaveReadOnlyFailed(const QString &inSavedLocation);
void DisplayObjectRenamed(const QString &origName, const QString &newName, bool async = false);
@@ -156,13 +153,13 @@ public:
bool ConfirmRevert();
- void DisplayProgressScreen(const Q3DStudio::CString &inActionText,
- const Q3DStudio::CString &inAdditionalText);
+ void DisplayProgressScreen(const QString &inActionText,
+ const QString &inAdditionalText);
void DestroyProgressScreen();
void DisplayEnvironmentVariablesError(const Q3DStudio::CString &inErrorMessage);
- void ResetSettings(const Q3DStudio::CString &inCurrentDocPath = "");
+ void ResetSettings(const QString &inCurrentDocPath = {});
bool DisplayResetKeyframeValuesDlg();
void DisplayPasteFailed();