diff options
author | Petr Mrázek <peterix@gmail.com> | 2019-07-09 22:04:52 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2019-07-09 22:04:52 +0200 |
commit | 725ec356350175ba08bca0eae8475dc2654dd10a (patch) | |
tree | 84e2d17c247dcca19cb14e7f033201286a166b00 | |
parent | 739a86f17194e60f44767d5830d7c214edc5d276 (diff) | |
download | MultiMC-725ec356350175ba08bca0eae8475dc2654dd10a.tar MultiMC-725ec356350175ba08bca0eae8475dc2654dd10a.tar.gz MultiMC-725ec356350175ba08bca0eae8475dc2654dd10a.tar.lz MultiMC-725ec356350175ba08bca0eae8475dc2654dd10a.tar.xz MultiMC-725ec356350175ba08bca0eae8475dc2654dd10a.zip |
NOISSUE recognize curseforge URLs dropped on top of MultiMC
-rw-r--r-- | api/logic/modplatform/flame/UrlResolvingTask.cpp | 5 | ||||
-rw-r--r-- | application/dialogs/NewInstanceDialog.cpp | 19 | ||||
-rw-r--r-- | application/dialogs/NewInstanceDialog.h | 2 | ||||
-rw-r--r-- | application/pages/modplatform/TwitchPage.cpp | 7 | ||||
-rw-r--r-- | 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 <pages/modplatform/ImportPage.h> #include <pages/modplatform/TechnicPage.h> + + 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<BasePage *> 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<InstanceTask> 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(); |