Mercurial > hg > sonic-lineup
changeset 421:44a175c7b81f pitch-align
Don't reopen previous session when constructing main window - wait until we've shown the window and checked whether the command line calls for a new session. Also expand playlists when parsing command args, and make sure paths actually added are absolute ones
| author | Chris Cannam |
|---|---|
| date | Wed, 06 May 2020 09:12:23 +0100 |
| parents | 67eb71cae128 |
| children | eb4a9dca0acd |
| files | main/MainWindow.cpp main/MainWindow.h main/main.cpp repoint-lock.json |
| diffstat | 4 files changed, 60 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/main/MainWindow.cpp Wed May 06 09:09:26 2020 +0100 +++ b/main/MainWindow.cpp Wed May 06 09:12:23 2020 +0100 @@ -58,7 +58,6 @@ #include "audio/AudioCallbackRecordTarget.h" #include "audio/PlaySpeedRangeMapper.h" #include "data/fileio/DataFileReaderFactory.h" -#include "data/fileio/PlaylistFileReader.h" #include "data/fileio/WavFileWriter.h" #include "data/fileio/CSVFileWriter.h" #include "data/fileio/BZipFileDevice.h" @@ -391,16 +390,7 @@ NetworkPermissionTester tester; m_networkPermission = tester.havePermission(); - - if (!reopenLastSession()) { - QTimer::singleShot(400, this, SLOT(introDialog())); - } else { - // Do this here only if not showing the intro dialog - - // otherwise the introDialog function will do this after it - // has shown the dialog, so we don't end up with both at once - checkForNewerVersion(); - } - + // QTimer::singleShot(500, this, SLOT(betaReleaseWarning())); }
--- a/main/MainWindow.h Wed May 06 09:09:26 2020 +0100 +++ b/main/MainWindow.h Wed May 06 09:12:23 2020 +0100 @@ -75,6 +75,7 @@ public slots: void openSmallSession(const SmallSession &); + bool reopenLastSession(); void preferenceChanged(PropertyContainer::PropertyName) override; bool commitData(bool mayAskUser); // on session shutdown @@ -84,6 +85,9 @@ void selectMainPane(); + void introDialog(); + void checkForNewerVersion(); + protected slots: virtual void openFiles(); virtual void openLocation(); @@ -93,7 +97,6 @@ virtual void newSession(); virtual void preferences(); - bool reopenLastSession(); void closeSession() override; void outlineWaveformModeSelected(); @@ -129,9 +132,6 @@ virtual void restoreNormalPlayback(); void monitoringLevelsChanged(float, float) override; - - void introDialog(); - void checkForNewerVersion(); void betaReleaseWarning();
--- a/main/main.cpp Wed May 06 09:09:26 2020 +0100 +++ b/main/main.cpp Wed May 06 09:12:23 2020 +0100 @@ -19,6 +19,7 @@ #include "base/TempDirectory.h" #include "base/PropertyContainer.h" #include "base/Preferences.h" +#include "data/fileio/PlaylistFileReader.h" #include "widgets/TipDialog.h" #include "svcore/plugin/PluginScan.h" @@ -302,16 +303,57 @@ SmallSession session; bool haveSession = false; + + QStringList filePaths; for (QStringList::iterator i = args.begin(); i != args.end(); ++i) { if (i == args.begin()) continue; if (i->startsWith('-')) continue; + QString arg = *i; + + // If an arg is a playlist file, we can streamline things and + // make sure we get the proper absolute paths by expanding it + // here, rather than adding it to the session and waiting for + // it to be expanded in the main application logic. (That + // would work too, it's just not so clean a user experience.) + + if (PlaylistFileReader::isSupported(arg)) { + PlaylistFileReader reader(arg); + if (!reader.isOK()) { + // But if we can't open the playlist file, add it to + // the session as if it were just any old file and let + // the main application worry about it later - we + // don't want to be popping up dialogs before the app + // has been exec'd + filePaths.push_back(arg); + } else { + auto playlist = reader.load(); + for (auto entry: playlist) { + filePaths.push_back(entry); + } + } + } else { + filePaths.push_back(arg); + } + } + + for (auto filePath: filePaths) { + + // Add the argument to our session as a file path or URL to be + // opened. We want to avoid relative file paths, but to do so + // we must first check that they are not absolute URLs. + + QUrl url(filePath); + if (url.isRelative()) { + filePath = QFileInfo(filePath).absoluteFilePath(); + } + if (session.mainFile == "") { - session.mainFile = *i; + session.mainFile = filePath; } else { - session.additionalFiles.push_back(*i); + session.additionalFiles.push_back(filePath); } haveSession = true; @@ -319,6 +361,13 @@ if (haveSession) { gui->openSmallSession(session); + } else if (!gui->reopenLastSession()) { + QTimer::singleShot(400, gui, SLOT(introDialog())); + } else { + // Do this here only if not showing the intro dialog - + // otherwise the introDialog function will do this after it + // has shown the dialog, so we don't end up with both at once + gui->checkForNewerVersion(); } int rv = application.exec();
--- a/repoint-lock.json Wed May 06 09:09:26 2020 +0100 +++ b/repoint-lock.json Wed May 06 09:12:23 2020 +0100 @@ -1,16 +1,16 @@ { "libraries": { "vamp-plugin-sdk": { - "pin": "b9422f3e63a4" + "pin": "8ffb8985ae8f" }, "svcore": { - "pin": "9762a7f084a0" + "pin": "f36fef97ac81" }, "svgui": { - "pin": "5e091b0e317c" + "pin": "d6976d231efb" }, "svapp": { - "pin": "31289e8592c7" + "pin": "f32df46d0c84" }, "checker": { "pin": "e839338d3869"
