diff options
author | OverMighty <its.overmighty@gmail.com> | 2020-02-05 00:29:23 +0100 |
---|---|---|
committer | OverMighty <its.overmighty@gmail.com> | 2020-02-05 12:37:09 +0100 |
commit | bc04d89c32142094eec161709cf3932b7213b058 (patch) | |
tree | eed989535c2f4181f0d836805fd6f8464bb4cd3f /application/MultiMC.cpp | |
parent | bc98181ec274dfc933c5c0207943f9de1dbaf1d1 (diff) | |
download | PrismLauncher-bc04d89c32142094eec161709cf3932b7213b058.tar.gz PrismLauncher-bc04d89c32142094eec161709cf3932b7213b058.tar.bz2 PrismLauncher-bc04d89c32142094eec161709cf3932b7213b058.zip |
feat: add --import command-line option
When specified, opens the "Import from zip" dialog as soon as the main
window is shown, with the URL field prefilled with the argument given to
the option.
Closes #2998
Diffstat (limited to 'application/MultiMC.cpp')
-rw-r--r-- | application/MultiMC.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index c4e4392d..039fb11d 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -34,6 +34,7 @@ #include <QNetworkAccessManager> #include <QTranslator> #include <QLibraryInfo> +#include <QList> #include <QStringList> #include <QDebug> #include <QStyleFactory> @@ -174,6 +175,10 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) parser.addSwitch("alive"); parser.addDocumentation("alive", "Write a small '" + liveCheckFile + "' file after MultiMC starts"); + parser.addOption("import"); + parser.addShortOpt("import", 'I'); + parser.addDocumentation("import", "Import instance from specified zip (local path or URL)"); + // parse the arguments try { @@ -207,6 +212,7 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) } m_instanceIdToLaunch = args["launch"].toString(); m_liveCheck = args["alive"].toBool(); + m_zipToImport = args["import"].toUrl(); QString origcwdPath = QDir::currentPath(); QString binPath = applicationDirPath(); @@ -812,6 +818,12 @@ void MultiMC::performMainStartupAction() showMainWindow(false); qDebug() << "<> Main window shown."; } + + if (!m_zipToImport.isEmpty()) { + qDebug() << "<> Importing instance from zip:" << m_zipToImport.toString(); + QList<QUrl> urls = { m_zipToImport }; + m_mainWindow->droppedURLs(urls); + } } void MultiMC::showFatalErrorMessage(const QString& title, const QString& content) |