summaryrefslogtreecommitdiffstats
path: root/application/pages/modplatform
diff options
context:
space:
mode:
authorJanrupf <werbung.janrupf@t-online.de>2018-04-07 16:15:58 +0200
committerPetr Mrázek <peterix@gmail.com>2018-04-07 22:09:19 +0200
commit7e1c5d439a2ef6ce1346a3581776f58508a22afe (patch)
treeed9e037feaee01e100cee36369274492155a8833 /application/pages/modplatform
parent38ed0c2a1ff5839cc5b7a1addd25932a7c88b4de (diff)
downloadMultiMC-7e1c5d439a2ef6ce1346a3581776f58508a22afe.tar
MultiMC-7e1c5d439a2ef6ce1346a3581776f58508a22afe.tar.gz
MultiMC-7e1c5d439a2ef6ce1346a3581776f58508a22afe.tar.lz
MultiMC-7e1c5d439a2ef6ce1346a3581776f58508a22afe.tar.xz
MultiMC-7e1c5d439a2ef6ce1346a3581776f58508a22afe.zip
#2228, #2229 - Auto import pack icons and fixed to big version selection - Closes #2228, Closes #2229
Diffstat (limited to 'application/pages/modplatform')
-rw-r--r--application/pages/modplatform/FTBPage.cpp12
-rw-r--r--application/pages/modplatform/FtbListModel.cpp12
-rw-r--r--application/pages/modplatform/FtbListModel.h4
3 files changed, 27 insertions, 1 deletions
diff --git a/application/pages/modplatform/FTBPage.cpp b/application/pages/modplatform/FTBPage.cpp
index 7f8ee54e..f438fce7 100644
--- a/application/pages/modplatform/FTBPage.cpp
+++ b/application/pages/modplatform/FTBPage.cpp
@@ -50,6 +50,9 @@ FTBPage::FTBPage(NewInstanceDialog* dialog, QWidget *parent)
thirdPartyFilterModel->setSorting(publicFilterModel->getCurrentSorting());
}
+ ui->packVersionSelection->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ ui->packVersionSelection->view()->parentWidget()->setMaximumHeight(300);
+
connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &FTBPage::onSortingSelectionChanged);
connect(ui->packVersionSelection, &QComboBox::currentTextChanged, this, &FTBPage::onVersionSelectionItemChanged);
@@ -96,6 +99,15 @@ void FTBPage::suggestCurrent()
if(!selected.broken)
{
dialog->setSuggestedPack(selected.name, new FtbPackInstallTask(selected, selectedVersion));
+ if(selected.type == FtbPackType::Public) {
+ publicListModel->getLogo(selected.logo, [this](QString logo){
+ dialog->setSuggestedIconFromFile(logo, "ftb_" + selected.name);
+ });
+ } else if (selected.type == FtbPackType::ThirdParty) {
+ thirdPartyModel->getLogo(selected.logo, [this](QString logo){
+ dialog->setSuggestedIconFromFile(logo, "ftb_" + selected.name);
+ });
+ }
}
else
{
diff --git a/application/pages/modplatform/FtbListModel.cpp b/application/pages/modplatform/FtbListModel.cpp
index 8e52f541..c14907c6 100644
--- a/application/pages/modplatform/FtbListModel.cpp
+++ b/application/pages/modplatform/FtbListModel.cpp
@@ -175,6 +175,9 @@ void FtbListModel::requestLogo(QString file)
auto fullPath = entry->getFullPath();
QObject::connect(job, &NetJob::finished, this, [this, file, fullPath]{
emit logoLoaded(file, QIcon(fullPath));
+ if(waitingCallbacks.contains(file)) {
+ waitingCallbacks.value(file)(fullPath);
+ }
});
QObject::connect(job, &NetJob::failed, this, [this, file]{
@@ -185,3 +188,12 @@ void FtbListModel::requestLogo(QString file)
m_loadingLogos.append(file);
}
+
+void FtbListModel::getLogo(const QString &logo, LogoCallback callback)
+{
+ if(m_logoMap.contains(logo)) {
+ callback(ENV.metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
+ } else {
+ requestLogo(logo);
+ }
+}
diff --git a/application/pages/modplatform/FtbListModel.h b/application/pages/modplatform/FtbListModel.h
index 12b26be1..5f6c9db1 100644
--- a/application/pages/modplatform/FtbListModel.h
+++ b/application/pages/modplatform/FtbListModel.h
@@ -10,6 +10,7 @@
#include <QIcon>
typedef QMap<QString, QIcon> FtbLogoMap;
+typedef std::function<void(QString)> LogoCallback;
class FtbFilterModel : public QSortFilterProxyModel
{
@@ -42,6 +43,7 @@ private:
QStringList m_failedLogos;
QStringList m_loadingLogos;
FtbLogoMap m_logoMap;
+ QMap<QString, LogoCallback> waitingCallbacks;
void requestLogo(QString file);
QString translatePackType(FtbPackType type) const;
@@ -61,5 +63,5 @@ public:
void fill(FtbModpackList modpacks);
FtbModpack at(int row);
-
+ void getLogo(const QString &logo, LogoCallback callback);
};