Apply suggestions

This commit is contained in:
timoreo 2022-05-20 22:06:36 +02:00
parent 30b56dbcbd
commit 6542f5f15a
No known key found for this signature in database
GPG Key ID: 121A72C3512BA288
2 changed files with 40 additions and 34 deletions

View File

@ -82,12 +82,13 @@ bool Flame::File::parseFromBytes(const QByteArray& bytes)
// this is probably a mod, dunno what else could modpacks download // this is probably a mod, dunno what else could modpacks download
targetFolder = "mods"; targetFolder = "mods";
} }
if(!obj.contains("downloadUrl") || obj["downloadUrl"].isNull() || !obj["downloadUrl"].isString() || obj["downloadUrl"].toString().isEmpty()){ QString rawUrl = Json::ensureString(obj, "downloadUrl");
if(rawUrl.isEmpty()){
//either there somehow is an emtpy string as a link, or it's null either way it's invalid //either there somehow is an emtpy string as a link, or it's null either way it's invalid
//soft failing //soft failing
return false; return false;
} }
QString rawUrl = Json::requireString(obj, "downloadUrl");
url = QUrl(rawUrl, QUrl::TolerantMode); url = QUrl(rawUrl, QUrl::TolerantMode);
if (!url.isValid()) { if (!url.isValid()) {
throw JSONValidationError(QString("Invalid URL: %1").arg(rawUrl)); throw JSONValidationError(QString("Invalid URL: %1").arg(rawUrl));

View File

@ -6,26 +6,39 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1989</width> <width>2445</width>
<height>685</height> <height>685</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="1"> <item row="4" column="0" colspan="2">
<widget class="QPushButton" name="searchButton"> <layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0" rowminimumheight="0" columnminimumwidth="0,0,0">
<property name="text"> <item row="0" column="2">
<string>Search</string> <widget class="QComboBox" name="versionSelectionBox"/>
</property> </item>
</widget> <item row="0" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Version selected:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="sortByBox"/>
</item>
</layout>
</item> </item>
<item row="0" column="0"> <item row="1" column="0">
<widget class="QLineEdit" name="searchEdit"> <widget class="QLineEdit" name="searchEdit">
<property name="placeholderText"> <property name="placeholderText">
<string>Search and filter...</string> <string>Search and filter...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0"> <item row="1" column="0">
<widget class="QListView" name="packView"> <widget class="QListView" name="packView">
@ -55,30 +68,22 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="1" column="1">
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0" rowminimumheight="0" columnminimumwidth="0,0,0"> <widget class="QPushButton" name="searchButton">
<item row="0" column="2">
<widget class="QComboBox" name="versionSelectionBox"/>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Version selected:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="sortByBox"/>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>WARNING !! Curseforge is very unreliable and low quality. Some mod authors have disabled the ability for third party apps (like polymc) to download the mods, you may need to manually download some mods</string> <string>Search</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>WARNING: CurseForge's API is very unreliable and low quality. Also, some mod authors have disabled the ability for third party apps (like PolyMC) to download their mods. As such, you may need to manually download some mods to be able to use the modpack.</string>
</property> </property>
</widget> </widget>
</item> </item>