GH-3720 Fix UI inconsistencies with Modplatforms

Fixes GH-3118
Fixes GH-3720
Fixes GH-3731

Icons and Ok button state will now switch consistently when moving
between tabs. ATLaunchers packlist is now no longer redownloaded
each time you open its Tab. All lists are striped now. And all
search and filter fields now have a placeholder text.
This commit is contained in:
phit 2021-06-19 16:19:39 +02:00
parent 5f8d07c009
commit f7c144c393
15 changed files with 205 additions and 115 deletions

View File

@ -173,6 +173,14 @@ void NewInstanceDialog::setSuggestedIconFromFile(const QString &path, const QStr
ui->iconButton->setIcon(QIcon(path)); ui->iconButton->setIcon(QIcon(path));
} }
void NewInstanceDialog::setSuggestedIcon(const QString &key)
{
auto icon = MMC->icons()->getIcon(key);
importIcon = false;
ui->iconButton->setIcon(icon);
}
InstanceTask * NewInstanceDialog::extractTask() InstanceTask * NewInstanceDialog::extractTask()
{ {
InstanceTask * extracted = creationTask.get(); InstanceTask * extracted = creationTask.get();

View File

@ -43,6 +43,7 @@ public:
void setSuggestedPack(const QString & name = QString(), InstanceTask * task = nullptr); void setSuggestedPack(const QString & name = QString(), InstanceTask * task = nullptr);
void setSuggestedIconFromFile(const QString &path, const QString &name); void setSuggestedIconFromFile(const QString &path, const QString &name);
void setSuggestedIcon(const QString &key);
InstanceTask * extractTask(); InstanceTask * extractTask();

View File

@ -71,6 +71,7 @@ void ImportPage::updateState()
{ {
QFileInfo fi(url.fileName()); QFileInfo fi(url.fileName());
dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url)); dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url));
dialog->setSuggestedIcon("default");
} }
} }
else else
@ -83,6 +84,7 @@ void ImportPage::updateState()
// hook, line and sinker. // hook, line and sinker.
QFileInfo fi(url.fileName()); QFileInfo fi(url.fileName());
dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url)); dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url));
dialog->setSuggestedIcon("default");
} }
} }
else else

View File

@ -82,10 +82,19 @@ BaseVersionPtr VanillaPage::selectedVersion() const
void VanillaPage::suggestCurrent() void VanillaPage::suggestCurrent()
{ {
if(m_selectedVersion && isOpened) if (!isOpened)
{ {
dialog->setSuggestedPack(m_selectedVersion->descriptor(), new InstanceCreationTask(m_selectedVersion)); return;
} }
if(!m_selectedVersion)
{
dialog->setSuggestedPack();
return;
}
dialog->setSuggestedPack(m_selectedVersion->descriptor(), new InstanceCreationTask(m_selectedVersion));
dialog->setSuggestedIcon("default");
} }
void VanillaPage::setSelectedVersion(BaseVersionPtr version) void VanillaPage::setSelectedVersion(BaseVersionPtr version)

View File

