summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-05-28 12:40:00 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-05-29 09:38:08 +0000
commitd9825cfc56d8cd4bac194d6935dcdaec53dfae9f (patch)
treea6658bd7c1e660d7ee83d3b6d533529e47c32d20
parent5f625401ebe432648208edc58fc8f862659284c4 (diff)
Fix the initial directory for opening a presentation
Now File/Open always shows the most recently opened presentation's directory. Task-number: QT3DS-1471 Change-Id: I4038528001bdc7e597b4b4cff3cde579815679bf Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Janne Kangas <janne.kangas@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Studio/Application/StudioApp.cpp28
-rw-r--r--src/Authoring/Studio/Application/StudioApp.h3
2 files changed, 19 insertions, 12 deletions
diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp
index 0e0e717b..cff12964 100644
--- a/src/Authoring/Studio/Application/StudioApp.cpp
+++ b/src/Authoring/Studio/Application/StudioApp.cpp
@@ -528,17 +528,10 @@ bool CStudioApp::showStartupDialog()
CStartupDlg theStartupDlg(m_pMainWnd);
// Populate recent items
- Q3DStudio::CFilePath theMostRecentDirectory = Q3DStudio::CFilePath(".");
if (m_views) {
CRecentItems *theRecentItems = m_views->getMainFrame()->GetRecentItems();
- for (long theIndex = 0; theIndex < theRecentItems->GetItemCount(); ++theIndex) {
- if (theIndex == 0) {
- theMostRecentDirectory =
- Q3DStudio::CFilePath(theRecentItems->GetItem(0).GetAbsolutePath())
- .GetDirectory();
- }
+ for (long theIndex = 0; theIndex < theRecentItems->GetItemCount(); ++theIndex)
theStartupDlg.AddRecentItem(theRecentItems->GetItem(theIndex));
- }
}
theStartupDlg.exec();
@@ -550,7 +543,7 @@ bool CStudioApp::showStartupDialog()
break;
case CStartupDlg::EStartupChoice_NewDoc: {
- Qt3DSFile theFile = m_dialogs->GetNewDocumentChoice(theMostRecentDirectory);
+ Qt3DSFile theFile = m_dialogs->GetNewDocumentChoice(getMostRecentDirectory());
if (theFile.GetPath() != "") {
if (!m_core->OnNewDocument(theFile, true)) {
// Invalid filename, show a message box and the dialog again
@@ -564,7 +557,7 @@ bool CStudioApp::showStartupDialog()
} break;
case CStartupDlg::EStartupChoice_OpenDoc: {
- Qt3DSFile theFile = m_dialogs->GetFileOpenChoice(theMostRecentDirectory);
+ Qt3DSFile theFile = m_dialogs->GetFileOpenChoice(getMostRecentDirectory());
if (theFile.GetPath() != "") {
OnLoadDocument(theFile);
theReturn = true;
@@ -1628,6 +1621,19 @@ void CStudioApp::SaveUIAFile(bool subpresentations)
qt3ds::state::IApplication::EnsureApplicationFile(docBA.constData(), list, subpresentations);
}
+CFilePath CStudioApp::getMostRecentDirectory() const
+{
+ CFilePath mostRecentDirectory = Q3DStudio::CFilePath(".");
+ if (m_views) {
+ CRecentItems *recentItems = m_views->getMainFrame()->GetRecentItems();
+ if (recentItems->GetItemCount() > 0) {
+ mostRecentDirectory = CFilePath(recentItems->GetItem(0).GetAbsolutePath())
+ .GetDirectory();
+ }
+ }
+ return mostRecentDirectory;
+}
+
//=============================================================================
/**
* Called by OnLoadDocument, to allow the error reporting to be inserted.
@@ -1650,7 +1656,7 @@ void CStudioApp::OnLoadDocumentCatcher(const Qt3DSFile &inDocument)
void CStudioApp::OnFileOpen()
{
if (PerformSavePrompt()) {
- Qt3DSFile theFile = m_dialogs->GetFileOpenChoice();
+ Qt3DSFile theFile = m_dialogs->GetFileOpenChoice(getMostRecentDirectory());
if (theFile.GetPath() != "")
OnLoadDocument(theFile);
}
diff --git a/src/Authoring/Studio/Application/StudioApp.h b/src/Authoring/Studio/Application/StudioApp.h
index e4597f2c..9dbe1180 100644
--- a/src/Authoring/Studio/Application/StudioApp.h
+++ b/src/Authoring/Studio/Application/StudioApp.h
@@ -35,7 +35,7 @@
#include "StudioObjectTypes.h"
#include "DispatchListeners.h"
#include "Qt3DSDMHandles.h"
-
+#include "Qt3DSFileTools.h"
#include <QtWidgets/qapplication.h>
namespace Q3DStudio {
@@ -239,6 +239,7 @@ public:
QMap<QString, CDataInputDialogItem *> m_dataInputDialogItems;
void SaveUIAFile(bool subpresentations = true);
+ Q3DStudio::CFilePath getMostRecentDirectory() const;
};
extern CStudioApp g_StudioApp;