GH-899 clean up mod browse buttons and dead legacy forge
This commit is contained in:
parent
c09dc85090
commit
49d3705d16
@ -3,11 +3,15 @@
|
|||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include "dialogs/ProgressDialog.h"
|
#include "dialogs/ProgressDialog.h"
|
||||||
#include "net/PasteUpload.h"
|
#include "net/PasteUpload.h"
|
||||||
#include "dialogs/CustomMessageBox.h"
|
#include "dialogs/CustomMessageBox.h"
|
||||||
|
|
||||||
|
#include "MultiMC.h"
|
||||||
|
#include <settings/SettingsObject.h>
|
||||||
|
|
||||||
void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)
|
void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)
|
||||||
{
|
{
|
||||||
ProgressDialog dialog(parentWidget);
|
ProgressDialog dialog(parentWidget);
|
||||||
@ -46,3 +50,52 @@ void GuiUtil::setClipboardText(const QString &text)
|
|||||||
{
|
{
|
||||||
QApplication::clipboard()->setText(text);
|
QApplication::clipboard()->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList GuiUtil::BrowseForMods(QString context, QString caption, QString filter,
|
||||||
|
QWidget *parentWidget)
|
||||||
|
{
|
||||||
|
static QMap<QString, QString> savedPaths;
|
||||||
|
|
||||||
|
QFileDialog w(parentWidget, caption);
|
||||||
|
QSet<QString> locations;
|
||||||
|
QString modsFolder = MMC->settings()->get("CentralModsDir").toString();
|
||||||
|
auto f = [&](QStandardPaths::StandardLocation l)
|
||||||
|
{
|
||||||
|
QString location = QStandardPaths::writableLocation(l);
|
||||||
|
QFileInfo finfo(location);
|
||||||
|
if (!finfo.exists())
|
||||||
|
return;
|
||||||
|
locations.insert(location);
|
||||||
|
};
|
||||||
|
f(QStandardPaths::DesktopLocation);
|
||||||
|
f(QStandardPaths::DocumentsLocation);
|
||||||
|
f(QStandardPaths::DownloadLocation);
|
||||||
|
f(QStandardPaths::HomeLocation);
|
||||||
|
QList<QUrl> urls;
|
||||||
|
for (auto location : locations)
|
||||||
|
{
|
||||||
|
urls.append(QUrl::fromLocalFile(location));
|
||||||
|
}
|
||||||
|
urls.append(QUrl::fromLocalFile(modsFolder));
|
||||||
|
|
||||||
|
w.setFileMode(QFileDialog::ExistingFiles);
|
||||||
|
w.setAcceptMode(QFileDialog::AcceptOpen);
|
||||||
|
w.setNameFilter(filter);
|
||||||
|
if(savedPaths.contains(context))
|
||||||
|
{
|
||||||
|
w.setDirectory(savedPaths[context]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
w.setDirectory(modsFolder);
|
||||||
|
}
|
||||||
|
w.setSidebarUrls(urls);
|
||||||
|
|
||||||
|
if (w.exec())
|
||||||
|
{
|
||||||
|
savedPaths[context] = w.directory().absolutePath();
|
||||||
|
return w.getOpenFileNames();
|
||||||
|
}
|
||||||
|
savedPaths[context] = w.directory().absolutePath();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
@ -6,4 +6,5 @@ namespace GuiUtil
|
|||||||
{
|
{
|
||||||
void uploadPaste(const QString &text, QWidget *parentWidget);
|
void uploadPaste(const QString &text, QWidget *parentWidget);
|
||||||
void setClipboardText(const QString &text);
|
void setClipboardText(const QString &text);
|
||||||
|
QStringList BrowseForMods(QString context, QString caption, QString filter, QWidget *parentWidget);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "minecraft/LegacyInstance.h"
|
#include "minecraft/LegacyInstance.h"
|
||||||
#include "Env.h"
|
#include "Env.h"
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
#include <GuiUtil.h>
|
||||||
|
|
||||||
LegacyJarModPage::LegacyJarModPage(LegacyInstance *inst, QWidget *parent)
|
LegacyJarModPage::LegacyJarModPage(LegacyInstance *inst, QWidget *parent)
|
||||||
: QWidget(parent), ui(new Ui::LegacyJarModPage), m_inst(inst)
|
: QWidget(parent), ui(new Ui::LegacyJarModPage), m_inst(inst)
|
||||||
@ -98,53 +99,16 @@ bool LegacyJarModPage::eventFilter(QObject *obj, QEvent *ev)
|
|||||||
return QWidget::eventFilter(obj, ev);
|
return QWidget::eventFilter(obj, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LegacyJarModPage::on_addForgeBtn_clicked()
|
|
||||||
{
|
|
||||||
//FIXME: dead. clean up.
|
|
||||||
/*
|
|
||||||
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
|
|
||||||
vselect.setExactFilter(1, m_inst->intendedVersionId());
|
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
|
||||||
{
|
|
||||||
ForgeVersionPtr forge =
|
|
||||||
std::dynamic_pointer_cast<ForgeVersion>(vselect.selectedVersion());
|
|
||||||
if (!forge)
|
|
||||||
return;
|
|
||||||
auto entry = Env::getInstance().metacache()->resolveEntry("minecraftforge", forge->filename());
|
|
||||||
if (entry->stale)
|
|
||||||
{
|
|
||||||
NetJob *fjob = new NetJob("Forge download");
|
|
||||||
auto cacheDl = CacheDownload::make(forge->universal_url, entry);
|
|
||||||
fjob->addNetAction(cacheDl);
|
|
||||||
ProgressDialog dlg(this);
|
|
||||||
dlg.exec(fjob);
|
|
||||||
if (dlg.result() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
m_jarmods->stopWatching();
|
|
||||||
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
|
|
||||||
m_jarmods->startWatching();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// failed to download forge :/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_jarmods->stopWatching();
|
|
||||||
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
|
|
||||||
m_jarmods->startWatching();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
void LegacyJarModPage::on_addJarBtn_clicked()
|
void LegacyJarModPage::on_addJarBtn_clicked()
|
||||||
{
|
{
|
||||||
//: Title of jar mod selection dialog
|
auto list = GuiUtil::BrowseForMods("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), this->parentWidget());
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Jar Mods"));
|
if(!list.empty())
|
||||||
for (auto filename : fileNames)
|
|
||||||
{
|
{
|
||||||
m_jarmods->stopWatching();
|
m_jarmods->stopWatching();
|
||||||
m_jarmods->installMod(QFileInfo(filename));
|
for (auto filename : list)
|
||||||
|
{
|
||||||
|
m_jarmods->installMod(QFileInfo(filename));
|
||||||
|
}
|
||||||
m_jarmods->startWatching();
|
m_jarmods->startWatching();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,6 @@ slots:
|
|||||||
|
|
||||||
void on_addJarBtn_clicked();
|
void on_addJarBtn_clicked();
|
||||||
void on_rmJarBtn_clicked();
|
void on_rmJarBtn_clicked();
|
||||||
void on_addForgeBtn_clicked();
|
|
||||||
void on_moveJarUpBtn_clicked();
|
void on_moveJarUpBtn_clicked();
|
||||||
void on_moveJarDownBtn_clicked();
|
void on_moveJarDownBtn_clicked();
|
||||||
void on_viewJarBtn_clicked();
|
void on_viewJarBtn_clicked();
|
||||||
|
@ -101,13 +101,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addForgeBtn">
|
|
||||||
<property name="text">
|
|
||||||
<string>Install Forge</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
#include "dialogs/CustomMessageBox.h"
|
#include "dialogs/CustomMessageBox.h"
|
||||||
#include "dialogs/ModEditDialogCommon.h"
|
#include "dialogs/ModEditDialogCommon.h"
|
||||||
|
#include <GuiUtil.h>
|
||||||
#include "minecraft/ModList.h"
|
#include "minecraft/ModList.h"
|
||||||
#include "minecraft/Mod.h"
|
#include "minecraft/Mod.h"
|
||||||
#include "minecraft/VersionFilterData.h"
|
#include "minecraft/VersionFilterData.h"
|
||||||
@ -121,14 +122,22 @@ bool ModFolderPage::eventFilter(QObject *obj, QEvent *ev)
|
|||||||
|
|
||||||
void ModFolderPage::on_addModBtn_clicked()
|
void ModFolderPage::on_addModBtn_clicked()
|
||||||
{
|
{
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(
|
auto list = GuiUtil::BrowseForMods(
|
||||||
this, QApplication::translate("ModFolderPage", "Select Loader Mods"), MMC->settings()->get("CentralModsDir").toString());
|
m_helpName,
|
||||||
for (auto filename : fileNames)
|
tr("Select %1",
|
||||||
|
"Select whatever type of files the page contains. Example: 'Loader Mods'")
|
||||||
|
.arg(m_displayName),
|
||||||
|
tr("%1 (*.zip *.jar)").arg(m_displayName), this->parentWidget());
|
||||||
|
if (!list.empty())
|
||||||
{
|
{
|
||||||
m_mods->stopWatching();
|
m_mods->stopWatching();
|
||||||
m_mods->installMod(QFileInfo(filename));
|
for (auto filename : list)
|
||||||
|
{
|
||||||
|
m_mods->installMod(QFileInfo(filename));
|
||||||
|
}
|
||||||
m_mods->startWatching();
|
m_mods->startWatching();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void ModFolderPage::on_rmModBtn_clicked()
|
void ModFolderPage::on_rmModBtn_clicked()
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "dialogs/ModEditDialogCommon.h"
|
#include "dialogs/ModEditDialogCommon.h"
|
||||||
|
|
||||||
#include "dialogs/ProgressDialog.h"
|
#include "dialogs/ProgressDialog.h"
|
||||||
|
#include <GuiUtil.h>
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@ -145,36 +146,11 @@ void VersionPage::on_removeLibraryBtn_clicked()
|
|||||||
|
|
||||||
void VersionPage::on_jarmodBtn_clicked()
|
void VersionPage::on_jarmodBtn_clicked()
|
||||||
{
|
{
|
||||||
QFileDialog w;
|
auto list = GuiUtil::BrowseForMods("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), this->parentWidget());
|
||||||
QSet<QString> locations;
|
if(!list.empty())
|
||||||
QString modsFolder = MMC->settings()->get("CentralModsDir").toString();
|
|
||||||
auto f = [&](QStandardPaths::StandardLocation l)
|
|
||||||
{
|
{
|
||||||
QString location = QStandardPaths::writableLocation(l);
|
m_version->installJarMods(list);
|
||||||
QFileInfo finfo(location);
|
|
||||||
if (!finfo.exists())
|
|
||||||
return;
|
|
||||||
locations.insert(location);
|
|
||||||
};
|
|
||||||
f(QStandardPaths::DesktopLocation);
|
|
||||||
f(QStandardPaths::DocumentsLocation);
|
|
||||||
f(QStandardPaths::DownloadLocation);
|
|
||||||
f(QStandardPaths::HomeLocation);
|
|
||||||
QList<QUrl> urls;
|
|
||||||
for (auto location : locations)
|
|
||||||
{
|
|
||||||
urls.append(QUrl::fromLocalFile(location));
|
|
||||||
}
|
}
|
||||||
urls.append(QUrl::fromLocalFile(modsFolder));
|
|
||||||
|
|
||||||
w.setFileMode(QFileDialog::ExistingFiles);
|
|
||||||
w.setAcceptMode(QFileDialog::AcceptOpen);
|
|
||||||
w.setNameFilter(tr("Minecraft jar mods (*.zip *.jar)"));
|
|
||||||
w.setDirectory(modsFolder);
|
|
||||||
w.setSidebarUrls(urls);
|
|
||||||
|
|
||||||
if (w.exec())
|
|
||||||
m_version->installJarMods(w.selectedFiles());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VersionPage::on_resetLibraryOrderBtn_clicked()
|
void VersionPage::on_resetLibraryOrderBtn_clicked()
|
||||||
|
Loading…
Reference in New Issue
Block a user