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