summaryrefslogtreecommitdiffstats
path: root/gui/dialogs
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-02-01 14:52:21 +0100
committerJan Dalheimer <jan@dalheimer.de>2014-02-01 14:52:21 +0100
commit4a9e213238234b03fdd994143726a3f75290fc26 (patch)
treeaf1063eeb8cc0e82c09295e52997d88d8b45a581 /gui/dialogs
parent556d8f0ec16e5030cfbfac9dc0fc2c796e829dcb (diff)
downloadMultiMC-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')
-rw-r--r--gui/dialogs/OneSixModEditDialog.cpp63
-rw-r--r--gui/dialogs/OneSixModEditDialog.h5
-rw-r--r--gui/dialogs/OneSixModEditDialog.ui36
3 files changed, 67 insertions, 37 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 &current, const QModelIndex &previous)
+{
+ if (!current.isValid())
+ {
+ ui->removeLibraryBtn->setDisabled(true);
+ }
+ else
+ {
+ ui->removeLibraryBtn->setEnabled(m_version->canRemove(current.row()));
+ }
+}
diff --git a/gui/dialogs/OneSixModEditDialog.h b/gui/dialogs/OneSixModEditDialog.h
index 161604c9..7e759f48 100644
--- a/gui/dialogs/OneSixModEditDialog.h
+++ b/gui/dialogs/OneSixModEditDialog.h
@@ -45,7 +45,9 @@ slots:
void on_buttonBox_rejected();
void on_forgeBtn_clicked();
void on_liteloaderBtn_clicked();
- void on_customEditorBtn_clicked();
+ void on_userEditorBtn_clicked();
+ void on_reloadLibrariesBtn_clicked();
+ void on_removeLibraryBtn_clicked();
void updateVersionControls();
void disableVersionControls();
@@ -64,4 +66,5 @@ private:
public
slots:
void loaderCurrent(QModelIndex current, QModelIndex previous);
+ void versionCurrent(const QModelIndex &current, const QModelIndex &previous);
};
diff --git a/gui/dialogs/OneSixModEditDialog.ui b/gui/dialogs/OneSixModEditDialog.ui
index 67642c23..d90c6d93 100644
--- a/gui/dialogs/OneSixModEditDialog.ui
+++ b/gui/dialogs/OneSixModEditDialog.ui
@@ -26,7 +26,7 @@
</size>
</property>
<property name="currentIndex">
- <number>1</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="libTab">
<attribute name="title">
@@ -36,13 +36,6 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Tweakers:</string>
- </property>
- </widget>
- </item>
- <item>
<widget class="ModListView" name="libraryTreeView">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
@@ -51,7 +44,7 @@
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<attribute name="headerVisible">
- <bool>false</bool>
+ <bool>true</bool>
</attribute>
</widget>
</item>
@@ -96,37 +89,22 @@
</item>
<item>
<widget class="Line" name="line">
- <property name="frameShadow">
- <enum>QFrame::Sunken</enum>
- </property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="addLibraryBtn">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Add new libraries</string>
- </property>
+ <widget class="QPushButton" name="reloadLibrariesBtn">
<property name="text">
- <string>&amp;Add</string>
+ <string>Reload</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeLibraryBtn">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Remove selected libraries</string>
- </property>
<property name="text">
- <string>&amp;Remove</string>
+ <string>Remove</string>
</property>
</widget>
</item>
@@ -138,9 +116,9 @@
</widget>
</item>
<item>
- <widget class="QPushButton" name="customEditorBtn">
+ <widget class="QPushButton" name="userEditorBtn">
<property name="text">
- <string>Open custom.json</string>
+ <string>Open user.json</string>
</property>
</widget>
</item>