diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2014-02-01 14:52:21 +0100 |
---|---|---|
committer | Jan Dalheimer <jan@dalheimer.de> | 2014-02-01 14:52:21 +0100 |
commit | 4a9e213238234b03fdd994143726a3f75290fc26 (patch) | |
tree | af1063eeb8cc0e82c09295e52997d88d8b45a581 /gui/dialogs/OneSixModEditDialog.cpp | |
parent | 556d8f0ec16e5030cfbfac9dc0fc2c796e829dcb (diff) | |
download | MultiMC-4a9e213238234b03fdd994143726a3f75290fc26.tar MultiMC-4a9e213238234b03fdd994143726a3f75290fc26.tar.gz MultiMC-4a9e213238234b03fdd994143726a3f75290fc26.tar.lz MultiMC-4a9e213238234b03fdd994143726a3f75290fc26.tar.xz MultiMC-4a9e213238234b03fdd994143726a3f75290fc26.zip |
Change the OneSix library view. It now shows a list of patches.
Diffstat (limited to 'gui/dialogs/OneSixModEditDialog.cpp')
-rw-r--r-- | gui/dialogs/OneSixModEditDialog.cpp | 63 |
1 files changed, 56 insertions, 7 deletions
diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp index ad15311b..a34409f5 100644 --- a/gui/dialogs/OneSixModEditDialog.cpp +++ b/gui/dialogs/OneSixModEditDialog.cpp @@ -55,6 +55,8 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent) main_model->setSourceModel(m_version.get()); ui->libraryTreeView->setModel(main_model); ui->libraryTreeView->installEventFilter(this); + connect(ui->libraryTreeView->selectionModel(), &QItemSelectionModel::currentChanged, + this, &OneSixModEditDialog::versionCurrent); updateVersionControls(); } else @@ -93,10 +95,8 @@ OneSixModEditDialog::~OneSixModEditDialog() void OneSixModEditDialog::updateVersionControls() { - bool customVersion = m_inst->versionIsCustom(); ui->forgeBtn->setEnabled(true); ui->liteloaderBtn->setEnabled(LiteLoaderInstaller().canApply(m_inst)); - ui->customEditorBtn->setEnabled(customVersion); ui->mainClassEdit->setText(m_version->mainClass); } @@ -104,23 +104,52 @@ void OneSixModEditDialog::disableVersionControls() { ui->forgeBtn->setEnabled(false); ui->liteloaderBtn->setEnabled(false); - ui->customEditorBtn->setEnabled(false); + ui->reloadLibrariesBtn->setEnabled(false); + ui->removeLibraryBtn->setEnabled(false); ui->mainClassEdit->setText(""); } -void OneSixModEditDialog::on_customEditorBtn_clicked() +void OneSixModEditDialog::on_userEditorBtn_clicked() { - if (QDir(m_inst->instanceRoot()).exists("custom.json")) + if (QDir(m_inst->instanceRoot()).exists("user.json")) + { + if (!MMC->openJsonEditor(m_inst->instanceRoot() + "/user.json")) + { + QMessageBox::warning(this, tr("Error"), tr("Unable to open user.json, check the settings")); + } + } +} + +void OneSixModEditDialog::on_reloadLibrariesBtn_clicked() +{ + m_inst->reloadVersion(this); +} + +void OneSixModEditDialog::on_removeLibraryBtn_clicked() +{ + if (ui->libraryTreeView->currentIndex().isValid()) { - if (!MMC->openJsonEditor(m_inst->instanceRoot() + "/custom.json")) + if (!m_version->remove(ui->libraryTreeView->currentIndex().row())) { - QMessageBox::warning(this, tr("Error"), tr("Unable to open custom.json, check the settings")); + QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file")); + } + else + { + m_inst->reloadVersion(this); } } } void OneSixModEditDialog::on_forgeBtn_clicked() { + if (QDir(m_inst->instanceRoot()).exists("custom.json")) + { + if (QMessageBox::question(this, tr("Revert?"), tr("This action will remove your custom.json. Continue?")) != QMessageBox::Yes) + { + return; + } + QDir(m_inst->instanceRoot()).remove("custom.json"); + } VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this); vselect.setFilter(1, m_inst->currentVersionId()); if (vselect.exec() && vselect.selectedVersion()) @@ -167,6 +196,14 @@ void OneSixModEditDialog::on_forgeBtn_clicked() void OneSixModEditDialog::on_liteloaderBtn_clicked() { + if (QDir(m_inst->instanceRoot()).exists("custom.json")) + { + if (QMessageBox::question(this, tr("Revert?"), tr("This action will remove your custom.json. Continue?")) != QMessageBox::Yes) + { + return; + } + QDir(m_inst->instanceRoot()).remove("custom.json"); + } LiteLoaderInstaller liteloader; if (!liteloader.canApply(m_inst)) { @@ -304,3 +341,15 @@ void OneSixModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previou Mod &m = m_mods->operator[](row); ui->frame->updateWithMod(m); } + +void OneSixModEditDialog::versionCurrent(const QModelIndex ¤t, const QModelIndex &previous) +{ + if (!current.isValid()) + { + ui->removeLibraryBtn->setDisabled(true); + } + else + { + ui->removeLibraryBtn->setEnabled(m_version->canRemove(current.row())); + } +} |