Modify "Change Version" to use "Install Loader" dialog
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
4332b62a62
commit
4cdf669154
@ -74,7 +74,14 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage {
|
||||
bool m_loaded = false;
|
||||
};
|
||||
|
||||
InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr<PackProfile> profile, QWidget* parent)
|
||||
InstallLoaderPage* pageCast(BasePage* page)
|
||||
{
|
||||
auto result = dynamic_cast<InstallLoaderPage*>(page);
|
||||
Q_ASSERT(result != nullptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr<PackProfile> profile, const QString& uid, QWidget* parent)
|
||||
: QDialog(parent), m_profile(profile), m_container(new PageContainer(this)), m_buttons(new QDialogButtonBox(this))
|
||||
{
|
||||
auto layout = new QVBoxLayout(this);
|
||||
@ -86,7 +93,7 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr<PackProfile> profile, Q
|
||||
|
||||
auto refreshButton = new QPushButton(tr("&Refresh"), this);
|
||||
connect(refreshButton, &QPushButton::pressed, this, [this] {
|
||||
dynamic_cast<InstallLoaderPage*>(m_container->selectedPage())->loadList();
|
||||
pageCast(m_container->selectedPage())->loadList();
|
||||
});
|
||||
buttonLayout->addWidget(refreshButton);
|
||||
|
||||
@ -105,7 +112,10 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr<PackProfile> profile, Q
|
||||
[this](BasePage* previous, BasePage* selected) { updateAcceptButton(selected); });
|
||||
updateAcceptButton(m_container->selectedPage());
|
||||
|
||||
dynamic_cast<InstallLoaderPage*>(m_container->selectedPage())->selectSearch();
|
||||
pageCast(m_container->selectedPage())->selectSearch();
|
||||
for (BasePage* page : m_container->getPages())
|
||||
if (page->id() == uid)
|
||||
m_container->selectPage(page->id());
|
||||
}
|
||||
|
||||
QList<BasePage*> InstallLoaderDialog::getPages()
|
||||
@ -135,7 +145,7 @@ void InstallLoaderDialog::updateAcceptButton(const BasePage* page)
|
||||
void InstallLoaderDialog::done(int result)
|
||||
{
|
||||
if (result == Accepted) {
|
||||
auto* page = dynamic_cast<InstallLoaderPage*>(m_container->selectedPage());
|
||||
auto* page = pageCast(m_container->selectedPage());
|
||||
if (page->selectedVersion()) {
|
||||
m_profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor());
|
||||
m_profile->resolve(Net::Mode::Online);
|
||||
|
@ -26,11 +26,11 @@ class PageContainer;
|
||||
class PackProfile;
|
||||
class QDialogButtonBox;
|
||||
|
||||
class InstallLoaderDialog : public QDialog, public BasePageProvider {
|
||||
class InstallLoaderDialog final : public QDialog, public BasePageProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InstallLoaderDialog(std::shared_ptr<PackProfile> instance, QWidget* parent = nullptr);
|
||||
explicit InstallLoaderDialog(std::shared_ptr<PackProfile> instance, const QString& uid = QString(), QWidget* parent = nullptr);
|
||||
|
||||
QList<BasePage*> getPages() override;
|
||||
QString dialogTitle() override;
|
||||
|
@ -432,6 +432,16 @@ void VersionPage::on_actionChange_version_triggered()
|
||||
return;
|
||||
}
|
||||
auto uid = list->uid();
|
||||
|
||||
// FIXME: this is still a horrible HACK.
|
||||
if (uid == "net.minecraftforge" || uid == "com.mumfrey.liteloader" || uid == "net.fabricmc.fabric-loader" ||
|
||||
uid == "org.quiltmc.quilt-loader") {
|
||||
InstallLoaderDialog dialog(m_inst->getPackProfile(), uid, this);
|
||||
dialog.exec();
|
||||
m_container->refreshContainer();
|
||||
return;
|
||||
}
|
||||
|
||||
VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this);
|
||||
if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed")
|
||||
{
|
||||
@ -485,7 +495,7 @@ void VersionPage::on_actionDownload_All_triggered()
|
||||
|
||||
void VersionPage::on_actionInstall_Loader_triggered()
|
||||
{
|
||||
InstallLoaderDialog dialog(m_inst->getPackProfile(), this);
|
||||
InstallLoaderDialog dialog(m_inst->getPackProfile(), QString(), this);
|
||||
dialog.exec();
|
||||
m_container->refreshContainer();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user