From df6e66101c2ce5635f20df2f1d7954a681845ab1 Mon Sep 17 00:00:00 2001 From: Janrupf Date: Thu, 5 Apr 2018 19:33:31 +0200 Subject: [PATCH] NOISSUE Added 3rd party pack support --- application/FtbListModel.cpp | 16 +++---- application/pages/modplatform/FTBPage.cpp | 11 +++++ application/pages/modplatform/FTBPage.h | 2 + application/pages/modplatform/FTBPage.ui | 56 +++++++++++------------ 4 files changed, 47 insertions(+), 38 deletions(-) diff --git a/application/FtbListModel.cpp b/application/FtbListModel.cpp index d8c18ee50..41e49b65c 100644 --- a/application/FtbListModel.cpp +++ b/application/FtbListModel.cpp @@ -172,22 +172,20 @@ void FtbListModel::requestLogo(QString file) return; } - MetaEntryPtr entry = ENV.metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file)); + MetaEntryPtr entry = ENV.metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file.section(".", 0, 0))); NetJob *job = new NetJob(QString("FTB Icon Download for %1").arg(file)); job->addNetAction(Net::Download::makeCached(QUrl(QString("https://ftb.cursecdn.com/FTB2/static/%1").arg(file)), entry)); - QString *_file = new QString(file); - MetaEntry *_entry = entry.get(); - - QObject::connect(job, &NetJob::finished, this, [this, _file, _entry]{ + auto fullPath = entry->getFullPath(); + QObject::connect(job, &NetJob::finished, this, [this, file, fullPath]{ QPixmap pixmap; - pixmap.load(_entry->getFullPath()); + pixmap.load(fullPath); pixmap = pixmap.scaled(QSize(42, 42)); - emit logoLoaded(*_file, pixmap); + emit logoLoaded(file, pixmap); }); - QObject::connect(job, &NetJob::failed, this, [this, _file]{ - emit logoFailed(*_file); + QObject::connect(job, &NetJob::failed, this, [this, file]{ + emit logoFailed(file); }); job->start(); diff --git a/application/pages/modplatform/FTBPage.cpp b/application/pages/modplatform/FTBPage.cpp index 3b8087998..8c8d8a7d5 100644 --- a/application/pages/modplatform/FTBPage.cpp +++ b/application/pages/modplatform/FTBPage.cpp @@ -53,7 +53,12 @@ FTBPage::FTBPage(NewInstanceDialog* dialog, QWidget *parent) connect(ui->publicPackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &FTBPage::onPublicPackSelectionChanged); connect(ui->thirdPartyPackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &FTBPage::onThirdPartyPackSelectionChanged); + connect(ui->ftbTabWidget, &QTabWidget::currentChanged, this, &FTBPage::onTabChanged); + ui->modpackInfo->setOpenExternalLinks(true); + + ui->publicPackList->selectionModel()->reset(); + ui->thirdPartyPackList->selectionModel()->reset(); } FTBPage::~FTBPage() @@ -172,3 +177,9 @@ void FTBPage::onSortingSelectionChanged(QString data) publicFilterModel->setSorting(toSet); thirdPartyFilterModel->setSorting(toSet); } + +void FTBPage::onTabChanged(int tab) +{ + ui->publicPackList->selectionModel()->reset(); + ui->thirdPartyPackList->selectionModel()->reset(); +} diff --git a/application/pages/modplatform/FTBPage.h b/application/pages/modplatform/FTBPage.h index ba8dd299d..413f5e285 100644 --- a/application/pages/modplatform/FTBPage.h +++ b/application/pages/modplatform/FTBPage.h @@ -75,6 +75,8 @@ private slots: void onPublicPackSelectionChanged(QModelIndex first, QModelIndex second); void onThirdPartyPackSelectionChanged(QModelIndex first, QModelIndex second); + void onTabChanged(int tab); + private: bool initialized = false; FtbModpack selectedPack; diff --git a/application/pages/modplatform/FTBPage.ui b/application/pages/modplatform/FTBPage.ui index ee91f1f5b..cb085af2c 100644 --- a/application/pages/modplatform/FTBPage.ui +++ b/application/pages/modplatform/FTBPage.ui @@ -10,7 +10,7 @@ 602 - + 0 @@ -23,7 +23,7 @@ 0 - + 0 @@ -57,7 +57,7 @@ - + 0 @@ -74,37 +74,35 @@ Public Packs - - - - 0 - 0 - 221 - 491 - - - - Qt::ScrollBarAlwaysOn - - + + + + + Qt::ScrollBarAsNeeded + + + Qt::ScrollBarAlwaysOff + + + + 3rd Party Packs - - - - 0 - 0 - 221 - 491 - - - - Qt::ScrollBarAlwaysOn - - + + + + + Qt::ScrollBarAsNeeded + + + Qt::ScrollBarAlwaysOff + + + +