From 55a0d110b654a93ef1bb9ee50a6f02ecaec7f88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 13 May 2014 23:57:34 +0200 Subject: Lock down the version cache. Just enough to make it annoying to corrupt the files. --- gui/dialogs/InstanceEditDialog.cpp | 55 +++++++++++++++++++++++++++++--------- gui/dialogs/InstanceEditDialog.h | 1 + 2 files changed, 43 insertions(+), 13 deletions(-) (limited to 'gui/dialogs') diff --git a/gui/dialogs/InstanceEditDialog.cpp b/gui/dialogs/InstanceEditDialog.cpp index 5bd923e3..48657c71 100644 --- a/gui/dialogs/InstanceEditDialog.cpp +++ b/gui/dialogs/InstanceEditDialog.cpp @@ -50,6 +50,7 @@ #include "CustomMessageBox.h" #include #include +#include #include #include @@ -171,6 +172,26 @@ void InstanceEditDialog::on_removeLibraryBtn_clicked() } } +void InstanceEditDialog::on_jarmodBtn_clicked() +{ + QFileDialog w; + w.setFileMode(QFileDialog::AnyFile); + // w.setOption(QFileDialog::DontUseNativeDialog, true); + QListView *l = w.findChild("listView"); + if (l) + { + l->setSelectionMode(QAbstractItemView::ExtendedSelection); + } + QTreeView *t = w.findChild(); + if (t) + { + t->setSelectionMode(QAbstractItemView::ExtendedSelection); + } + int result = w.exec(); + auto list = w.selectedFiles(); + QLOG_INFO() << list.join(" "); +} + void InstanceEditDialog::on_resetLibraryOrderBtn_clicked() { try @@ -192,8 +213,10 @@ void InstanceEditDialog::on_moveLibraryUpBtn_clicked() try { const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row(); - const int newRow = 0;m_version->move(row, VersionFinal::MoveUp); - //ui->libraryTreeView->selectionModel()->setCurrentIndex(m_version->index(newRow), QItemSelectionModel::ClearAndSelect); + const int newRow = 0; + m_version->move(row, VersionFinal::MoveUp); + // ui->libraryTreeView->selectionModel()->setCurrentIndex(m_version->index(newRow), + // QItemSelectionModel::ClearAndSelect); } catch (MMCError &e) { @@ -210,8 +233,10 @@ void InstanceEditDialog::on_moveLibraryDownBtn_clicked() try { const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row(); - const int newRow = 0;m_version->move(row, VersionFinal::MoveDown); - //ui->libraryTreeView->selectionModel()->setCurrentIndex(m_version->index(newRow), QItemSelectionModel::ClearAndSelect); + const int newRow = 0; + m_version->move(row, VersionFinal::MoveDown); + // ui->libraryTreeView->selectionModel()->setCurrentIndex(m_version->index(newRow), + // QItemSelectionModel::ClearAndSelect); } catch (MMCError &e) { @@ -221,7 +246,8 @@ void InstanceEditDialog::on_moveLibraryDownBtn_clicked() void InstanceEditDialog::on_changeMCVersionBtn_clicked() { - VersionSelectDialog vselect(m_inst->versionList().get(), tr("Change Minecraft version"), this); + VersionSelectDialog vselect(m_inst->versionList().get(), tr("Change Minecraft version"), + this); if (!vselect.exec() || !vselect.selectedVersion()) return; @@ -266,8 +292,9 @@ void InstanceEditDialog::on_forgeBtn_clicked() // FIXME: use actual model, not reloading. Move logic to model. if (m_version->hasFtbPack()) { - if (QMessageBox::question(this, tr("Revert?"), - tr("This action will remove the FTB pack version patch. Continue?")) != + if (QMessageBox::question( + this, tr("Revert?"), + tr("This action will remove the FTB pack version patch. Continue?")) != QMessageBox::Yes) { return; @@ -293,7 +320,8 @@ void InstanceEditDialog::on_forgeBtn_clicked() if (vselect.exec() && vselect.selectedVersion()) { ProgressDialog dialog(this); - dialog.exec(ForgeInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this)); + dialog.exec( + ForgeInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this)); } } @@ -301,8 +329,9 @@ void InstanceEditDialog::on_liteloaderBtn_clicked() { if (m_version->hasFtbPack()) { - if (QMessageBox::question(this, tr("Revert?"), - tr("This action will remove the FTB pack version patch. Continue?")) != + if (QMessageBox::question( + this, tr("Revert?"), + tr("This action will remove the FTB pack version patch. Continue?")) != QMessageBox::Yes) { return; @@ -329,7 +358,8 @@ void InstanceEditDialog::on_liteloaderBtn_clicked() if (vselect.exec() && vselect.selectedVersion()) { ProgressDialog dialog(this); - dialog.exec(LiteLoaderInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this)); + dialog.exec( + LiteLoaderInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this)); } } @@ -497,8 +527,7 @@ void InstanceEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous ui->frame->updateWithMod(m); } -void InstanceEditDialog::versionCurrent(const QModelIndex ¤t, - const QModelIndex &previous) +void InstanceEditDialog::versionCurrent(const QModelIndex ¤t, const QModelIndex &previous) { if (!current.isValid()) { diff --git a/gui/dialogs/InstanceEditDialog.h b/gui/dialogs/InstanceEditDialog.h index d601074a..e99899be 100644 --- a/gui/dialogs/InstanceEditDialog.h +++ b/gui/dialogs/InstanceEditDialog.h @@ -44,6 +44,7 @@ slots: void on_resetLibraryOrderBtn_clicked(); void on_moveLibraryUpBtn_clicked(); void on_moveLibraryDownBtn_clicked(); + void on_jarmodBtn_clicked(); // loader mod tab void on_addModBtn_clicked(); -- cgit v1.2.3