summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2019-06-27 03:20:11 +0200
committerPetr Mrázek <peterix@gmail.com>2019-06-27 03:20:11 +0200
commitfde43c993e0a143b9dddcaff2190c91f4e5e3cb9 (patch)
treef1a97f55cc655e68c11660290eb9e0460a0ae96f /application
parent917f148fc41db7d68ef94c8ea29cd417a8f1ff33 (diff)
downloadMultiMC-fde43c993e0a143b9dddcaff2190c91f4e5e3cb9.tar
MultiMC-fde43c993e0a143b9dddcaff2190c91f4e5e3cb9.tar.gz
MultiMC-fde43c993e0a143b9dddcaff2190c91f4e5e3cb9.tar.lz
MultiMC-fde43c993e0a143b9dddcaff2190c91f4e5e3cb9.tar.xz
MultiMC-fde43c993e0a143b9dddcaff2190c91f4e5e3cb9.zip
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.
Diffstat (limited to 'application')
-rw-r--r--application/pages/modplatform/ImportPage.cpp5
-rw-r--r--application/pages/modplatform/TwitchPage.cpp23
-rw-r--r--application/pages/modplatform/TwitchPage.h6
-rw-r--r--application/pages/modplatform/TwitchPage.ui33
4 files changed, 63 insertions, 4 deletions
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 <MultiMC.h>
#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<Flame::UrlResolvingTask> 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 @@
<height>405</height>
</rect>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="label_3">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="lineEdit"/>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Twitch URL:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="3">
+ <widget class="QLabel" name="twitchLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="font">
<font>
<pointsize>40</pointsize>
@@ -26,8 +42,19 @@
</property>
</widget>
</item>
+ <item row="0" column="2">
+ <widget class="QPushButton" name="checkButton">
+ <property name="text">
+ <string>Check</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
+ <tabstops>
+ <tabstop>lineEdit</tabstop>
+ <tabstop>checkButton</tabstop>
+ </tabstops>
<resources>
<include location="../../resources/assets/assets.qrc"/>
</resources>