@ -45,15 +45,29 @@ bool AtlPage::shouldDisplay() const
void AtlPage::openedImpl() void AtlPage::openedImpl()
{ {
if(!initialized)
{
listModel->request(); listModel->request();
initialized = true;
}
suggestCurrent();
} }
void AtlPage::suggestCurrent() void AtlPage::suggestCurrent()
{ {
if(isOpened) { if(!isOpened)
dialog->setSuggestedPack(selected.name, new ATLauncher::PackInstallTask(this, selected.safeName, selectedVersion)); {
return;
} }
if (selectedVersion.isEmpty())
{
dialog->setSuggestedPack();
return;
}
dialog->setSuggestedPack(selected.name, new ATLauncher::PackInstallTask(this, selected.safeName, selectedVersion));
auto editedLogoName = selected.safeName; auto editedLogoName = selected.safeName;
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/images/%1.png").arg(selected.safeName.toLower()); auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/images/%1.png").arg(selected.safeName.toLower());
listModel->getLogo(selected.safeName, url, [this, editedLogoName](QString logo) listModel->getLogo(selected.safeName, url, [this, editedLogoName](QString logo)

View File

@ -81,4 +81,6 @@ private:
ATLauncher::IndexedPack selected; ATLauncher::IndexedPack selected;
QString selectedVersion; QString selectedVersion;
bool initialized = false;
}; };

View File

@ -21,6 +21,9 @@
<height>48</height> <height>48</height>
</size> </size>
</property> </property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
@ -48,7 +51,14 @@
<item row="2" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0" rowminimumheight="0" columnminimumwidth="0,0,0"> <layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0" rowminimumheight="0" columnminimumwidth="0,0,0">
<item row="0" column="2"> <item row="0" column="2">
<widget class="QComboBox" name="versionSelectionBox"/> <widget class="QComboBox" name="versionSelectionBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">

View File

@ -18,6 +18,8 @@ FlamePage::FlamePage(NewInstanceDialog* dialog, QWidget *parent)
ui->packView->setModel(listModel); ui->packView->setModel(listModel);
ui->versionSelectionBox->setMaxVisibleItems(10); ui->versionSelectionBox->setMaxVisibleItems(10);
// fix height for themes that dont respect max visible like fusion
ui->versionSelectionBox->setStyleSheet("combobox-popup: 0;");
// index is used to set the sorting with the curseforge api // index is used to set the sorting with the curseforge api
ui->sortByBox->addItem(tr("Sort by featured")); ui->sortByBox->addItem(tr("Sort by featured"));
@ -157,6 +159,12 @@ void FlamePage::suggestCurrent()
return; return;
} }
if (selectedVersion.isEmpty())
{
dialog->setSuggestedPack();
return;
}
dialog->setSuggestedPack(current.name, new InstanceImportTask(selectedVersion)); dialog->setSuggestedPack(current.name, new InstanceImportTask(selectedVersion));
QString editedLogoName; QString editedLogoName;
editedLogoName = "curseforge_" + current.logoName.section(".", 0, 0); editedLogoName = "curseforge_" + current.logoName.section(".", 0, 0);

View File

@ -60,16 +60,24 @@ bool FtbPage::shouldDisplay() const
void FtbPage::openedImpl() void FtbPage::openedImpl()
{ {
dialog->setSuggestedPack();
triggerSearch(); triggerSearch();
suggestCurrent();
} }
void FtbPage::suggestCurrent() void FtbPage::suggestCurrent()
{ {
if(isOpened) if(!isOpened)
{ {
dialog->setSuggestedPack(selected.name, new ModpacksCH::PackInstallTask(selected, selectedVersion)); return;
}
if (selectedVersion.isEmpty())
{
dialog->setSuggestedPack();
return;
}
dialog->setSuggestedPack(selected.name, new ModpacksCH::PackInstallTask(selected, selectedVersion));
for(auto art : selected.art) { for(auto art : selected.art) {
if(art.type == "square") { if(art.type == "square") {
QString editedLogoName; QString editedLogoName;
@ -81,7 +89,6 @@ void FtbPage::suggestCurrent()
}); });
} }
} }
}
} }
void FtbPage::triggerSearch() void FtbPage::triggerSearch()

View File

@ -32,7 +32,11 @@
</layout> </layout>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLineEdit" name="searchEdit"/> <widget class="QLineEdit" name="searchEdit">
<property name="placeholderText">
<string>Search and filter ...</string>
</property>
</widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QPushButton" name="searchButton"> <widget class="QPushButton" name="searchButton">
@ -51,6 +55,9 @@
<height>48</height> <height>48</height>
</size> </size>
</property> </property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">

View File

