feat(RD): add resource pack downloader

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow
2022-12-16 20:26:10 -03:00
parent e89a10945c
commit c3ea303a37
20 changed files with 538 additions and 23 deletions

View File

@ -25,6 +25,7 @@
#include "ResourceDownloadTask.h"
#include "minecraft/mod/ModFolderModel.h"
#include "minecraft/mod/ResourcePackFolderModel.h"
#include "ui/dialogs/ReviewMessageBox.h"
@ -229,4 +230,30 @@ QList<BasePage*> ModDownloadDialog::getPages()
return pages;
}
ResourcePackDownloadDialog::ResourcePackDownloadDialog(QWidget* parent,
const std::shared_ptr<ResourcePackFolderModel>& resource_packs,
BaseInstance* instance)
: ResourceDownloadDialog(parent, resource_packs), m_instance(instance)
{
setWindowTitle(dialogTitle());
initializeContainer();
connectButtons();
if (!geometrySaveKey().isEmpty())
restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get(geometrySaveKey()).toByteArray()));
}
QList<BasePage*> ResourcePackDownloadDialog::getPages()
{
QList<BasePage*> pages;
pages.append(ModrinthResourcePackPage::create(this, *m_instance));
if (APPLICATION->capabilities() & Application::SupportsFlame)
pages.append(FlameResourcePackPage::create(this, *m_instance));
return pages;
}
} // namespace ResourceDownload

View File

@ -35,6 +35,7 @@ class QVBoxLayout;
class QDialogButtonBox;
class ResourceDownloadTask;
class ResourceFolderModel;
class ResourcePackFolderModel;
namespace ResourceDownload {
@ -108,4 +109,23 @@ class ModDownloadDialog final : public ResourceDownloadDialog {
BaseInstance* m_instance;
};
class ResourcePackDownloadDialog final : public ResourceDownloadDialog {
Q_OBJECT
public:
explicit ResourcePackDownloadDialog(QWidget* parent,
const std::shared_ptr<ResourcePackFolderModel>& resource_packs,
BaseInstance* instance);
~ResourcePackDownloadDialog() override = default;
//: String that gets appended to the resource pack download dialog title ("Download " + resourcesString())
[[nodiscard]] QString resourcesString() const override { return tr("resource packs"); }
[[nodiscard]] QString geometrySaveKey() const override { return "RPDownloadGeometry"; }
QList<BasePage*> getPages() override;
private:
BaseInstance* m_instance;
};
} // namespace ResourceDownload