Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into filters
This commit is contained in:
@@ -214,19 +214,25 @@ void ModUpdateDialog::checkCandidates()
|
||||
}
|
||||
static FlameAPI api;
|
||||
|
||||
auto getRequiredBy = depTask->getRequiredBy();
|
||||
auto dependencyExtraInfo = depTask->getExtraInfo();
|
||||
|
||||
for (auto dep : depTask->getDependecies()) {
|
||||
auto changelog = dep->version.changelog;
|
||||
if (dep->pack->provider == ModPlatform::ResourceProvider::FLAME)
|
||||
changelog = api.getModFileChangelog(dep->version.addonId.toInt(), dep->version.fileId.toInt());
|
||||
auto download_task = makeShared<ResourceDownloadTask>(dep->pack, dep->version, m_mod_model);
|
||||
CheckUpdateTask::UpdatableMod updatable = {
|
||||
dep->pack->name, dep->version.hash, "", dep->version.version, dep->version.version_type,
|
||||
changelog, dep->pack->provider, download_task
|
||||
};
|
||||
auto extraInfo = dependencyExtraInfo.value(dep->version.addonId.toString());
|
||||
CheckUpdateTask::UpdatableMod updatable = { dep->pack->name,
|
||||
dep->version.hash,
|
||||
"",
|
||||
dep->version.version,
|
||||
dep->version.version_type,
|
||||
changelog,
|
||||
dep->pack->provider,
|
||||
download_task,
|
||||
!extraInfo.maybe_installed };
|
||||
|
||||
appendMod(updatable, getRequiredBy.value(dep->version.addonId.toString()));
|
||||
appendMod(updatable, extraInfo.required_by);
|
||||
m_tasks.insert(updatable.name, updatable.download);
|
||||
}
|
||||
}
|
||||
@@ -412,7 +418,10 @@ void ModUpdateDialog::onMetadataFailed(Mod* mod, bool try_others, ModPlatform::R
|
||||
void ModUpdateDialog::appendMod(CheckUpdateTask::UpdatableMod const& info, QStringList requiredBy)
|
||||
{
|
||||
auto item_top = new QTreeWidgetItem(ui->modTreeWidget);
|
||||
item_top->setCheckState(0, Qt::CheckState::Checked);
|
||||
item_top->setCheckState(0, info.enabled ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
||||
if (!info.enabled) {
|
||||
item_top->setToolTip(0, tr("Mod was disabled as it may be already instaled."));
|
||||
}
|
||||
item_top->setText(0, info.name);
|
||||
item_top->setExpanded(true);
|
||||
|
||||
|
||||
@@ -97,6 +97,9 @@ NewInstanceDialog::NewInstanceDialog(const QString& initialGroup,
|
||||
ui->verticalLayout->insertWidget(2, m_container);
|
||||
|
||||
m_container->addButtons(m_buttons);
|
||||
connect(m_container, &PageContainer::selectedPageChanged, this, [this](BasePage* previous, BasePage* selected) {
|
||||
m_buttons->button(QDialogButtonBox::Ok)->setEnabled(creationTask && !instName().isEmpty());
|
||||
});
|
||||
|
||||
// Bonk Qt over its stupid head and make sure it understands which button is the default one...
|
||||
// See: https://stackoverflow.com/questions/24556831/qbuttonbox-set-default-button
|
||||
|
||||
@@ -133,7 +133,7 @@ void ResourceDownloadDialog::confirm()
|
||||
auto confirm_dialog = ReviewMessageBox::create(this, tr("Confirm %1 to download").arg(resourcesString()));
|
||||
confirm_dialog->retranslateUi(resourcesString());
|
||||
|
||||
QHash<QString, QStringList> getRequiredBy;
|
||||
QHash<QString, GetModDependenciesTask::PackDependencyExtraInfo> dependencyExtraInfo;
|
||||
if (auto task = getModDependenciesTask(); task) {
|
||||
connect(task.get(), &Task::failed, this,
|
||||
[&](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec(); });
|
||||
@@ -158,7 +158,7 @@ void ResourceDownloadDialog::confirm()
|
||||
} else {
|
||||
for (auto dep : task->getDependecies())
|
||||
addResource(dep->pack, dep->version);
|
||||
getRequiredBy = task->getRequiredBy();
|
||||
dependencyExtraInfo = task->getExtraInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,9 +167,10 @@ void ResourceDownloadDialog::confirm()
|
||||
return QString::compare(a->getName(), b->getName(), Qt::CaseInsensitive) < 0;
|
||||
});
|
||||
for (auto& task : selected) {
|
||||
auto extraInfo = dependencyExtraInfo.value(task->getPack()->addonId.toString());
|
||||
confirm_dialog->appendResource({ task->getName(), task->getFilename(), task->getCustomPath(),
|
||||
ProviderCaps.name(task->getProvider()), getRequiredBy.value(task->getPack()->addonId.toString()),
|
||||
task->getVersion().version_type.toString() });
|
||||
ProviderCaps.name(task->getProvider()), extraInfo.required_by,
|
||||
task->getVersion().version_type.toString(), !extraInfo.maybe_installed });
|
||||
}
|
||||
|
||||
if (confirm_dialog->exec()) {
|
||||
|
||||
@@ -35,8 +35,11 @@ auto ReviewMessageBox::create(QWidget* parent, QString&& title, QString&& icon)
|
||||
void ReviewMessageBox::appendResource(ResourceInformation&& info)
|
||||
{
|
||||
auto itemTop = new QTreeWidgetItem(ui->modTreeWidget);
|
||||
itemTop->setCheckState(0, Qt::CheckState::Checked);
|
||||
itemTop->setCheckState(0, info.enabled ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
||||
itemTop->setText(0, info.name);
|
||||
if (!info.enabled) {
|
||||
itemTop->setToolTip(0, tr("Mod was disabled as it may be already instaled."));
|
||||
}
|
||||
|
||||
auto filenameItem = new QTreeWidgetItem(itemTop);
|
||||
filenameItem->setText(0, tr("Filename: %1").arg(info.filename));
|
||||
|
||||
@@ -20,6 +20,7 @@ class ReviewMessageBox : public QDialog {
|
||||
QString provider;
|
||||
QStringList required_by;
|
||||
QString version_type;
|
||||
bool enabled = true;
|
||||
};
|
||||
|
||||
void appendResource(ResourceInformation&& info);
|
||||
|
||||
@@ -465,7 +465,7 @@ void InstanceView::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
widWidth = m_catPixmap.width();
|
||||
if (m_catPixmap.height() < widHeight)
|
||||
widHeight = m_catPixmap.height();
|
||||
auto pixmap = m_catPixmap.scaled(widWidth, widHeight, Qt::KeepAspectRatio);
|
||||
auto pixmap = m_catPixmap.scaled(widWidth, widHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
QRect rectOfPixmap = pixmap.rect();
|
||||
rectOfPixmap.moveBottomRight(this->viewport()->rect().bottomRight());
|
||||
painter.drawPixmap(rectOfPixmap.topLeft(), pixmap);
|
||||
|
||||
@@ -93,6 +93,7 @@ void ModPage::triggerSearch()
|
||||
{
|
||||
auto changed = m_filter_widget->changed();
|
||||
m_filter = m_filter_widget->getFilter();
|
||||
m_ui->packView->selectionModel()->setCurrentIndex({}, QItemSelectionModel::SelectionFlag::ClearAndSelect);
|
||||
m_ui->packView->clearSelection();
|
||||
m_ui->packDescription->clear();
|
||||
m_ui->versionSelectionBox->clear();
|
||||
|
||||
@@ -23,6 +23,7 @@ ResourcePackResourcePage::ResourcePackResourcePage(ResourceDownloadDialog* dialo
|
||||
|
||||
void ResourcePackResourcePage::triggerSearch()
|
||||
{
|
||||
m_ui->packView->selectionModel()->setCurrentIndex({}, QItemSelectionModel::SelectionFlag::ClearAndSelect);
|
||||
m_ui->packView->clearSelection();
|
||||
m_ui->packDescription->clear();
|
||||
m_ui->versionSelectionBox->clear();
|
||||
|
||||
@@ -24,6 +24,7 @@ ShaderPackResourcePage::ShaderPackResourcePage(ShaderPackDownloadDialog* dialog,
|
||||
|
||||
void ShaderPackResourcePage::triggerSearch()
|
||||
{
|
||||
m_ui->packView->selectionModel()->setCurrentIndex({}, QItemSelectionModel::SelectionFlag::ClearAndSelect);
|
||||
m_ui->packView->clearSelection();
|
||||
m_ui->packDescription->clear();
|
||||
m_ui->versionSelectionBox->clear();
|
||||
|
||||
@@ -104,6 +104,7 @@ void ModrinthPage::retranslate()
|
||||
void ModrinthPage::openedImpl()
|
||||
{
|
||||
BasePage::openedImpl();
|
||||
suggestCurrent();
|
||||
triggerSearch();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,10 @@
|
||||
#include "ui/themes/CatPack.h"
|
||||
#include <QDate>
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
#include <QImageReader>
|
||||
#include <QRandomGenerator>
|
||||
#include "FileSystem.h"
|
||||
#include "Json.h"
|
||||
|
||||
@@ -79,7 +82,7 @@ JsonCatPack::JsonCatPack(QFileInfo& manifestInfo) : BasicCatPack(manifestInfo.di
|
||||
auto doc = Json::requireDocument(manifestInfo.absoluteFilePath(), "CatPack JSON file");
|
||||
const auto root = doc.object();
|
||||
m_name = Json::requireString(root, "name", "Catpack name");
|
||||
m_defaultPath = FS::PathCombine(path, Json::requireString(root, "default", "Default Cat"));
|
||||
m_default_path = FS::PathCombine(path, Json::requireString(root, "default", "Default Cat"));
|
||||
auto variants = Json::ensureArray(root, "variants", QJsonArray(), "Catpack Variants");
|
||||
for (auto v : variants) {
|
||||
auto variant = Json::ensureObject(v, QJsonObject(), "Cat variant");
|
||||
@@ -117,5 +120,21 @@ QString JsonCatPack::path(QDate now)
|
||||
if (startDate <= now && now <= endDate)
|
||||
return var.path;
|
||||
}
|
||||
return m_defaultPath;
|
||||
auto dInfo = QFileInfo(m_default_path);
|
||||
if (!dInfo.isDir())
|
||||
return m_default_path;
|
||||
|
||||
QStringList supportedImageFormats;
|
||||
for (auto format : QImageReader::supportedImageFormats()) {
|
||||
supportedImageFormats.append("*." + format);
|
||||
}
|
||||
|
||||
auto files = QDir(m_default_path).entryInfoList(supportedImageFormats, QDir::Files, QDir::Name);
|
||||
if (files.length() == 0)
|
||||
return "";
|
||||
auto idx = (now.dayOfYear() - 1) % files.length();
|
||||
auto isRandom = dInfo.fileName().compare("random", Qt::CaseInsensitive) == 0;
|
||||
if (isRandom)
|
||||
idx = QRandomGenerator::global()->bounded(0, files.length());
|
||||
return files[idx].absoluteFilePath();
|
||||
}
|
||||
|
||||
@@ -87,6 +87,6 @@ class JsonCatPack : public BasicCatPack {
|
||||
QString path(QDate now);
|
||||
|
||||
private:
|
||||
QString m_defaultPath;
|
||||
QString m_default_path;
|
||||
QList<Variant> m_variants;
|
||||
};
|
||||
|
||||
@@ -178,8 +178,8 @@ QList<ITheme*> ThemeManager::getValidApplicationThemes()
|
||||
QList<CatPack*> ThemeManager::getValidCatPacks()
|
||||
{
|
||||
QList<CatPack*> ret;
|
||||
ret.reserve(m_catPacks.size());
|
||||
for (auto&& [id, theme] : m_catPacks) {
|
||||
ret.reserve(m_cat_packs.size());
|
||||
for (auto&& [id, theme] : m_cat_packs) {
|
||||
ret.append(theme.get());
|
||||
}
|
||||
return ret;
|
||||
@@ -244,8 +244,8 @@ void ThemeManager::applyCurrentlySelectedTheme(bool initial)
|
||||
|
||||
QString ThemeManager::getCatPack(QString catName)
|
||||
{
|
||||
auto catIter = m_catPacks.find(!catName.isEmpty() ? catName : APPLICATION->settings()->get("BackgroundCat").toString());
|
||||
if (catIter != m_catPacks.end()) {
|
||||
auto catIter = m_cat_packs.find(!catName.isEmpty() ? catName : APPLICATION->settings()->get("BackgroundCat").toString());
|
||||
if (catIter != m_cat_packs.end()) {
|
||||
auto& catPack = catIter->second;
|
||||
themeDebugLog() << "applying catpack" << catPack->id();
|
||||
return catPack->path();
|
||||
@@ -253,14 +253,14 @@ QString ThemeManager::getCatPack(QString catName)
|
||||
themeWarningLog() << "Tried to get invalid catPack:" << catName;
|
||||
}
|
||||
|
||||
return m_catPacks.begin()->second->path();
|
||||
return m_cat_packs.begin()->second->path();
|
||||
}
|
||||
|
||||
QString ThemeManager::addCatPack(std::unique_ptr<CatPack> catPack)
|
||||
{
|
||||
QString id = catPack->id();
|
||||
if (m_catPacks.find(id) == m_catPacks.end())
|
||||
m_catPacks.emplace(id, std::move(catPack));
|
||||
if (m_cat_packs.find(id) == m_cat_packs.end())
|
||||
m_cat_packs.emplace(id, std::move(catPack));
|
||||
else
|
||||
themeWarningLog() << "CatPack(" << id << ") not added to prevent id duplication";
|
||||
return id;
|
||||
|
||||
@@ -61,7 +61,7 @@ class ThemeManager {
|
||||
QDir m_iconThemeFolder{ "iconthemes" };
|
||||
QDir m_applicationThemeFolder{ "themes" };
|
||||
QDir m_catPacksFolder{ "catpacks" };
|
||||
std::map<QString, std::unique_ptr<CatPack>> m_catPacks;
|
||||
std::map<QString, std::unique_ptr<CatPack>> m_cat_packs;
|
||||
|
||||
void initializeThemes();
|
||||
void initializeCatPacks();
|
||||
|
||||
Reference in New Issue
Block a user