@ -122,10 +122,17 @@ void Page::openedImpl()
void Page::suggestCurrent() void Page::suggestCurrent()
{ {
if(isOpened) if(!isOpened)
{ {
if(!selected.broken) return;
}
if(!selected.broken || !selectedVersion.isEmpty())
{ {
dialog->setSuggestedPack();
return;
}
dialog->setSuggestedPack(selected.name, new PackInstallTask(selected, selectedVersion)); dialog->setSuggestedPack(selected.name, new PackInstallTask(selected, selectedVersion));
QString editedLogoName; QString editedLogoName;
if(selected.logo.toLower().startsWith("ftb")) if(selected.logo.toLower().startsWith("ftb"))
@ -160,12 +167,6 @@ void Page::suggestCurrent()
dialog->setSuggestedIconFromFile(logo, editedLogoName); dialog->setSuggestedIconFromFile(logo, editedLogoName);
}); });
} }
}
else
{
dialog->setSuggestedPack();
}
}
} }
void Page::ftbPackDataDownloadSuccessfully(ModpackList publicPacks, ModpackList thirdPartyPacks) void Page::ftbPackDataDownloadSuccessfully(ModpackList publicPacks, ModpackList thirdPartyPacks)

View File

@ -29,6 +29,9 @@
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
@ -52,6 +55,9 @@
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -69,6 +75,9 @@
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">

View File

@ -72,7 +72,7 @@ int Technic::ListModel::rowCount(const QModelIndex&) const
void Technic::ListModel::searchWithTerm(const QString& term) void Technic::ListModel::searchWithTerm(const QString& term)
{ {
if(currentSearchTerm == term) { if(currentSearchTerm == term && currentSearchTerm.isNull() == term.isNull()) {
return; return;
} }
currentSearchTerm = term; currentSearchTerm = term;
@ -93,9 +93,18 @@ void Technic::ListModel::searchWithTerm(const QString& term)
void Technic::ListModel::performSearch() void Technic::ListModel::performSearch()
{ {
NetJob *netJob = new NetJob("Technic::Search"); NetJob *netJob = new NetJob("Technic::Search");
auto searchUrl = QString( QString searchUrl = "";
if (currentSearchTerm.isEmpty()) {
searchUrl = QString(
"https://api.technicpack.net/trending?build=multimc"
).arg(currentSearchTerm);
}
else
{
searchUrl = QString(
"https://api.technicpack.net/search?build=multimc&q=%1" "https://api.technicpack.net/search?build=multimc&q=%1"
).arg(currentSearchTerm); ).arg(currentSearchTerm);
}
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response)); netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
jobPtr = netJob; jobPtr = netJob;
jobPtr->start(); jobPtr->start();

View File

@ -60,7 +60,8 @@ bool TechnicPage::shouldDisplay() const
void TechnicPage::openedImpl() void TechnicPage::openedImpl()
{ {
dialog->setSuggestedPack(); suggestCurrent();
triggerSearch();
} }
void TechnicPage::triggerSearch() { void TechnicPage::triggerSearch() {
@ -95,8 +96,7 @@ void TechnicPage::suggestCurrent()
return; return;
} }
QString editedLogoName; QString editedLogoName = "technic_" + current.logoName.section(".", 0, 0);
editedLogoName = "technic_" + current.logoName.section(".", 0, 0);
model->getLogo(current.logoName, current.logoUrl, [this, editedLogoName](QString logo) model->getLogo(current.logoName, current.logoUrl, [this, editedLogoName](QString logo)
{ {
dialog->setSuggestedIconFromFile(logo, editedLogoName); dialog->setSuggestedIconFromFile(logo, editedLogoName);
@ -105,9 +105,9 @@ void TechnicPage::suggestCurrent()
if (current.metadataLoaded) if (current.metadataLoaded)
{ {
metadataLoaded(); metadataLoaded();
return;
} }
else
{
NetJob *netJob = new NetJob(QString("Technic::PackMeta(%1)").arg(current.name)); NetJob *netJob = new NetJob(QString("Technic::PackMeta(%1)").arg(current.name));
std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>(); std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>();
QString slug = current.slug; QString slug = current.slug;
@ -165,7 +165,6 @@ void TechnicPage::suggestCurrent()
metadataLoaded(); metadataLoaded();
}); });
netJob->start(); netJob->start();
}
} }
// expects current.metadataLoaded to be true // expects current.metadataLoaded to be true

View File

@ -27,7 +27,11 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLineEdit" name="searchEdit"/> <widget class="QLineEdit" name="searchEdit">
<property name="placeholderText">
<string>Search and filter ...</string>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="searchButton"> <widget class="QPushButton" name="searchButton">