Merge pull request #1825 from Trial97/ftb_import
This commit is contained in:
parent
bcb5b9c9c2
commit
557fce577a
@ -748,6 +748,9 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
|||||||
m_settings->registerSetting("ModrinthToken", "");
|
m_settings->registerSetting("ModrinthToken", "");
|
||||||
m_settings->registerSetting("UserAgentOverride", "");
|
m_settings->registerSetting("UserAgentOverride", "");
|
||||||
|
|
||||||
|
// FTBApp instances
|
||||||
|
m_settings->registerSetting("FTBAppInstancesPath", "");
|
||||||
|
|
||||||
// Init page provider
|
// Init page provider
|
||||||
{
|
{
|
||||||
m_globalSettingsProvider = std::make_shared<GenericPageProvider>(tr("Settings"));
|
m_globalSettingsProvider = std::make_shared<GenericPageProvider>(tr("Settings"));
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "ui/widgets/ProjectItem.h"
|
#include "ui/widgets/ProjectItem.h"
|
||||||
#include "ui_ImportFTBPage.h"
|
#include "ui_ImportFTBPage.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "ListModel.h"
|
#include "ListModel.h"
|
||||||
@ -56,6 +57,13 @@ ImportFTBPage::ImportFTBPage(NewInstanceDialog* dialog, QWidget* parent) : QWidg
|
|||||||
|
|
||||||
connect(ui->searchEdit, &QLineEdit::textChanged, this, &ImportFTBPage::triggerSearch);
|
connect(ui->searchEdit, &QLineEdit::textChanged, this, &ImportFTBPage::triggerSearch);
|
||||||
|
|
||||||
|
connect(ui->browseButton, &QPushButton::clicked, this, [this] {
|
||||||
|
auto path = listModel->getPath();
|
||||||
|
QString dir = QFileDialog::getExistingDirectory(this, tr("Select FTBApp instances directory"), path, QFileDialog::ShowDirsOnly);
|
||||||
|
if (!dir.isEmpty())
|
||||||
|
listModel->setPath(dir);
|
||||||
|
});
|
||||||
|
|
||||||
ui->modpackList->setItemDelegate(new ProjectItemDelegate(this));
|
ui->modpackList->setItemDelegate(new ProjectItemDelegate(this));
|
||||||
ui->modpackList->selectionModel()->reset();
|
ui->modpackList->selectionModel()->reset();
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QTreeView" name="modpackList">
|
<widget class="QTreeView" name="modpackList">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
@ -21,28 +21,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="3" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="searchEdit">
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Search and filter...</string>
|
|
||||||
</property>
|
|
||||||
<property name="clearButtonEnabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Search</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="sortByBox">
|
<widget class="QComboBox" name="sortByBox">
|
||||||
@ -69,6 +48,54 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="searchEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Search and filter...</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Search</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="browseButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Select FTBApp instances directory</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="viewfolder">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Note: If your FTB instances are not in the default location, select it using the button next to search.</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -17,11 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ListModel.h"
|
#include "ListModel.h"
|
||||||
|
#include <qfileinfo.h>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
#include "Application.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
#include "modplatform/import_ftb/PackHelpers.h"
|
#include "modplatform/import_ftb/PackHelpers.h"
|
||||||
@ -29,7 +31,7 @@
|
|||||||
|
|
||||||
namespace FTBImportAPP {
|
namespace FTBImportAPP {
|
||||||
|
|
||||||
QString getPath()
|
QString getStaticPath()
|
||||||
{
|
{
|
||||||
QString partialPath;
|
QString partialPath;
|
||||||
#if defined(Q_OS_OSX)
|
#if defined(Q_OS_OSX)
|
||||||
@ -42,14 +44,14 @@ QString getPath()
|
|||||||
return FS::PathCombine(partialPath, ".ftba");
|
return FS::PathCombine(partialPath, ".ftba");
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString ListModel::FTB_APP_PATH = getPath();
|
static const QString FTB_APP_PATH = FS::PathCombine(getStaticPath(), "instances");
|
||||||
|
|
||||||
void ListModel::update()
|
void ListModel::update()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
modpacks.clear();
|
modpacks.clear();
|
||||||
|
|
||||||
QString instancesPath = FS::PathCombine(FTB_APP_PATH, "instances");
|
QString instancesPath = getPath();
|
||||||
if (auto instancesInfo = QFileInfo(instancesPath); instancesInfo.exists() && instancesInfo.isDir()) {
|
if (auto instancesInfo = QFileInfo(instancesPath); instancesInfo.exists() && instancesInfo.isDir()) {
|
||||||
QDirIterator directoryIterator(instancesPath, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable | QDir::Hidden,
|
QDirIterator directoryIterator(instancesPath, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable | QDir::Hidden,
|
||||||
QDirIterator::FollowSymlinks);
|
QDirIterator::FollowSymlinks);
|
||||||
@ -168,4 +170,17 @@ FilterModel::Sorting FilterModel::getCurrentSorting()
|
|||||||
{
|
{
|
||||||
return currentSorting;
|
return currentSorting;
|
||||||
}
|
}
|
||||||
|
void ListModel::setPath(QString path)
|
||||||
|
{
|
||||||
|
APPLICATION->settings()->set("FTBAppInstancesPath", path);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ListModel::getPath()
|
||||||
|
{
|
||||||
|
auto path = APPLICATION->settings()->get("FTBAppInstancesPath").toString();
|
||||||
|
if (path.isEmpty() || !QFileInfo(path).exists())
|
||||||
|
path = FTB_APP_PATH;
|
||||||
|
return path;
|
||||||
|
}
|
||||||
} // namespace FTBImportAPP
|
} // namespace FTBImportAPP
|
@ -60,7 +60,8 @@ class ListModel : public QAbstractListModel {
|
|||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
static const QString FTB_APP_PATH;
|
QString getPath();
|
||||||
|
void setPath(QString path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ModpackList modpacks;
|
ModpackList modpacks;
|
||||||
|
Loading…
Reference in New Issue
Block a user