diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-05-19 02:22:09 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-09 01:38:31 +0200 |
commit | e118b1f9901d8d006dbe268b4b4047de27e4531d (patch) | |
tree | 6267039d1ff6047544ac98568f6382f751d93d35 /gui/dialogs | |
parent | 55a0d110b654a93ef1bb9ee50a6f02ecaec7f88d (diff) | |
download | MultiMC-e118b1f9901d8d006dbe268b4b4047de27e4531d.tar MultiMC-e118b1f9901d8d006dbe268b4b4047de27e4531d.tar.gz MultiMC-e118b1f9901d8d006dbe268b4b4047de27e4531d.tar.lz MultiMC-e118b1f9901d8d006dbe268b4b4047de27e4531d.tar.xz MultiMC-e118b1f9901d8d006dbe268b4b4047de27e4531d.zip |
Implement adding jar mods, break saving library order.
Diffstat (limited to 'gui/dialogs')
-rw-r--r-- | gui/dialogs/InstanceEditDialog.cpp | 47 | ||||
-rw-r--r-- | gui/dialogs/InstanceEditDialog.h | 2 |
2 files changed, 31 insertions, 18 deletions
diff --git a/gui/dialogs/InstanceEditDialog.cpp b/gui/dialogs/InstanceEditDialog.cpp index 48657c71..496d6973 100644 --- a/gui/dialogs/InstanceEditDialog.cpp +++ b/gui/dialogs/InstanceEditDialog.cpp @@ -35,7 +35,7 @@ #include "InstanceSettings.h" #include "logic/ModList.h" -#include "logic/minecraft/VersionFinal.h" +#include "logic/minecraft/InstanceVersion.h" #include "logic/EnabledItemFilter.h" #include "logic/forge/ForgeVersionList.h" #include "logic/forge/ForgeInstaller.h" @@ -175,21 +175,34 @@ 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<QListView *>("listView"); - if (l) + QSet<QString> locations; + QString modsFolder = MMC->settings()->get("CentralModsDir").toString(); + auto f = [&](QStandardPaths::StandardLocation l) { - l->setSelectionMode(QAbstractItemView::ExtendedSelection); - } - QTreeView *t = w.findChild<QTreeView *>(); - if (t) - { - t->setSelectionMode(QAbstractItemView::ExtendedSelection); - } - int result = w.exec(); - auto list = w.selectedFiles(); - QLOG_INFO() << list.join(" "); + QString location = QStandardPaths::writableLocation(l); + if(!QFileInfo::exists(location)) + return; + locations.insert(location); + }; + f(QStandardPaths::DesktopLocation); + f(QStandardPaths::DocumentsLocation); + f(QStandardPaths::DownloadLocation); + f(QStandardPaths::HomeLocation); + QList<QUrl> urls; + for(auto location: locations) + { + urls.append(QUrl::fromLocalFile(location)); + } + urls.append(QUrl::fromLocalFile(modsFolder)); + + w.setFileMode(QFileDialog::ExistingFiles); + w.setAcceptMode(QFileDialog::AcceptOpen); + w.setNameFilter(tr("Minecraft jar mods (*.zip *.jar)")); + w.setDirectory(modsFolder); + w.setSidebarUrls(urls); + + if(w.exec()); + m_version->installJarMods(w.selectedFiles()); } void InstanceEditDialog::on_resetLibraryOrderBtn_clicked() @@ -214,7 +227,7 @@ void InstanceEditDialog::on_moveLibraryUpBtn_clicked() { const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row(); const int newRow = 0; - m_version->move(row, VersionFinal::MoveUp); + m_version->move(row, InstanceVersion::MoveUp); // ui->libraryTreeView->selectionModel()->setCurrentIndex(m_version->index(newRow), // QItemSelectionModel::ClearAndSelect); } @@ -234,7 +247,7 @@ void InstanceEditDialog::on_moveLibraryDownBtn_clicked() { const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row(); const int newRow = 0; - m_version->move(row, VersionFinal::MoveDown); + m_version->move(row, InstanceVersion::MoveDown); // ui->libraryTreeView->selectionModel()->setCurrentIndex(m_version->index(newRow), // QItemSelectionModel::ClearAndSelect); } diff --git a/gui/dialogs/InstanceEditDialog.h b/gui/dialogs/InstanceEditDialog.h index e99899be..7661ff7f 100644 --- a/gui/dialogs/InstanceEditDialog.h +++ b/gui/dialogs/InstanceEditDialog.h @@ -80,7 +80,7 @@ protected: private: Ui::InstanceEditDialog *ui; - std::shared_ptr<VersionFinal> m_version; + std::shared_ptr<InstanceVersion> m_version; std::shared_ptr<ModList> m_mods; std::shared_ptr<ModList> m_coremods; std::shared_ptr<ModList> m_jarmods; |