mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-05-06 17:44:41 +02:00
Add Change Version action to all pages
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
1809858fc7
commit
f57ca1e79e
@ -377,7 +377,7 @@ QList<BasePage*> ShaderPackDownloadDialog::getPages()
|
|||||||
return pages;
|
return pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModDownloadDialog::setModMetadata(std::shared_ptr<Metadata::ModStruct> meta)
|
void ResourceDownloadDialog::setResourceMetadata(const std::shared_ptr<Metadata::ModStruct>& meta)
|
||||||
{
|
{
|
||||||
switch (meta->provider) {
|
switch (meta->provider) {
|
||||||
case ModPlatform::ResourceProvider::MODRINTH:
|
case ModPlatform::ResourceProvider::MODRINTH:
|
||||||
|
@ -69,6 +69,8 @@ class ResourceDownloadDialog : public QDialog, public BasePageProvider {
|
|||||||
const QList<DownloadTaskPtr> getTasks();
|
const QList<DownloadTaskPtr> getTasks();
|
||||||
[[nodiscard]] const std::shared_ptr<ResourceFolderModel> getBaseModel() const { return m_base_model; }
|
[[nodiscard]] const std::shared_ptr<ResourceFolderModel> getBaseModel() const { return m_base_model; }
|
||||||
|
|
||||||
|
void setResourceMetadata(const std::shared_ptr<Metadata::ModStruct>& meta);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
void reject() override;
|
void reject() override;
|
||||||
@ -107,8 +109,6 @@ class ModDownloadDialog final : public ResourceDownloadDialog {
|
|||||||
QList<BasePage*> getPages() override;
|
QList<BasePage*> getPages() override;
|
||||||
GetModDependenciesTask::Ptr getModDependenciesTask() override;
|
GetModDependenciesTask::Ptr getModDependenciesTask() override;
|
||||||
|
|
||||||
void setModMetadata(std::shared_ptr<Metadata::ModStruct>);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BaseInstance* m_instance;
|
BaseInstance* m_instance;
|
||||||
};
|
};
|
||||||
|
@ -316,6 +316,10 @@ void ExternalResourcesPage::updateActions()
|
|||||||
const bool hasSelection = ui->treeView->selectionModel()->hasSelection();
|
const bool hasSelection = ui->treeView->selectionModel()->hasSelection();
|
||||||
ui->actionUpdateItem->setEnabled(!m_model->empty());
|
ui->actionUpdateItem->setEnabled(!m_model->empty());
|
||||||
ui->actionResetItemMetadata->setEnabled(hasSelection);
|
ui->actionResetItemMetadata->setEnabled(hasSelection);
|
||||||
|
|
||||||
|
const QModelIndexList rows = ui->treeView->selectionModel()->selectedRows();
|
||||||
|
ui->actionChangeVersion->setEnabled(rows.count() == 1 && m_model->at(m_filterModel->mapToSource(rows[0]).row()).metadata() != nullptr);
|
||||||
|
|
||||||
ui->actionRemoveItem->setEnabled(hasSelection);
|
ui->actionRemoveItem->setEnabled(hasSelection);
|
||||||
ui->actionEnableItem->setEnabled(hasSelection);
|
ui->actionEnableItem->setEnabled(hasSelection);
|
||||||
ui->actionDisableItem->setEnabled(hasSelection);
|
ui->actionDisableItem->setEnabled(hasSelection);
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="dragDropMode">
|
<property name="dragDropMode">
|
||||||
<enum>QAbstractItemView::DragDropMode::DropOnly</enum>
|
<enum>QAbstractItemView::NoDragDrop</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="uniformRowHeights">
|
<property name="uniformRowHeights">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -74,7 +74,7 @@
|
|||||||
<string>Actions</string>
|
<string>Actions</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolButtonStyle">
|
<property name="toolButtonStyle">
|
||||||
<enum>Qt::ToolButtonStyle::ToolButtonTextOnly</enum>
|
<enum>Qt::ToolButtonIconOnly</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="useDefaultAction" stdset="0">
|
<property name="useDefaultAction" stdset="0">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -177,7 +177,7 @@
|
|||||||
<string>Reset Update Metadata</string>
|
<string>Reset Update Metadata</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionVerifyItemDependencies">
|
<action name="actionVerifyItemDependencies">
|
||||||
@ -185,7 +185,7 @@
|
|||||||
<string>Verify Dependencies</string>
|
<string>Verify Dependencies</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionExportMetadata">
|
<action name="actionExportMetadata">
|
||||||
@ -200,6 +200,9 @@
|
|||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionChangeVersion">
|
<action name="actionChangeVersion">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Change Version</string>
|
<string>Change Version</string>
|
||||||
</property>
|
</property>
|
||||||
@ -207,7 +210,7 @@
|
|||||||
<string>Change a resource's version.</string>
|
<string>Change a resource's version.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -308,7 +308,7 @@ void ModFolderPage::changeModVersion()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ResourceDownload::ModDownloadDialog mdownload(this, m_model, m_instance);
|
ResourceDownload::ModDownloadDialog mdownload(this, m_model, m_instance);
|
||||||
mdownload.setModMetadata((*mods_list.begin())->metadata());
|
mdownload.setResourceMetadata((*mods_list.begin())->metadata());
|
||||||
if (mdownload.exec()) {
|
if (mdownload.exec()) {
|
||||||
auto tasks = new ConcurrentTask(this, "Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
auto tasks = new ConcurrentTask(this, "Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||||
|
@ -67,6 +67,10 @@ ResourcePackPage::ResourcePackPage(MinecraftInstance* instance, std::shared_ptr<
|
|||||||
connect(ui->actionResetItemMetadata, &QAction::triggered, this, &ResourcePackPage::deleteResourcePackMetadata);
|
connect(ui->actionResetItemMetadata, &QAction::triggered, this, &ResourcePackPage::deleteResourcePackMetadata);
|
||||||
|
|
||||||
ui->actionUpdateItem->setMenu(updateMenu);
|
ui->actionUpdateItem->setMenu(updateMenu);
|
||||||
|
|
||||||
|
ui->actionChangeVersion->setToolTip(tr("Change a mod's version."));
|
||||||
|
connect(ui->actionChangeVersion, &QAction::triggered, this, &ResourcePackPage::changeResourcePackVersion);
|
||||||
|
ui->actionsToolbar->insertActionAfter(ui->actionUpdateItem, ui->actionChangeVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourcePackPage::updateFrame(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
void ResourcePackPage::updateFrame(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||||
@ -214,3 +218,56 @@ void ResourcePackPage::deleteResourcePackMetadata()
|
|||||||
|
|
||||||
m_model->deleteMetadata(selection);
|
m_model->deleteMetadata(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourcePackPage::changeResourcePackVersion()
|
||||||
|
{
|
||||||
|
if (m_instance->typeName() != "Minecraft")
|
||||||
|
return; // this is a null instance or a legacy instance
|
||||||
|
|
||||||
|
if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Resource pack updates are unavailable when metadata is disabled!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QModelIndexList rows = ui->treeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
if (rows.count() != 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Resource &resource = m_model->at(m_filterModel->mapToSource(rows[0]).row());
|
||||||
|
|
||||||
|
if (resource.metadata() == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ResourceDownload::ResourcePackDownloadDialog mdownload(this, m_model, m_instance);
|
||||||
|
mdownload.setResourceMetadata(resource.metadata());
|
||||||
|
if (mdownload.exec()) {
|
||||||
|
auto tasks =
|
||||||
|
new ConcurrentTask(this, "Download Resource Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
|
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||||
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
connect(tasks, &Task::aborted, [this, tasks]() {
|
||||||
|
CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show();
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
connect(tasks, &Task::succeeded, [this, tasks]() {
|
||||||
|
QStringList warnings = tasks->warnings();
|
||||||
|
if (warnings.count())
|
||||||
|
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
||||||
|
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
|
||||||
|
for (auto& task : mdownload.getTasks()) {
|
||||||
|
tasks->addTask(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressDialog loadDialog(this);
|
||||||
|
loadDialog.setSkipButton(true, tr("Abort"));
|
||||||
|
loadDialog.execWithTask(tasks);
|
||||||
|
|
||||||
|
m_model->update();
|
||||||
|
}
|
||||||
|
}
|
@ -64,6 +64,7 @@ class ResourcePackPage : public ExternalResourcesPage {
|
|||||||
void downloadResourcePacks();
|
void downloadResourcePacks();
|
||||||
void updateResourcePacks();
|
void updateResourcePacks();
|
||||||
void deleteResourcePackMetadata();
|
void deleteResourcePackMetadata();
|
||||||
|
void changeResourcePackVersion();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<ResourcePackFolderModel> m_model;
|
std::shared_ptr<ResourcePackFolderModel> m_model;
|
||||||
|
@ -70,6 +70,10 @@ ShaderPackPage::ShaderPackPage(MinecraftInstance* instance, std::shared_ptr<Shad
|
|||||||
connect(ui->actionResetItemMetadata, &QAction::triggered, this, &ShaderPackPage::deleteShaderPackMetadata);
|
connect(ui->actionResetItemMetadata, &QAction::triggered, this, &ShaderPackPage::deleteShaderPackMetadata);
|
||||||
|
|
||||||
ui->actionUpdateItem->setMenu(updateMenu);
|
ui->actionUpdateItem->setMenu(updateMenu);
|
||||||
|
|
||||||
|
ui->actionChangeVersion->setToolTip(tr("Change a shader pack's version."));
|
||||||
|
connect(ui->actionChangeVersion, &QAction::triggered, this, &ShaderPackPage::changeShaderPackVersion);
|
||||||
|
ui->actionsToolbar->insertActionAfter(ui->actionUpdateItem, ui->actionChangeVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderPackPage::downloadShaderPack()
|
void ShaderPackPage::downloadShaderPack()
|
||||||
@ -207,3 +211,56 @@ void ShaderPackPage::deleteShaderPackMetadata()
|
|||||||
|
|
||||||
m_model->deleteMetadata(selection);
|
m_model->deleteMetadata(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShaderPackPage::changeShaderPackVersion()
|
||||||
|
{
|
||||||
|
if (m_instance->typeName() != "Minecraft")
|
||||||
|
return; // this is a null instance or a legacy instance
|
||||||
|
|
||||||
|
if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Shader pack updates are unavailable when metadata is disabled!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QModelIndexList rows = ui->treeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
if (rows.count() != 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Resource &resource = m_model->at(m_filterModel->mapToSource(rows[0]).row());
|
||||||
|
|
||||||
|
if (resource.metadata() == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ResourceDownload::ShaderPackDownloadDialog mdownload(this, m_model, m_instance);
|
||||||
|
mdownload.setResourceMetadata(resource.metadata());
|
||||||
|
if (mdownload.exec()) {
|
||||||
|
auto tasks =
|
||||||
|
new ConcurrentTask(this, "Download Shader Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
|
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||||
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
connect(tasks, &Task::aborted, [this, tasks]() {
|
||||||
|
CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show();
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
connect(tasks, &Task::succeeded, [this, tasks]() {
|
||||||
|
QStringList warnings = tasks->warnings();
|
||||||
|
if (warnings.count())
|
||||||
|
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
||||||
|
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
|
||||||
|
for (auto& task : mdownload.getTasks()) {
|
||||||
|
tasks->addTask(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressDialog loadDialog(this);
|
||||||
|
loadDialog.setSkipButton(true, tr("Abort"));
|
||||||
|
loadDialog.execWithTask(tasks);
|
||||||
|
|
||||||
|
m_model->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -56,6 +56,7 @@ class ShaderPackPage : public ExternalResourcesPage {
|
|||||||
void downloadShaderPack();
|
void downloadShaderPack();
|
||||||
void updateShaderPacks();
|
void updateShaderPacks();
|
||||||
void deleteShaderPackMetadata();
|
void deleteShaderPackMetadata();
|
||||||
|
void changeShaderPackVersion();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<ShaderPackFolderModel> m_model;
|
std::shared_ptr<ShaderPackFolderModel> m_model;
|
||||||
|
@ -69,6 +69,11 @@ TexturePackPage::TexturePackPage(MinecraftInstance* instance, std::shared_ptr<Te
|
|||||||
connect(ui->actionResetItemMetadata, &QAction::triggered, this, &TexturePackPage::deleteTexturePackMetadata);
|
connect(ui->actionResetItemMetadata, &QAction::triggered, this, &TexturePackPage::deleteTexturePackMetadata);
|
||||||
|
|
||||||
ui->actionUpdateItem->setMenu(updateMenu);
|
ui->actionUpdateItem->setMenu(updateMenu);
|
||||||
|
|
||||||
|
ui->actionChangeVersion->setToolTip(tr("Change a texture pack's version."));
|
||||||
|
connect(ui->actionChangeVersion, &QAction::triggered, this, &TexturePackPage::changeTexturePackVersion);
|
||||||
|
ui->actionsToolbar->insertActionAfter(ui->actionUpdateItem, ui->actionChangeVersion);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TexturePackPage::updateFrame(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
void TexturePackPage::updateFrame(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||||
@ -216,3 +221,55 @@ void TexturePackPage::deleteTexturePackMetadata()
|
|||||||
|
|
||||||
m_model->deleteMetadata(selection);
|
m_model->deleteMetadata(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TexturePackPage::changeTexturePackVersion() {
|
||||||
|
if (m_instance->typeName() != "Minecraft")
|
||||||
|
return; // this is a null instance or a legacy instance
|
||||||
|
|
||||||
|
if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Texture pack updates are unavailable when metadata is disabled!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QModelIndexList rows = ui->treeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
if (rows.count() != 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Resource &resource = m_model->at(m_filterModel->mapToSource(rows[0]).row());
|
||||||
|
|
||||||
|
if (resource.metadata() == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ResourceDownload::TexturePackDownloadDialog mdownload(this, m_model, m_instance);
|
||||||
|
mdownload.setResourceMetadata(resource.metadata());
|
||||||
|
if (mdownload.exec()) {
|
||||||
|
auto tasks =
|
||||||
|
new ConcurrentTask(this, "Download Texture Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
|
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||||
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
connect(tasks, &Task::aborted, [this, tasks]() {
|
||||||
|
CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show();
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
connect(tasks, &Task::succeeded, [this, tasks]() {
|
||||||
|
QStringList warnings = tasks->warnings();
|
||||||
|
if (warnings.count())
|
||||||
|
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
||||||
|
|
||||||
|
tasks->deleteLater();
|
||||||
|
});
|
||||||
|
|
||||||
|
for (auto& task : mdownload.getTasks()) {
|
||||||
|
tasks->addTask(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressDialog loadDialog(this);
|
||||||
|
loadDialog.setSkipButton(true, tr("Abort"));
|
||||||
|
loadDialog.execWithTask(tasks);
|
||||||
|
|
||||||
|
m_model->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -59,6 +59,7 @@ class TexturePackPage : public ExternalResourcesPage {
|
|||||||
void downloadTexturePacks();
|
void downloadTexturePacks();
|
||||||
void updateTexturePacks();
|
void updateTexturePacks();
|
||||||
void deleteTexturePackMetadata();
|
void deleteTexturePackMetadata();
|
||||||
|
void changeTexturePackVersion();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<TexturePackFolderModel> m_model;
|
std::shared_ptr<TexturePackFolderModel> m_model;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user