From 725ec356350175ba08bca0eae8475dc2654dd10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 9 Jul 2019 22:04:52 +0200 Subject: NOISSUE recognize curseforge URLs dropped on top of MultiMC --- api/logic/modplatform/flame/UrlResolvingTask.cpp | 5 +++++ application/dialogs/NewInstanceDialog.cpp | 19 ++++++++++++++----- application/dialogs/NewInstanceDialog.h | 2 ++ application/pages/modplatform/TwitchPage.cpp | 7 ++++++- application/pages/modplatform/TwitchPage.h | 4 +++- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/api/logic/modplatform/flame/UrlResolvingTask.cpp b/api/logic/modplatform/flame/UrlResolvingTask.cpp index 9d53e7e5..efea350c 100644 --- a/api/logic/modplatform/flame/UrlResolvingTask.cpp +++ b/api/logic/modplatform/flame/UrlResolvingTask.cpp @@ -21,6 +21,11 @@ void Flame::UrlResolvingTask::resolveUrl() { setStatus(tr("Resolving URL...")); setProgress(0, 1); + QUrl actualUrl(m_url); + if(actualUrl.host() != "www.curseforge.com") { + emitFailed(tr("Not a Twitch URL.")); + return; + } m_dljob.reset(new NetJob("URL resolver")); bool weAreDigging = false; diff --git a/application/dialogs/NewInstanceDialog.cpp b/application/dialogs/NewInstanceDialog.cpp index 402a3417..3533763d 100644 --- a/application/dialogs/NewInstanceDialog.cpp +++ b/application/dialogs/NewInstanceDialog.cpp @@ -39,6 +39,8 @@ #include #include + + NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString & url, QWidget *parent) : QDialog(parent), ui(new Ui::NewInstanceDialog) { @@ -94,8 +96,15 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString if(!url.isEmpty()) { - m_container->selectPage("import"); - importPage->setUrl(url); + QUrl actualUrl(url); + if(actualUrl.host() == "www.curseforge.com") { + m_container->selectPage("twitch"); + twitchPage->setUrl(url); + } + else { + m_container->selectPage("import"); + importPage->setUrl(url); + } } updateDialogState(); @@ -119,13 +128,13 @@ void NewInstanceDialog::accept() QList NewInstanceDialog::getPages() { importPage = new ImportPage(this); + twitchPage = new TwitchPage(this); return { new VanillaPage(this), - new FTBPage(this), importPage, - new TwitchPage(this), - new TechnicPage(this) + twitchPage, + new FTBPage(this) }; } diff --git a/application/dialogs/NewInstanceDialog.h b/application/dialogs/NewInstanceDialog.h index c86ab73f..0b8b2fb8 100644 --- a/application/dialogs/NewInstanceDialog.h +++ b/application/dialogs/NewInstanceDialog.h @@ -29,6 +29,7 @@ class NewInstanceDialog; class PageContainer; class QDialogButtonBox; class ImportPage; +class TwitchPage; class NewInstanceDialog : public QDialog, public BasePageProvider { @@ -67,6 +68,7 @@ private: QString InstIconKey; ImportPage *importPage = nullptr; + TwitchPage *twitchPage = nullptr; std::unique_ptr creationTask; bool importIcon = false; diff --git a/application/pages/modplatform/TwitchPage.cpp b/application/pages/modplatform/TwitchPage.cpp index 52d87fa4..ea0f9267 100644 --- a/application/pages/modplatform/TwitchPage.cpp +++ b/application/pages/modplatform/TwitchPage.cpp @@ -30,7 +30,6 @@ void TwitchPage::openedImpl() void TwitchPage::triggerCheck(bool) { if(m_modIdResolver) { - qDebug() << "Click!"; return; } auto task = new Flame::UrlResolvingTask(ui->lineEdit->text()); @@ -39,6 +38,12 @@ void TwitchPage::triggerCheck(bool) task->start(); } +void TwitchPage::setUrl(const QString& url) +{ + ui->lineEdit->setText(url); + triggerCheck(true); +} + void TwitchPage::checkDone() { auto result = m_modIdResolver->getResults(); diff --git a/application/pages/modplatform/TwitchPage.h b/application/pages/modplatform/TwitchPage.h index 6d5146cc..600913cd 100644 --- a/application/pages/modplatform/TwitchPage.h +++ b/application/pages/modplatform/TwitchPage.h @@ -38,7 +38,7 @@ public: virtual ~TwitchPage(); virtual QString displayName() const override { - return tr("Twitch"); + return tr("Twitch URL"); } virtual QIcon icon() const override { @@ -56,6 +56,8 @@ public: void openedImpl() override; + void setUrl(const QString & url); + private slots: void triggerCheck(bool checked); void checkDone(); -- cgit v1.2.3