diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-05-04 22:35:16 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-05-04 22:35:16 +0300 |
commit | 8b14b946e248c327046777eb2ed494170452f108 (patch) | |
tree | aa19e6bffe19775623ada24e38d724031480f40a /launcher/ui | |
parent | f7b912fc9d804902a725fa903be8574e1e202f69 (diff) | |
parent | e4449a0ba32593b4fd76e3f2ced176e5b3bbd952 (diff) | |
download | PrismLauncher-8b14b946e248c327046777eb2ed494170452f108.tar.gz PrismLauncher-8b14b946e248c327046777eb2ed494170452f108.tar.bz2 PrismLauncher-8b14b946e248c327046777eb2ed494170452f108.zip |
Merge branch 'Fix_Assert' of github.com:Trial97/PrismLauncher into develop
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/ui')
-rw-r--r-- | launcher/ui/dialogs/ResourceDownloadDialog.cpp | 75 | ||||
-rw-r--r-- | launcher/ui/dialogs/ResourceDownloadDialog.h | 9 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/ModModel.cpp | 15 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/ModPage.cpp | 7 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/ModPage.h | 2 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/ResourceModel.cpp | 70 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/ResourceModel.h | 14 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/ResourcePage.cpp | 17 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/ResourcePage.h | 13 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/ShaderPackPage.cpp | 10 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/ShaderPackPage.h | 2 | ||||
-rw-r--r-- | launcher/ui/widgets/PageContainer.cpp | 5 | ||||
-rw-r--r-- | launcher/ui/widgets/PageContainer.h | 1 |
13 files changed, 122 insertions, 118 deletions
diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp index ca2d409c..c74aaace 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp +++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp @@ -23,7 +23,6 @@ #include <QPushButton> #include <algorithm> -#include <memory> #include "Application.h" #include "ResourceDownloadTask.h" @@ -126,13 +125,12 @@ void ResourceDownloadDialog::connectButtons() static ModPlatform::ProviderCapabilities ProviderCaps; -QStringList ResourceDownloadDialog::getReqiredBy(QList<QVariant> req_by) +QStringList getReqiredBy(QList<ResourceDownloadDialog::DownloadTaskPtr> tasks, QList<QVariant> req_by) { auto req = QStringList(); - auto keys = m_selected.keys(); for (auto r : req_by) { - for (auto& task : keys) { - auto selected = m_selected.constFind(task).value()->getPack(); + for (auto& task : tasks) { + auto selected = task->getPack(); if (selected.addonId == r) { req.append(selected.name); break; @@ -170,23 +168,25 @@ void ResourceDownloadDialog::confirm() return; } else for (auto dep : task->getDependecies()) { - addResource(dep->pack, dep->version, true); + addResource(dep->pack, dep->version); } } - auto keys = m_selected.keys(); - keys.sort(Qt::CaseInsensitive); - for (auto& task : keys) { - auto selected = m_selected.constFind(task).value(); - auto required_by = getReqiredBy(selected->getVersion().required_by); - confirm_dialog->appendResource( - { task, selected->getFilename(), selected->getCustomPath(), ProviderCaps.name(selected->getProvider()), required_by }); + auto selected = getTasks(); + std::sort(selected.begin(), selected.end(), [](const DownloadTaskPtr& a, const DownloadTaskPtr& b) { + return QString::compare(a->getName(), b->getName(), Qt::CaseInsensitive) < 0; + }); + for (auto& task : selected) { + confirm_dialog->appendResource({ task->getName(), task->getFilename(), task->getCustomPath(), + ProviderCaps.name(task->getProvider()), getReqiredBy(selected, task->getVersion().required_by) }); } if (confirm_dialog->exec()) { auto deselected = confirm_dialog->deselectedResources(); - for (auto name : deselected) { - m_selected.remove(name); + for (auto page : m_container->getPages()) { + auto res = static_cast<ResourcePage*>(page); + for (auto name : deselected) + res->removeResourceFromPage(name); } this->accept(); @@ -203,32 +203,39 @@ ResourcePage* ResourceDownloadDialog::getSelectedPage() return m_selectedPage; } -void ResourceDownloadDialog::addResource(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& ver, bool is_indexed) +void ResourceDownloadDialog::addResource(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& ver) { - removeResource(pack, ver); - - ver.is_currently_selected = true; - m_selected.insert(pack.name, makeShared<ResourceDownloadTask>(pack, ver, getBaseModel(), is_indexed)); - - m_buttons.button(QDialogButtonBox::Ok)->setEnabled(!m_selected.isEmpty()); + removeResource(pack.name); + m_selectedPage->addResourceToPage(pack, ver, getBaseModel()); + setButtonStatus(); } -void ResourceDownloadDialog::removeResource(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& ver) +void ResourceDownloadDialog::removeResource(const QString& pack_name) { - dynamic_cast<ResourcePage*>(m_container->getPage(Modrinth::id()))->removeResourceFromPage(pack.name); - dynamic_cast<ResourcePage*>(m_container->getPage(Flame::id()))->removeResourceFromPage(pack.name); - - // Deselect the new version too, since all versions of that pack got removed. - ver.is_currently_selected = false; - - m_selected.remove(pack.name); + for (auto page : m_container->getPages()) { + static_cast<ResourcePage*>(page)->removeResourceFromPage(pack_name); + } + setButtonStatus(); +} - m_buttons.button(QDialogButtonBox::Ok)->setEnabled(!m_selected.isEmpty()); +void ResourceDownloadDialog::setButtonStatus() +{ + auto selected = false; + for (auto page : m_container->getPages()) { + auto res = static_cast<ResourcePage*>(page); + selected = selected || res->hasSelectedPacks(); + } + m_buttons.button(QDialogButtonBox::Ok)->setEnabled(selected); } const QList<ResourceDownloadDialog::DownloadTaskPtr> ResourceDownloadDialog::getTasks() { - return m_selected.values(); + QList<DownloadTaskPtr> selected; + for (auto page : m_container->getPages()) { + auto res = static_cast<ResourcePage*>(page); + selected.append(res->selectedPacks()); + } + return selected; } void ResourceDownloadDialog::selectedPageChanged(BasePage* previous, BasePage* selected) @@ -277,10 +284,8 @@ QList<BasePage*> ModDownloadDialog::getPages() GetModDependenciesTask::Ptr ModDownloadDialog::getModDependenciesTask() { if (auto model = dynamic_cast<ModFolderModel*>(getBaseModel().get()); model) { - auto keys = m_selected.keys(); QList<std::shared_ptr<GetModDependenciesTask::PackDependency>> selectedVers; - for (auto& task : keys) { - auto selected = m_selected.constFind(task).value(); + for (auto& selected : getTasks()) { selectedVers.append(std::make_shared<GetModDependenciesTask::PackDependency>(selected->getPack(), selected->getVersion())); } diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.h b/launcher/ui/dialogs/ResourceDownloadDialog.h index 1145f63a..08436a9f 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.h +++ b/launcher/ui/dialogs/ResourceDownloadDialog.h @@ -63,8 +63,8 @@ class ResourceDownloadDialog : public QDialog, public BasePageProvider { bool selectPage(QString pageId); ResourcePage* getSelectedPage(); - void addResource(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&, bool is_indexed = false); - void removeResource(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&); + void addResource(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&); + void removeResource(const QString&); const QList<DownloadTaskPtr> getTasks(); [[nodiscard]] const std::shared_ptr<ResourceFolderModel> getBaseModel() const { return m_base_model; } @@ -80,11 +80,10 @@ class ResourceDownloadDialog : public QDialog, public BasePageProvider { protected: [[nodiscard]] virtual QString geometrySaveKey() const { return ""; } + void setButtonStatus(); [[nodiscard]] virtual GetModDependenciesTask::Ptr getModDependenciesTask() { return nullptr; } - QStringList getReqiredBy(QList<QVariant> req_by); - protected: const std::shared_ptr<ResourceFolderModel> m_base_model; @@ -93,8 +92,6 @@ class ResourceDownloadDialog : public QDialog, public BasePageProvider { QDialogButtonBox m_buttons; QVBoxLayout m_vertical_layout; - - QHash<QString, DownloadTaskPtr> m_selected; }; class ModDownloadDialog final : public ResourceDownloadDialog { diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp index 251200f7..3ffe6cb0 100644 --- a/launcher/ui/pages/modplatform/ModModel.cpp +++ b/launcher/ui/pages/modplatform/ModModel.cpp @@ -6,23 +6,12 @@ #include "minecraft/MinecraftInstance.h" #include "minecraft/PackProfile.h" -#include "minecraft/mod/ModFolderModel.h" -#include "modplatform/ModIndex.h" #include <QMessageBox> namespace ResourceDownload { -ModModel::ModModel(BaseInstance const& base_inst, ResourceAPI* api) : ResourceModel(api), m_base_instance(base_inst) -{ - auto folder = static_cast<MinecraftInstance const&>(m_base_instance).loaderModList(); - for (auto mod : folder->allMods()) { - auto meta = mod->metadata(); - ModPlatform::IndexedPack pack{ meta->project_id, meta->provider, meta->name, meta->slug }; - pack.loadedFileId = meta->file_id; - addPack(pack); - } -} +ModModel::ModModel(BaseInstance const& base_inst, ResourceAPI* api) : ResourceModel(api), m_base_instance(base_inst) {} /******** Make data requests ********/ @@ -35,7 +24,7 @@ ResourceAPI::SearchArgs ModModel::createSearchArguments() std::optional<std::list<Version>> versions{}; - { // Version filter + { // Version filter if (!m_filter->versions.empty()) versions = m_filter->versions; } diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp index efff1ff4..a6186d89 100644 --- a/launcher/ui/pages/modplatform/ModPage.cpp +++ b/launcher/ui/pages/modplatform/ModPage.cpp @@ -145,11 +145,12 @@ void ModPage::updateVersionList() updateSelectionButton(); } -void ModPage::addResourceToDialog(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& version) +void ModPage::addResourceToPage(ModPlatform::IndexedPack& pack, + ModPlatform::IndexedVersion& version, + const std::shared_ptr<ResourceFolderModel> base_model) { bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool(); - m_model->addPack(pack); - m_parent_dialog->addResource(pack, version, is_indexed); + m_model->addPack(pack, version, base_model, is_indexed); } } // namespace ResourceDownload diff --git a/launcher/ui/pages/modplatform/ModPage.h b/launcher/ui/pages/modplatform/ModPage.h index c3b58cd6..6ecf8a94 100644 --- a/launcher/ui/pages/modplatform/ModPage.h +++ b/launcher/ui/pages/modplatform/ModPage.h @@ -50,7 +50,7 @@ class ModPage : public ResourcePage { [[nodiscard]] QMap<QString, QString> urlHandlers() const override; - void addResourceToDialog(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&) override; + void addResourceToPage(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&, const std::shared_ptr<ResourceFolderModel>) override; virtual auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const -> bool = 0; diff --git a/launcher/ui/pages/modplatform/ResourceModel.cpp b/launcher/ui/pages/modplatform/ResourceModel.cpp index a58ce549..056b28cc 100644 --- a/launcher/ui/pages/modplatform/ResourceModel.cpp +++ b/launcher/ui/pages/modplatform/ResourceModel.cpp @@ -337,15 +337,15 @@ void ResourceModel::searchRequestSucceeded(QJsonDocument& doc) ModPlatform::IndexedPack pack; try { loadIndexedPack(pack, packObj); - if (auto sel = std::find_if( - m_selected.begin(), m_selected.end(), - [&pack](const ModPlatform::IndexedPack& i) { return i.provider == pack.provider && i.addonId == pack.addonId; }); + if (auto sel = std::find_if(m_selected.begin(), m_selected.end(), + [&pack](const DownloadTaskPtr i) { + const auto ipack = i->getPack(); + return ipack.provider == pack.provider && ipack.addonId == pack.addonId; + }); sel != m_selected.end()) { - pack.versionsLoaded = sel->versionsLoaded; - pack.versions = sel->versions; - pack.loadedFileId = sel->loadedFileId; - } - newList.append(pack); + newList.append(sel->get()->getPack()); + } else + newList.append(pack); } catch (const JSONValidationError& e) { qWarning() << "Error while loading resource from " << debugName() << ": " << e.cause(); continue; @@ -408,12 +408,6 @@ void ResourceModel::versionRequestSucceeded(QJsonDocument& doc, ModPlatform::Ind try { auto arr = doc.isObject() ? Json::ensureArray(doc.object(), "data") : doc.array(); loadIndexedPackVersions(current_pack, arr); - if (current_pack.loadedFileId.isValid()) - if (auto ver = - std::find_if(current_pack.versions.begin(), current_pack.versions.end(), - [¤t_pack](const ModPlatform::IndexedVersion& v) { return v.fileId == current_pack.loadedFileId; }); - ver != current_pack.versions.end()) - ver->is_currently_selected = true; } catch (const JSONValidationError& e) { qDebug() << doc; qWarning() << "Error while reading " << debugName() << " resource version: " << e.cause(); @@ -457,47 +451,35 @@ void ResourceModel::infoRequestSucceeded(QJsonDocument& doc, ModPlatform::Indexe emit projectInfoUpdated(); } -void ResourceModel::removePack(QString& rem) +void ResourceModel::addPack(ModPlatform::IndexedPack& pack, + ModPlatform::IndexedVersion& version, + const std::shared_ptr<ResourceFolderModel> packs, + bool is_indexed, + QString custom_target_folder) +{ + version.is_currently_selected = true; + m_selected.append(makeShared<ResourceDownloadTask>(pack, version, packs, is_indexed, custom_target_folder)); +} + +void ResourceModel::removePack(const QString& rem) { - auto pred = [&rem](const ModPlatform::IndexedPack& i) { return rem == i.name; }; + auto pred = [&rem](const DownloadTaskPtr i) { return rem == i->getName(); }; #if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0) m_selected.removeIf(pred); #else - { // well partial implementation of remove_if in case the QT Version is not high enough - const auto cbegin = m_selected.cbegin(); - const auto cend = m_selected.cend(); - const auto t_it = std::find_if(cbegin, cend, pred); - auto result = std::distance(cbegin, t_it); - if (result != m_selected.size()) { - // now detach: - const auto e = m_selected.end(); - - auto it = std::next(m_selected.begin(), result); - auto dest = it; - - // Loop Invariants: - // - it != e - // - [next(it), e[ still to be checked - // - [c.begin(), dest[ are result - while (++it != e) { - if (!pred(*it)) { - *dest = std::move(*it); - ++dest; - } - } - - result = std::distance(dest, e); - m_selected.erase(dest, e); - } + { + for (auto it = m_selected.begin(); it != m_selected.end();) + if (pred(*it)) + it = m_selected.erase(it); + else + ++it; } #endif - // m_selected.removeAt(qsizetype i) auto pack = std::find_if(m_packs.begin(), m_packs.end(), [&rem](const ModPlatform::IndexedPack& i) { return rem == i.name; }); if (pack == m_packs.end()) { // ignore it if is not in the current search return; } if (!pack->versionsLoaded) { - pack->loadedFileId = {}; return; } for (auto& ver : pack->versions) diff --git a/launcher/ui/pages/modplatform/ResourceModel.h b/launcher/ui/pages/modplatform/ResourceModel.h index 5eb63901..735d1687 100644 --- a/launcher/ui/pages/modplatform/ResourceModel.h +++ b/launcher/ui/pages/modplatform/ResourceModel.h @@ -10,6 +10,7 @@ #include "QObjectPtr.h" +#include "ResourceDownloadTask.h" #include "modplatform/ResourceAPI.h" #include "tasks/ConcurrentTask.h" @@ -29,6 +30,8 @@ class ResourceModel : public QAbstractListModel { Q_PROPERTY(QString search_term MEMBER m_search_term WRITE setSearchTerm) public: + using DownloadTaskPtr = shared_qobject_ptr<ResourceDownloadTask>; + ResourceModel(ResourceAPI* api); ~ResourceModel() override; @@ -80,8 +83,13 @@ class ResourceModel : public QAbstractListModel { /** Gets the icon at the URL for the given index. If it's not fetched yet, fetch it and update when fisinhed. */ std::optional<QIcon> getIcon(QModelIndex&, const QUrl&); - void addPack(ModPlatform::IndexedPack& add) { m_selected.append(add); } - void removePack(QString& rem); + void addPack(ModPlatform::IndexedPack& pack, + ModPlatform::IndexedVersion& version, + const std::shared_ptr<ResourceFolderModel> packs, + bool is_indexed = false, + QString custom_target_folder = {}); + void removePack(const QString& rem); + QList<DownloadTaskPtr> selectedPacks() { return m_selected; } protected: /** Resets the model's data. */ @@ -127,7 +135,7 @@ class ResourceModel : public QAbstractListModel { QSet<QUrl> m_failed_icon_actions; QList<ModPlatform::IndexedPack> m_packs; - QList<ModPlatform::IndexedPack> m_selected; + QList<DownloadTaskPtr> m_selected; // HACK: We need this to prevent callbacks from calling the model after it has already been deleted. // This leaks a tiny bit of memory per time the user has opened a resource dialog. How to make this better? diff --git a/launcher/ui/pages/modplatform/ResourcePage.cpp b/launcher/ui/pages/modplatform/ResourcePage.cpp index 24347dbd..4ebdea56 100644 --- a/launcher/ui/pages/modplatform/ResourcePage.cpp +++ b/launcher/ui/pages/modplatform/ResourcePage.cpp @@ -37,6 +37,7 @@ */ #include "ResourcePage.h" +#include "modplatform/ModIndex.h" #include "ui_ResourcePage.h" #include <QDesktopServices> @@ -308,16 +309,22 @@ void ResourcePage::onVersionSelectionChanged(QString data) void ResourcePage::addResourceToDialog(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& version) { - m_model->addPack(pack); m_parent_dialog->addResource(pack, version); } -void ResourcePage::removeResourceFromDialog(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& version) +void ResourcePage::removeResourceFromDialog(const QString& pack_name) { - m_parent_dialog->removeResource(pack, version); + m_parent_dialog->removeResource(pack_name); } -void ResourcePage::removeResourceFromPage(QString& name) +void ResourcePage::addResourceToPage(ModPlatform::IndexedPack& pack, + ModPlatform::IndexedVersion& ver, + const std::shared_ptr<ResourceFolderModel> base_model) +{ + m_model->addPack(pack, ver, base_model); +} + +void ResourcePage::removeResourceFromPage(const QString& name) { m_model->removePack(name); } @@ -333,7 +340,7 @@ void ResourcePage::onResourceSelected() auto& version = current_pack.versions[m_selected_version_index]; if (version.is_currently_selected) - removeResourceFromDialog(current_pack, version); + removeResourceFromDialog(current_pack.name); else addResourceToDialog(current_pack, version); diff --git a/launcher/ui/pages/modplatform/ResourcePage.h b/launcher/ui/pages/modplatform/ResourcePage.h index a9db52e3..df68e6fd 100644 --- a/launcher/ui/pages/modplatform/ResourcePage.h +++ b/launcher/ui/pages/modplatform/ResourcePage.h @@ -7,10 +7,12 @@ #include <QTimer> #include <QWidget> +#include "ResourceDownloadTask.h" #include "modplatform/ModIndex.h" #include "modplatform/ResourceAPI.h" #include "ui/pages/BasePage.h" +#include "ui/pages/modplatform/ResourceModel.h" #include "ui/widgets/ProgressWidget.h" namespace Ui { @@ -27,6 +29,7 @@ class ResourceModel; class ResourcePage : public QWidget, public BasePage { Q_OBJECT public: + using DownloadTaskPtr = shared_qobject_ptr<ResourceDownloadTask>; ~ResourcePage() override; /* Affects what the user sees */ @@ -72,9 +75,13 @@ class ResourcePage : public QWidget, public BasePage { virtual void updateSelectionButton(); virtual void updateVersionList(); - virtual void addResourceToDialog(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&); - virtual void removeResourceFromDialog(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&); - virtual void removeResourceFromPage(QString& name); + void addResourceToDialog(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&); + void removeResourceFromDialog(const QString& pack_name); + virtual void removeResourceFromPage(const QString& name); + virtual void addResourceToPage(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&, const std::shared_ptr<ResourceFolderModel>); + + QList<DownloadTaskPtr> selectedPacks() { return m_model->selectedPacks(); } + bool hasSelectedPacks() { return !(m_model->selectedPacks().isEmpty()); } protected slots: virtual void triggerSearch() {} diff --git a/launcher/ui/pages/modplatform/ShaderPackPage.cpp b/launcher/ui/pages/modplatform/ShaderPackPage.cpp index 1b9b2b83..c7a69418 100644 --- a/launcher/ui/pages/modplatform/ShaderPackPage.cpp +++ b/launcher/ui/pages/modplatform/ShaderPackPage.cpp @@ -43,12 +43,14 @@ QMap<QString, QString> ShaderPackResourcePage::urlHandlers() const return map; } -void ShaderPackResourcePage::addResourceToDialog(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& version) +void ShaderPackResourcePage::addResourceToPage(ModPlatform::IndexedPack& pack, + ModPlatform::IndexedVersion& version, + const std::shared_ptr<ResourceFolderModel> base_model) { + QString custom_target_folder; if (version.loaders.contains(QStringLiteral("canvas"))) - version.custom_target_folder = QStringLiteral("resourcepacks"); - m_model->addPack(pack); - m_parent_dialog->addResource(pack, version); + custom_target_folder = QStringLiteral("resourcepacks"); + m_model->addPack(pack, version, base_model, false, custom_target_folder); } } // namespace ResourceDownload diff --git a/launcher/ui/pages/modplatform/ShaderPackPage.h b/launcher/ui/pages/modplatform/ShaderPackPage.h index 972419a8..8a293f74 100644 --- a/launcher/ui/pages/modplatform/ShaderPackPage.h +++ b/launcher/ui/pages/modplatform/ShaderPackPage.h @@ -40,7 +40,7 @@ class ShaderPackResourcePage : public ResourcePage { [[nodiscard]] bool supportsFiltering() const override { return false; }; - void addResourceToDialog(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&) override; + void addResourceToPage(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&, const std::shared_ptr<ResourceFolderModel>) override; [[nodiscard]] QMap<QString, QString> urlHandlers() const override; diff --git a/launcher/ui/widgets/PageContainer.cpp b/launcher/ui/widgets/PageContainer.cpp index 0a06a351..84a4e0de 100644 --- a/launcher/ui/widgets/PageContainer.cpp +++ b/launcher/ui/widgets/PageContainer.cpp @@ -135,6 +135,11 @@ BasePage* PageContainer::getPage(QString pageId) return m_model->findPageEntryById(pageId); } +const QList<BasePage*> PageContainer::getPages() const +{ + return m_model->pages(); +} + void PageContainer::refreshContainer() { m_proxyModel->invalidate(); diff --git a/launcher/ui/widgets/PageContainer.h b/launcher/ui/widgets/PageContainer.h index 97e294dc..ad74d43a 100644 --- a/launcher/ui/widgets/PageContainer.h +++ b/launcher/ui/widgets/PageContainer.h @@ -80,6 +80,7 @@ public: virtual bool selectPage(QString pageId) override; BasePage* getPage(QString pageId) override; + const QList<BasePage*> getPages() const; void refreshContainer() override; virtual void setParentContainer(BasePageContainer * container) |