From fde43c993e0a143b9dddcaff2190c91f4e5e3cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 27 Jun 2019 03:20:11 +0200 Subject: NOISSUE add silly twitch URL and CCIP resolving page to 'add instance' It needs a few more steps and it will handle all kinds of twitch packs. --- application/pages/modplatform/ImportPage.cpp | 5 +++++ application/pages/modplatform/TwitchPage.cpp | 23 ++++++++++++++++++- application/pages/modplatform/TwitchPage.h | 6 +++++ application/pages/modplatform/TwitchPage.ui | 33 +++++++++++++++++++++++++--- 4 files changed, 63 insertions(+), 4 deletions(-) (limited to 'application') diff --git a/application/pages/modplatform/ImportPage.cpp b/application/pages/modplatform/ImportPage.cpp index 3cd7c2cf..3910dfda 100644 --- a/application/pages/modplatform/ImportPage.cpp +++ b/application/pages/modplatform/ImportPage.cpp @@ -75,6 +75,11 @@ void ImportPage::updateState() } else { + if(input.endsWith("?client=y")) { + input.chop(9); + input.append("/file"); + url = QUrl::fromUserInput(input); + } // hook, line and sinker. QFileInfo fi(url.fileName()); dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url)); diff --git a/application/pages/modplatform/TwitchPage.cpp b/application/pages/modplatform/TwitchPage.cpp index a984c01c..2f138b94 100644 --- a/application/pages/modplatform/TwitchPage.cpp +++ b/application/pages/modplatform/TwitchPage.cpp @@ -8,6 +8,7 @@ TwitchPage::TwitchPage(NewInstanceDialog* dialog, QWidget *parent) : QWidget(parent), ui(new Ui::TwitchPage), dialog(dialog) { ui->setupUi(this); + connect(ui->checkButton, &QPushButton::clicked, this, &TwitchPage::triggerCheck); } TwitchPage::~TwitchPage() @@ -17,10 +18,30 @@ TwitchPage::~TwitchPage() bool TwitchPage::shouldDisplay() const { - return false; + return true; } void TwitchPage::openedImpl() { dialog->setSuggestedPack(); } + +void TwitchPage::triggerCheck(bool) +{ + if(m_modIdResolver) { + qDebug() << "Click!"; + return; + } + auto task = new Flame::UrlResolvingTask(ui->lineEdit->text()); + connect(task, &Task::finished, this, &TwitchPage::checkDone); + m_modIdResolver.reset(task); + task->start(); +} + +void TwitchPage::checkDone() +{ + auto result = m_modIdResolver->getResults(); + auto formatted = QString("Project %1, File %2").arg(result.projectId).arg(result.fileId); + ui->twitchLabel->setText(formatted); + m_modIdResolver.reset(); +} diff --git a/application/pages/modplatform/TwitchPage.h b/application/pages/modplatform/TwitchPage.h index 5d959962..6d5146cc 100644 --- a/application/pages/modplatform/TwitchPage.h +++ b/application/pages/modplatform/TwitchPage.h @@ -20,6 +20,7 @@ #include "pages/BasePage.h" #include #include "tasks/Task.h" +#include "modplatform/flame/UrlResolvingTask.h" namespace Ui { @@ -55,7 +56,12 @@ public: void openedImpl() override; +private slots: + void triggerCheck(bool checked); + void checkDone(); + private: Ui::TwitchPage *ui = nullptr; NewInstanceDialog* dialog = nullptr; + shared_qobject_ptr m_modIdResolver; }; diff --git a/application/pages/modplatform/TwitchPage.ui b/application/pages/modplatform/TwitchPage.ui index 0930f541..0db2484d 100644 --- a/application/pages/modplatform/TwitchPage.ui +++ b/application/pages/modplatform/TwitchPage.ui @@ -10,9 +10,25 @@ 405 - - - + + + + + + + + Twitch URL: + + + + + + + + 0 + 0 + + 40 @@ -26,8 +42,19 @@ + + + + Check + + + + + lineEdit + checkButton + -- cgit v1.2.3