Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into fix_retry_dialog
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include "AccountListPage.h"
|
||||
#include "minecraft/auth/AccountData.h"
|
||||
#include "ui/dialogs/skins/SkinManageDialog.h"
|
||||
#include "ui_AccountListPage.h"
|
||||
|
||||
#include <QItemSelectionModel>
|
||||
@@ -47,11 +47,6 @@
|
||||
#include "ui/dialogs/CustomMessageBox.h"
|
||||
#include "ui/dialogs/MSALoginDialog.h"
|
||||
#include "ui/dialogs/OfflineLoginDialog.h"
|
||||
#include "ui/dialogs/ProgressDialog.h"
|
||||
#include "ui/dialogs/SkinUploadDialog.h"
|
||||
|
||||
#include "minecraft/services/SkinDelete.h"
|
||||
#include "tasks/Task.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
@@ -233,8 +228,7 @@ void AccountListPage::updateButtonStates()
|
||||
}
|
||||
ui->actionRemove->setEnabled(accountIsReady);
|
||||
ui->actionSetDefault->setEnabled(accountIsReady);
|
||||
ui->actionUploadSkin->setEnabled(accountIsReady && accountIsOnline);
|
||||
ui->actionDeleteSkin->setEnabled(accountIsReady && accountIsOnline);
|
||||
ui->actionManageSkins->setEnabled(accountIsReady && accountIsOnline);
|
||||
ui->actionRefresh->setEnabled(accountIsReady && accountIsOnline);
|
||||
|
||||
if (m_accounts->defaultAccount().get() == nullptr) {
|
||||
@@ -247,29 +241,13 @@ void AccountListPage::updateButtonStates()
|
||||
ui->listView->resizeColumnToContents(3);
|
||||
}
|
||||
|
||||
void AccountListPage::on_actionUploadSkin_triggered()
|
||||
void AccountListPage::on_actionManageSkins_triggered()
|
||||
{
|
||||
QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes();
|
||||
if (selection.size() > 0) {
|
||||
QModelIndex selected = selection.first();
|
||||
MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>();
|
||||
SkinUploadDialog dialog(account, this);
|
||||
SkinManageDialog dialog(this, account);
|
||||
dialog.exec();
|
||||
}
|
||||
}
|
||||
|
||||
void AccountListPage::on_actionDeleteSkin_triggered()
|
||||
{
|
||||
QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes();
|
||||
if (selection.size() <= 0)
|
||||
return;
|
||||
|
||||
QModelIndex selected = selection.first();
|
||||
MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>();
|
||||
ProgressDialog prog(this);
|
||||
auto deleteSkinTask = std::make_shared<SkinDelete>(this, account->accessToken());
|
||||
if (prog.execWithTask((Task*)deleteSkinTask.get()) != QDialog::Accepted) {
|
||||
CustomMessageBox::selectable(this, tr("Skin Delete"), tr("Failed to delete current skin!"), QMessageBox::Warning)->exec();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +76,7 @@ class AccountListPage : public QMainWindow, public BasePage {
|
||||
void on_actionRefresh_triggered();
|
||||
void on_actionSetDefault_triggered();
|
||||
void on_actionNoDefault_triggered();
|
||||
void on_actionUploadSkin_triggered();
|
||||
void on_actionDeleteSkin_triggered();
|
||||
void on_actionManageSkins_triggered();
|
||||
|
||||
void listChanged();
|
||||
|
||||
|
||||
@@ -59,14 +59,8 @@
|
||||
<addaction name="actionSetDefault"/>
|
||||
<addaction name="actionNoDefault"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionUploadSkin"/>
|
||||
<addaction name="actionDeleteSkin"/>
|
||||
<addaction name="actionManageSkins"/>
|
||||
</widget>
|
||||
<action name="actionRemove">
|
||||
<property name="text">
|
||||
<string>Remo&ve</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSetDefault">
|
||||
<property name="text">
|
||||
<string>&Set Default</string>
|
||||
@@ -80,17 +74,12 @@
|
||||
<string>&No Default</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUploadSkin">
|
||||
<action name="actionManageSkins">
|
||||
<property name="text">
|
||||
<string>&Upload Skin</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDeleteSkin">
|
||||
<property name="text">
|
||||
<string>&Delete Skin</string>
|
||||
<string>&Manage Skins</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Delete the currently active skin and go back to the default one</string>
|
||||
<string>Manage Skins</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAddMicrosoft">
|
||||
@@ -111,6 +100,11 @@
|
||||
<string>Refresh the account tokens</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemove">
|
||||
<property name="text">
|
||||
<string>Remo&ve</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
@@ -173,6 +173,17 @@ void LauncherPage::on_downloadsDirBrowseBtn_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherPage::on_skinsDirBrowseBtn_clicked()
|
||||
{
|
||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Skins Folder"), ui->skinsDirTextBox->text());
|
||||
|
||||
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
||||
if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) {
|
||||
QString cooked_dir = FS::NormalizePath(raw_dir);
|
||||
ui->skinsDirTextBox->setText(cooked_dir);
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherPage::on_metadataDisableBtn_clicked()
|
||||
{
|
||||
ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked());
|
||||
@@ -209,6 +220,7 @@ void LauncherPage::applySettings()
|
||||
s->set("CentralModsDir", ui->modsDirTextBox->text());
|
||||
s->set("IconsDir", ui->iconsDirTextBox->text());
|
||||
s->set("DownloadsDir", ui->downloadsDirTextBox->text());
|
||||
s->set("SkinsDir", ui->skinsDirTextBox->text());
|
||||
s->set("DownloadsDirWatchRecursive", ui->downloadsDirWatchRecursiveCheckBox->isChecked());
|
||||
|
||||
auto sortMode = (InstSortMode)ui->sortingModeGroup->checkedId();
|
||||
@@ -271,6 +283,7 @@ void LauncherPage::loadSettings()
|
||||
ui->modsDirTextBox->setText(s->get("CentralModsDir").toString());
|
||||
ui->iconsDirTextBox->setText(s->get("IconsDir").toString());
|
||||
ui->downloadsDirTextBox->setText(s->get("DownloadsDir").toString());
|
||||
ui->skinsDirTextBox->setText(s->get("SkinsDir").toString());
|
||||
ui->downloadsDirWatchRecursiveCheckBox->setChecked(s->get("DownloadsDirWatchRecursive").toBool());
|
||||
|
||||
QString sortMode = s->get("InstSortMode").toString();
|
||||
|
||||
@@ -74,6 +74,7 @@ class LauncherPage : public QWidget, public BasePage {
|
||||
void on_modsDirBrowseBtn_clicked();
|
||||
void on_iconsDirBrowseBtn_clicked();
|
||||
void on_downloadsDirBrowseBtn_clicked();
|
||||
void on_skinsDirBrowseBtn_clicked();
|
||||
void on_metadataDisableBtn_clicked();
|
||||
|
||||
/*!
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<string>Folders</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="foldersBoxLayout">
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelDownloadsDir">
|
||||
<property name="text">
|
||||
<string>&Downloads:</string>
|
||||
@@ -90,13 +90,16 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="instDirTextBox"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="downloadsDirTextBox"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="iconsDirTextBox"/>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="skinsDirTextBox"/>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QToolButton" name="downloadsDirBrowseBtn">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
@@ -147,7 +150,24 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<item row="3" column="2">
|
||||
<widget class="QToolButton" name="skinsDirBrowseBtn">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelSkinsDir">
|
||||
<property name="text">
|
||||
<string>&Skins:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>skinsDirTextBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="downloadsDirWatchRecursiveCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>When enabled, in addition to the downloads folder, its sub folders will also be searched when looking for resources (e.g. when looking for blocked mods on CurseForge).</string>
|
||||
|
||||
@@ -70,15 +70,15 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="WideBar" name="actionsToolbar">
|
||||
<property name="useDefaultAction" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Actions</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextOnly</enum>
|
||||
</property>
|
||||
<property name="useDefaultAction" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>RightToolBarArea</enum>
|
||||
</attribute>
|
||||
@@ -171,6 +171,17 @@
|
||||
<string>Try to check or update all selected resources (all resources if none are selected)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExportMetadata">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Export modlist</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Export mod's metadata to text</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "InstanceTask.h"
|
||||
#include "Json.h"
|
||||
#include "Markdown.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include "modplatform/modrinth/ModrinthPackManifest.h"
|
||||
|
||||
@@ -332,7 +333,7 @@ void ModrinthManagedPackPage::suggestVersion()
|
||||
}
|
||||
auto version = m_pack.versions.at(index);
|
||||
|
||||
ui->changelogTextBrowser->setHtml(markdownToHTML(version.changelog.toUtf8()));
|
||||
ui->changelogTextBrowser->setHtml(StringUtils::htmlListPatch(markdownToHTML(version.changelog.toUtf8())));
|
||||
|
||||
ManagedPackPage::suggestVersion();
|
||||
}
|
||||
@@ -420,7 +421,7 @@ void FlameManagedPackPage::parseManagedPack()
|
||||
"Don't worry though, it will ask you to update this instance instead, so you'll not lose this instance!"
|
||||
"</h4>");
|
||||
|
||||
ui->changelogTextBrowser->setHtml(message);
|
||||
ui->changelogTextBrowser->setHtml(StringUtils::htmlListPatch(message));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -502,7 +503,8 @@ void FlameManagedPackPage::suggestVersion()
|
||||
}
|
||||
auto version = m_pack.versions.at(index);
|
||||
|
||||
ui->changelogTextBrowser->setHtml(m_api.getModFileChangelog(m_inst->getManagedPackID().toInt(), version.fileId));
|
||||
ui->changelogTextBrowser->setHtml(
|
||||
StringUtils::htmlListPatch(m_api.getModFileChangelog(m_inst->getManagedPackID().toInt(), version.fileId)));
|
||||
|
||||
ManagedPackPage::suggestVersion();
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
*/
|
||||
|
||||
#include "ModFolderPage.h"
|
||||
#include "ui/dialogs/ExportToModListDialog.h"
|
||||
#include "ui_ExternalResourcesPage.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
@@ -121,6 +122,9 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
|
||||
ui->actionsToolbar->addAction(ui->actionVisitItemPage);
|
||||
connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages);
|
||||
|
||||
ui->actionsToolbar->insertActionAfter(ui->actionVisitItemPage, ui->actionExportMetadata);
|
||||
connect(ui->actionExportMetadata, &QAction::triggered, this, &ModFolderPage::exportModMetadata);
|
||||
|
||||
auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); };
|
||||
|
||||
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
@@ -372,3 +376,15 @@ void ModFolderPage::deleteModMetadata()
|
||||
|
||||
m_model->deleteModsMetadata(selection);
|
||||
}
|
||||
|
||||
void ModFolderPage::exportModMetadata()
|
||||
{
|
||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
|
||||
auto selectedMods = m_model->selectedMods(selection);
|
||||
if (selectedMods.length() == 0)
|
||||
selectedMods = m_model->allMods();
|
||||
|
||||
std::sort(selectedMods.begin(), selectedMods.end(), [](const Mod* a, const Mod* b) { return a->name() < b->name(); });
|
||||
ExportToModListDialog dlg(m_instance->name(), selectedMods, this);
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ class ModFolderPage : public ExternalResourcesPage {
|
||||
private slots:
|
||||
void removeItems(const QItemSelection& selection) override;
|
||||
void deleteModMetadata();
|
||||
void exportModMetadata();
|
||||
|
||||
void installMods();
|
||||
void updateMods(bool includeDeps = false);
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
CustomPage::CustomPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), dialog(dialog), ui(new Ui::CustomPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tabWidget->tabBar()->hide();
|
||||
connect(ui->versionList, &VersionSelectWidget::selectedVersionChanged, this, &CustomPage::setSelectedVersion);
|
||||
filterChanged();
|
||||
connect(ui->alphaFilter, &QCheckBox::stateChanged, this, &CustomPage::filterChanged);
|
||||
|
||||
@@ -24,29 +24,21 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string notr="true"/>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="2" column="0">
|
||||
<widget class="Line" name="line">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="content">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>813</width>
|
||||
<height>605</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="minecraftLayout">
|
||||
<item>
|
||||
<widget class="VersionSelectWidget" name="versionList" native="true">
|
||||
@@ -147,7 +139,20 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="loaderLayout">
|
||||
<item>
|
||||
<widget class="VersionSelectWidget" name="loaderVersionList" native="true">
|
||||
@@ -273,7 +278,6 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>releaseFilter</tabstop>
|
||||
<tabstop>snapshotFilter</tabstop>
|
||||
<tabstop>betaFilter</tabstop>
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "ui_ImportPage.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMimeDatabase>
|
||||
#include <QValidator>
|
||||
#include <utility>
|
||||
|
||||
@@ -51,6 +52,7 @@
|
||||
#include "Json.h"
|
||||
|
||||
#include "InstanceImportTask.h"
|
||||
#include "net/NetJob.h"
|
||||
|
||||
class UrlValidator : public QValidator {
|
||||
public:
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
|
||||
#include "Markdown.h"
|
||||
|
||||
#include "StringUtils.h"
|
||||
#include "ui/dialogs/ResourceDownloadDialog.h"
|
||||
#include "ui/pages/modplatform/ResourceModel.h"
|
||||
#include "ui/widgets/ProjectItem.h"
|
||||
@@ -234,8 +235,8 @@ void ResourcePage::updateUi()
|
||||
|
||||
text += "<hr>";
|
||||
|
||||
m_ui->packDescription->setHtml(
|
||||
text + (current_pack->extraData.body.isEmpty() ? current_pack->description : markdownToHTML(current_pack->extraData.body)));
|
||||
m_ui->packDescription->setHtml(StringUtils::htmlListPatch(
|
||||
text + (current_pack->extraData.body.isEmpty() ? current_pack->description : markdownToHTML(current_pack->extraData.body))));
|
||||
m_ui->packDescription->flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "ui_AtlPage.h"
|
||||
|
||||
#include "BuildConfig.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include "AtlUserInteractionSupportImpl.h"
|
||||
#include "modplatform/atlauncher/ATLPackInstallTask.h"
|
||||
@@ -144,7 +145,7 @@ void AtlPage::onSelectionChanged(QModelIndex first, [[maybe_unused]] QModelIndex
|
||||
|
||||
selected = filterModel->data(first, Qt::UserRole).value<ATLauncher::IndexedPack>();
|
||||
|
||||
ui->packDescription->setHtml(selected.description.replace("\n", "<br>"));
|
||||
ui->packDescription->setHtml(StringUtils::htmlListPatch(selected.description.replace("\n", "<br>")));
|
||||
|
||||
for (const auto& version : selected.versions) {
|
||||
ui->versionSelectionBox->addItem(version.version);
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "FlameModel.h"
|
||||
#include "InstanceImportTask.h"
|
||||
#include "Json.h"
|
||||
#include "StringUtils.h"
|
||||
#include "modplatform/flame/FlameAPI.h"
|
||||
#include "ui/dialogs/NewInstanceDialog.h"
|
||||
#include "ui/widgets/ProjectItem.h"
|
||||
@@ -178,7 +179,11 @@ void FlamePage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelInde
|
||||
|
||||
for (auto version : current.versions) {
|
||||
auto release_type = version.version_type.isValid() ? QString(" [%1]").arg(version.version_type.toString()) : "";
|
||||
ui->versionSelectionBox->addItem(QString("%1%2").arg(version.version, release_type), QVariant(version.downloadUrl));
|
||||
auto mcVersion = !version.mcVersion.isEmpty() && !version.version.contains(version.mcVersion)
|
||||
? QString(" for %1").arg(version.mcVersion)
|
||||
: "";
|
||||
ui->versionSelectionBox->addItem(QString("%1%2%3").arg(version.version, mcVersion, release_type),
|
||||
QVariant(version.downloadUrl));
|
||||
}
|
||||
|
||||
QVariant current_updated;
|
||||
@@ -292,6 +297,6 @@ void FlamePage::updateUi()
|
||||
text += "<hr>";
|
||||
text += api.getModDescription(current.addonId).toUtf8();
|
||||
|
||||
ui->packDescription->setHtml(text + current.description);
|
||||
ui->packDescription->setHtml(StringUtils::htmlListPatch(text + current.description));
|
||||
ui->packDescription->flush();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "ui_ImportFTBPage.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QWidget>
|
||||
#include "FileSystem.h"
|
||||
#include "ListModel.h"
|
||||
@@ -58,8 +59,8 @@ ImportFTBPage::ImportFTBPage(NewInstanceDialog* dialog, QWidget* parent) : QWidg
|
||||
connect(ui->searchEdit, &QLineEdit::textChanged, this, &ImportFTBPage::triggerSearch);
|
||||
|
||||
connect(ui->browseButton, &QPushButton::clicked, this, [this] {
|
||||
auto path = listModel->getPath();
|
||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Select FTBApp instances directory"), path, QFileDialog::ShowDirsOnly);
|
||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Select FTBApp instances directory"), listModel->getUserPath(),
|
||||
QFileDialog::ShowDirsOnly);
|
||||
if (!dir.isEmpty())
|
||||
listModel->setPath(dir);
|
||||
});
|
||||
|
||||
@@ -24,45 +24,76 @@
|
||||
#include <QIcon>
|
||||
#include <QProcessEnvironment>
|
||||
#include "Application.h"
|
||||
#include "Exception.h"
|
||||
#include "FileSystem.h"
|
||||
#include "Json.h"
|
||||
#include "StringUtils.h"
|
||||
#include "modplatform/import_ftb/PackHelpers.h"
|
||||
#include "ui/widgets/ProjectItem.h"
|
||||
|
||||
namespace FTBImportAPP {
|
||||
|
||||
QString getStaticPath()
|
||||
QString getFTBRoot()
|
||||
{
|
||||
QString partialPath;
|
||||
QString partialPath = QDir::homePath();
|
||||
#if defined(Q_OS_OSX)
|
||||
partialPath = FS::PathCombine(QDir::homePath(), "Library/Application Support");
|
||||
#elif defined(Q_OS_WIN32)
|
||||
partialPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", "");
|
||||
#else
|
||||
partialPath = QDir::homePath();
|
||||
partialPath = FS::PathCombine(partialPath, "Library/Application Support");
|
||||
#endif
|
||||
return FS::PathCombine(partialPath, ".ftba");
|
||||
}
|
||||
|
||||
static const QString FTB_APP_PATH = FS::PathCombine(getStaticPath(), "instances");
|
||||
QString getDynamicPath()
|
||||
{
|
||||
auto settingsPath = FS::PathCombine(getFTBRoot(), "storage", "settings.json");
|
||||
if (!QFileInfo::exists(settingsPath))
|
||||
settingsPath = FS::PathCombine(getFTBRoot(), "bin", "settings.json");
|
||||
if (!QFileInfo::exists(settingsPath)) {
|
||||
qWarning() << "The ftb app setings doesn't exist.";
|
||||
return {};
|
||||
}
|
||||
try {
|
||||
auto doc = Json::requireDocument(FS::read(settingsPath));
|
||||
return Json::requireString(Json::requireObject(doc), "instanceLocation");
|
||||
} catch (const Exception& e) {
|
||||
qCritical() << "Could not read ftb settings file: " << e.cause();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
ListModel::ListModel(QObject* parent) : QAbstractListModel(parent), m_instances_path(getDynamicPath()) {}
|
||||
|
||||
void ListModel::update()
|
||||
{
|
||||
beginResetModel();
|
||||
modpacks.clear();
|
||||
m_modpacks.clear();
|
||||
|
||||
QString instancesPath = getPath();
|
||||
if (auto instancesInfo = QFileInfo(instancesPath); instancesInfo.exists() && instancesInfo.isDir()) {
|
||||
QDirIterator directoryIterator(instancesPath, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable | QDir::Hidden,
|
||||
auto wasPathAdded = [this](QString path) {
|
||||
for (auto pack : m_modpacks) {
|
||||
if (pack.path == path)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
auto scanPath = [this, wasPathAdded](QString path) {
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
if (auto instancesInfo = QFileInfo(path); !instancesInfo.exists() || !instancesInfo.isDir())
|
||||
return;
|
||||
QDirIterator directoryIterator(path, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable | QDir::Hidden,
|
||||
QDirIterator::FollowSymlinks);
|
||||
while (directoryIterator.hasNext()) {
|
||||
auto modpack = parseDirectory(directoryIterator.next());
|
||||
if (!modpack.path.isEmpty())
|
||||
modpacks.append(modpack);
|
||||
auto currentPath = directoryIterator.next();
|
||||
if (!wasPathAdded(currentPath)) {
|
||||
auto modpack = parseDirectory(currentPath);
|
||||
if (!modpack.path.isEmpty())
|
||||
m_modpacks.append(modpack);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Couldn't find ftb instances folder: " << instancesPath;
|
||||
}
|
||||
};
|
||||
|
||||
scanPath(APPLICATION->settings()->get("FTBAppInstancesPath").toString());
|
||||
scanPath(m_instances_path);
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
@@ -70,11 +101,11 @@ void ListModel::update()
|
||||
QVariant ListModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
int pos = index.row();
|
||||
if (pos >= modpacks.size() || pos < 0 || !index.isValid()) {
|
||||
if (pos >= m_modpacks.size() || pos < 0 || !index.isValid()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
auto pack = modpacks.at(pos);
|
||||
auto pack = m_modpacks.at(pos);
|
||||
if (role == Qt::ToolTipRole) {
|
||||
}
|
||||
|
||||
@@ -110,9 +141,9 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
|
||||
|
||||
FilterModel::FilterModel(QObject* parent) : QSortFilterProxyModel(parent)
|
||||
{
|
||||
currentSorting = Sorting::ByGameVersion;
|
||||
sortings.insert(tr("Sort by Name"), Sorting::ByName);
|
||||
sortings.insert(tr("Sort by Game Version"), Sorting::ByGameVersion);
|
||||
m_currentSorting = Sorting::ByGameVersion;
|
||||
m_sortings.insert(tr("Sort by Name"), Sorting::ByName);
|
||||
m_sortings.insert(tr("Sort by Game Version"), Sorting::ByGameVersion);
|
||||
}
|
||||
|
||||
bool FilterModel::lessThan(const QModelIndex& left, const QModelIndex& right) const
|
||||
@@ -120,12 +151,12 @@ bool FilterModel::lessThan(const QModelIndex& left, const QModelIndex& right) co
|
||||
Modpack leftPack = sourceModel()->data(left, Qt::UserRole).value<Modpack>();
|
||||
Modpack rightPack = sourceModel()->data(right, Qt::UserRole).value<Modpack>();
|
||||
|
||||
if (currentSorting == Sorting::ByGameVersion) {
|
||||
if (m_currentSorting == Sorting::ByGameVersion) {
|
||||
Version lv(leftPack.mcVersion);
|
||||
Version rv(rightPack.mcVersion);
|
||||
return lv < rv;
|
||||
|
||||
} else if (currentSorting == Sorting::ByName) {
|
||||
} else if (m_currentSorting == Sorting::ByName) {
|
||||
return StringUtils::naturalCompare(leftPack.name, rightPack.name, Qt::CaseSensitive) >= 0;
|
||||
}
|
||||
|
||||
@@ -136,39 +167,39 @@ bool FilterModel::lessThan(const QModelIndex& left, const QModelIndex& right) co
|
||||
|
||||
bool FilterModel::filterAcceptsRow([[maybe_unused]] int sourceRow, [[maybe_unused]] const QModelIndex& sourceParent) const
|
||||
{
|
||||
if (searchTerm.isEmpty()) {
|
||||
if (m_searchTerm.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
Modpack pack = sourceModel()->data(index, Qt::UserRole).value<Modpack>();
|
||||
return pack.name.contains(searchTerm, Qt::CaseInsensitive);
|
||||
return pack.name.contains(m_searchTerm, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
void FilterModel::setSearchTerm(const QString term)
|
||||
{
|
||||
searchTerm = term.trimmed();
|
||||
m_searchTerm = term.trimmed();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
const QMap<QString, FilterModel::Sorting> FilterModel::getAvailableSortings()
|
||||
{
|
||||
return sortings;
|
||||
return m_sortings;
|
||||
}
|
||||
|
||||
QString FilterModel::translateCurrentSorting()
|
||||
{
|
||||
return sortings.key(currentSorting);
|
||||
return m_sortings.key(m_currentSorting);
|
||||
}
|
||||
|
||||
void FilterModel::setSorting(Sorting s)
|
||||
{
|
||||
currentSorting = s;
|
||||
m_currentSorting = s;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
FilterModel::Sorting FilterModel::getCurrentSorting()
|
||||
{
|
||||
return currentSorting;
|
||||
return m_currentSorting;
|
||||
}
|
||||
void ListModel::setPath(QString path)
|
||||
{
|
||||
@@ -176,11 +207,11 @@ void ListModel::setPath(QString path)
|
||||
update();
|
||||
}
|
||||
|
||||
QString ListModel::getPath()
|
||||
QString ListModel::getUserPath()
|
||||
{
|
||||
auto path = APPLICATION->settings()->get("FTBAppInstancesPath").toString();
|
||||
if (path.isEmpty() || !QFileInfo(path).exists())
|
||||
path = FTB_APP_PATH;
|
||||
if (path.isEmpty())
|
||||
path = m_instances_path;
|
||||
return path;
|
||||
}
|
||||
} // namespace FTBImportAPP
|
||||
@@ -42,28 +42,29 @@ class FilterModel : public QSortFilterProxyModel {
|
||||
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
|
||||
|
||||
private:
|
||||
QMap<QString, Sorting> sortings;
|
||||
Sorting currentSorting;
|
||||
QString searchTerm;
|
||||
QMap<QString, Sorting> m_sortings;
|
||||
Sorting m_currentSorting;
|
||||
QString m_searchTerm;
|
||||
};
|
||||
|
||||
class ListModel : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ListModel(QObject* parent) : QAbstractListModel(parent) {}
|
||||
ListModel(QObject* parent);
|
||||
virtual ~ListModel() = default;
|
||||
|
||||
int rowCount(const QModelIndex& parent) const { return modpacks.size(); }
|
||||
int rowCount(const QModelIndex& parent) const { return m_modpacks.size(); }
|
||||
int columnCount(const QModelIndex& parent) const { return 1; }
|
||||
QVariant data(const QModelIndex& index, int role) const;
|
||||
|
||||
void update();
|
||||
|
||||
QString getPath();
|
||||
QString getUserPath();
|
||||
void setPath(QString path);
|
||||
|
||||
private:
|
||||
ModpackList modpacks;
|
||||
ModpackList m_modpacks;
|
||||
const QString m_instances_path;
|
||||
};
|
||||
} // namespace FTBImportAPP
|
||||
@@ -35,6 +35,7 @@
|
||||
*/
|
||||
|
||||
#include "Page.h"
|
||||
#include "StringUtils.h"
|
||||
#include "ui/widgets/ProjectItem.h"
|
||||
#include "ui_Page.h"
|
||||
|
||||
@@ -260,8 +261,9 @@ void Page::onPackSelectionChanged(Modpack* pack)
|
||||
{
|
||||
ui->versionSelectionBox->clear();
|
||||
if (pack) {
|
||||
currentModpackInfo->setHtml("Pack by <b>" + pack->author + "</b>" + "<br>Minecraft " + pack->mcVersion + "<br>" + "<br>" +
|
||||
pack->description + "<ul><li>" + pack->mods.replace(";", "</li><li>") + "</li></ul>");
|
||||
currentModpackInfo->setHtml(StringUtils::htmlListPatch("Pack by <b>" + pack->author + "</b>" + "<br>Minecraft " + pack->mcVersion +
|
||||
"<br>" + "<br>" + pack->description + "<ul><li>" +
|
||||
pack->mods.replace(";", "</li><li>") + "</li></ul>"));
|
||||
bool currentAdded = false;
|
||||
|
||||
for (int i = 0; i < pack->oldVersions.size(); i++) {
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "InstanceImportTask.h"
|
||||
#include "Json.h"
|
||||
#include "Markdown.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include "ui/widgets/ProjectItem.h"
|
||||
|
||||
@@ -223,11 +224,12 @@ void ModrinthPage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelI
|
||||
}
|
||||
for (auto version : current.versions) {
|
||||
auto release_type = version.version_type.isValid() ? QString(" [%1]").arg(version.version_type.toString()) : "";
|
||||
if (!version.name.contains(version.version))
|
||||
ui->versionSelectionBox->addItem(QString("%1 — %2%3").arg(version.name, version.version, release_type),
|
||||
QVariant(version.id));
|
||||
else
|
||||
ui->versionSelectionBox->addItem(QString("%1%2").arg(version.name, release_type), QVariant(version.id));
|
||||
auto mcVersion = !version.gameVersion.isEmpty() && !version.name.contains(version.gameVersion)
|
||||
? QString(" for %1").arg(version.gameVersion)
|
||||
: "";
|
||||
auto versionStr = !version.name.contains(version.version) ? version.version : "";
|
||||
ui->versionSelectionBox->addItem(QString("%1%2 — %3%4").arg(version.name, mcVersion, versionStr, release_type),
|
||||
QVariant(version.id));
|
||||
}
|
||||
|
||||
QVariant current_updated;
|
||||
@@ -304,7 +306,7 @@ void ModrinthPage::updateUI()
|
||||
|
||||
text += markdownToHTML(current.extra.body.toUtf8());
|
||||
|
||||
ui->packDescription->setHtml(text + current.description);
|
||||
ui->packDescription->setHtml(StringUtils::htmlListPatch(text + current.description));
|
||||
ui->packDescription->flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "BuildConfig.h"
|
||||
#include "Json.h"
|
||||
#include "StringUtils.h"
|
||||
#include "TechnicModel.h"
|
||||
#include "modplatform/technic/SingleZipPackInstallTask.h"
|
||||
#include "modplatform/technic/SolderPackInstallTask.h"
|
||||
@@ -233,7 +234,7 @@ void TechnicPage::metadataLoaded()
|
||||
|
||||
text += "<br><br>";
|
||||
|
||||
ui->packDescription->setHtml(text + current.description);
|
||||
ui->packDescription->setHtml(StringUtils::htmlListPatch(text + current.description));
|
||||
|
||||
// Strip trailing forward-slashes from Solder URL's
|
||||
if (current.isSolder) {
|
||||
|
||||
Reference in New Issue
Block a user