Remove widgets from logic.
This commit is contained in:
parent
5a344a2933
commit
80d146866c
@ -124,7 +124,7 @@ void OneSixModEditDialog::disableVersionControls()
|
||||
|
||||
void OneSixModEditDialog::on_reloadLibrariesBtn_clicked()
|
||||
{
|
||||
m_inst->reloadVersion(this);
|
||||
m_inst->reloadVersion();
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_removeLibraryBtn_clicked()
|
||||
@ -137,7 +137,7 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_inst->reloadVersion(this);
|
||||
m_inst->reloadVersion();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -145,7 +145,7 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked()
|
||||
void OneSixModEditDialog::on_resetLibraryOrderBtn_clicked()
|
||||
{
|
||||
QDir(m_inst->instanceRoot()).remove("order.json");
|
||||
m_inst->reloadVersion(this);
|
||||
m_inst->reloadVersion();
|
||||
}
|
||||
void OneSixModEditDialog::on_moveLibraryUpBtn_clicked()
|
||||
{
|
||||
@ -181,7 +181,7 @@ void OneSixModEditDialog::on_moveLibraryUpBtn_clicked()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_inst->reloadVersion(this);
|
||||
m_inst->reloadVersion();
|
||||
ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow - 1), QItemSelectionModel::SelectCurrent);
|
||||
}
|
||||
}
|
||||
@ -218,7 +218,7 @@ void OneSixModEditDialog::on_moveLibraryDownBtn_clicked()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_inst->reloadVersion(this);
|
||||
m_inst->reloadVersion();
|
||||
ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow + 1), QItemSelectionModel::SelectCurrent);
|
||||
}
|
||||
}
|
||||
@ -232,7 +232,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||
return;
|
||||
}
|
||||
QDir(m_inst->instanceRoot()).remove("custom.json");
|
||||
m_inst->reloadVersion(this);
|
||||
m_inst->reloadVersion();
|
||||
}
|
||||
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
|
||||
vselect.setFilter(1, m_inst->currentVersionId());
|
||||
@ -277,7 +277,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
m_inst->reloadVersion(this);
|
||||
m_inst->reloadVersion();
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
||||
@ -289,7 +289,7 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
||||
return;
|
||||
}
|
||||
QDir(m_inst->instanceRoot()).remove("custom.json");
|
||||
m_inst->reloadVersion(this);
|
||||
m_inst->reloadVersion();
|
||||
}
|
||||
VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"), this);
|
||||
vselect.setFilter(1, m_inst->currentVersionId());
|
||||
@ -310,7 +310,7 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_inst->reloadVersion(this);
|
||||
m_inst->reloadVersion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -316,14 +316,14 @@ QString OneSixInstance::currentVersionId() const
|
||||
return intendedVersionId();
|
||||
}
|
||||
|
||||
bool OneSixInstance::reloadVersion(QWidget *widgetParent)
|
||||
bool OneSixInstance::reloadVersion()
|
||||
{
|
||||
I_D(OneSixInstance);
|
||||
|
||||
bool ret = d->version->reload(widgetParent, false, externalPatches());
|
||||
bool ret = d->version->reload(false, externalPatches());
|
||||
if (ret)
|
||||
{
|
||||
ret = d->vanillaVersion->reload(widgetParent, true, externalPatches());
|
||||
ret = d->vanillaVersion->reload(true, externalPatches());
|
||||
}
|
||||
if (ret)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
virtual QDialog *createModEditDialog(QWidget *parent) override;
|
||||
|
||||
/// reload the full version json files. return true on success!
|
||||
bool reloadVersion(QWidget *widgetParent = 0);
|
||||
bool reloadVersion();
|
||||
/// clears all version information in preparation for an update
|
||||
void clearVersion();
|
||||
/// get the current full version info
|
||||
|
@ -37,13 +37,11 @@ OneSixVersionBuilder::OneSixVersionBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
bool OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance,
|
||||
QWidget *widgetParent, const bool onlyVanilla, const QStringList &external)
|
||||
bool OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance, const bool onlyVanilla, const QStringList &external)
|
||||
{
|
||||
OneSixVersionBuilder builder;
|
||||
builder.m_version = version;
|
||||
builder.m_instance = instance;
|
||||
builder.m_widgetParent = widgetParent;
|
||||
return builder.buildInternal(onlyVanilla, external);
|
||||
}
|
||||
|
||||
@ -52,7 +50,6 @@ bool OneSixVersionBuilder::readJsonAndApplyToVersion(VersionFinal *version, cons
|
||||
OneSixVersionBuilder builder;
|
||||
builder.m_version = version;
|
||||
builder.m_instance = 0;
|
||||
builder.m_widgetParent = 0;
|
||||
return builder.readJsonAndApply(obj);
|
||||
}
|
||||
|
||||
@ -117,11 +114,13 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi
|
||||
auto error = file.applyTo(m_version);
|
||||
if (error != VersionFile::NoApplyError)
|
||||
{
|
||||
/*
|
||||
QMessageBox::critical(
|
||||
m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr(
|
||||
"Error while applying %1. Please check MultiMC-0.log for more info.")
|
||||
.arg(root.absoluteFilePath("version.json")));
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -159,10 +158,12 @@ bool OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi
|
||||
auto error = filePair.second.applyTo(m_version);
|
||||
if (error != VersionFile::NoApplyError)
|
||||
{
|
||||
/*
|
||||
QMessageBox::critical(
|
||||
m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr("Error while applying %1. Please check MultiMC-0.log "
|
||||
"for more info.").arg(filePair.first));
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -206,24 +207,30 @@ bool OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj)
|
||||
VersionFile file = VersionFile::fromJson(QJsonDocument(obj), QString(), false, isError);
|
||||
if (isError)
|
||||
{
|
||||
/*
|
||||
QMessageBox::critical(
|
||||
m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr("Error while reading. Please check MultiMC-0.log for more info."));
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
VersionFile::ApplyError error = file.applyTo(m_version);
|
||||
if (error == VersionFile::OtherError)
|
||||
{
|
||||
/*
|
||||
QMessageBox::critical(
|
||||
m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr("Error while applying. Please check MultiMC-0.log for more info."));
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
else if (error == VersionFile::LauncherVersionError)
|
||||
{
|
||||
/*
|
||||
QMessageBox::critical(
|
||||
m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr("The version descriptors of this instance are not compatible with the current version of MultiMC"));
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -235,29 +242,35 @@ bool OneSixVersionBuilder::parseJsonFile(const QFileInfo& fileInfo, const bool r
|
||||
QFile file(fileInfo.absoluteFilePath());
|
||||
if (!file.open(QFile::ReadOnly))
|
||||
{
|
||||
/*
|
||||
QMessageBox::critical(
|
||||
m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr("Unable to open %1: %2").arg(file.fileName(), file.errorString()));
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
QJsonParseError error;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError)
|
||||
{
|
||||
/*
|
||||
QMessageBox::critical(m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr("Unable to parse %1: %2 at %3")
|
||||
.arg(file.fileName(), error.errorString())
|
||||
.arg(error.offset));
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
bool isError = false;
|
||||
*out = VersionFile::fromJson(doc, file.fileName(), requireOrder, isError, isFTB);
|
||||
if (isError)
|
||||
{
|
||||
/*
|
||||
QMessageBox::critical(
|
||||
m_widgetParent, QObject::tr("Error"),
|
||||
QObject::tr("Error while reading %1. Please check MultiMC-0.log for more info.")
|
||||
.arg(file.fileName()));
|
||||
*/
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
class VersionFinal;
|
||||
class OneSixInstance;
|
||||
class QWidget;
|
||||
class QJsonObject;
|
||||
class QFileInfo;
|
||||
class VersionFile;
|
||||
@ -29,7 +28,7 @@ class OneSixVersionBuilder
|
||||
{
|
||||
OneSixVersionBuilder();
|
||||
public:
|
||||
static bool build(VersionFinal *version, OneSixInstance *instance, QWidget *widgetParent, const bool onlyVanilla, const QStringList &external);
|
||||
static bool build(VersionFinal *version, OneSixInstance *instance, const bool onlyVanilla, const QStringList &external);
|
||||
static bool readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj);
|
||||
|
||||
static QMap<QString, int> readOverrideOrders(OneSixInstance *instance);
|
||||
@ -38,7 +37,6 @@ public:
|
||||
private:
|
||||
VersionFinal *m_version;
|
||||
OneSixInstance *m_instance;
|
||||
QWidget *m_widgetParent;
|
||||
|
||||
bool buildInternal(const bool onlyVanilla, const QStringList &external);
|
||||
bool readJsonAndApply(const QJsonObject &obj);
|
||||
|
@ -26,10 +26,10 @@ VersionFinal::VersionFinal(OneSixInstance *instance, QObject *parent)
|
||||
clear();
|
||||
}
|
||||
|
||||
bool VersionFinal::reload(QWidget *widgetParent, const bool onlyVanilla, const QStringList &external)
|
||||
bool VersionFinal::reload(const bool onlyVanilla, const QStringList &external)
|
||||
{
|
||||
beginResetModel();
|
||||
bool ret = OneSixVersionBuilder::build(this, m_instance, widgetParent, onlyVanilla, external);
|
||||
bool ret = OneSixVersionBuilder::build(this, m_instance, onlyVanilla, external);
|
||||
endResetModel();
|
||||
return ret;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
virtual int columnCount(const QModelIndex &parent) const;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
bool reload(QWidget *widgetParent, const bool onlyVanilla = false, const QStringList &external = QStringList());
|
||||
bool reload(const bool onlyVanilla = false, const QStringList &external = QStringList());
|
||||
void clear();
|
||||
|
||||
void dump() const;
|
||||
|
Loading…
Reference in New Issue
Block a user