GH-1227: World import using drag and drop - zip files and folders
This commit is contained in:
@ -100,7 +100,7 @@ bool LegacyJarModPage::eventFilter(QObject *obj, QEvent *ev)
|
||||
|
||||
void LegacyJarModPage::on_addJarBtn_clicked()
|
||||
{
|
||||
auto list = GuiUtil::BrowseForMods("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), this->parentWidget());
|
||||
auto list = GuiUtil::BrowseForFiles("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), MMC->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
||||
if(!list.empty())
|
||||
{
|
||||
m_jarmods->stopWatching();
|
||||
|
@ -131,12 +131,13 @@ bool ModFolderPage::eventFilter(QObject *obj, QEvent *ev)
|
||||
|
||||
void ModFolderPage::on_addModBtn_clicked()
|
||||
{
|
||||
auto list = GuiUtil::BrowseForMods(
|
||||
auto list = GuiUtil::BrowseForFiles(
|
||||
m_helpName,
|
||||
tr("Select %1",
|
||||
"Select whatever type of files the page contains. Example: 'Loader Mods'")
|
||||
.arg(m_displayName),
|
||||
m_filter.arg(m_displayName), this->parentWidget());
|
||||
m_filter.arg(m_displayName), MMC->settings()->get("CentralModsDir").toString(),
|
||||
this->parentWidget());
|
||||
if (!list.empty())
|
||||
{
|
||||
m_mods->stopWatching();
|
||||
@ -146,8 +147,8 @@ void ModFolderPage::on_addModBtn_clicked()
|
||||
}
|
||||
m_mods->startWatching();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ModFolderPage::on_rmModBtn_clicked()
|
||||
{
|
||||
int first, last;
|
||||
|
@ -180,7 +180,7 @@ void VersionPage::on_jarmodBtn_clicked()
|
||||
nagShown = true;
|
||||
}
|
||||
}
|
||||
auto list = GuiUtil::BrowseForMods("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), this->parentWidget());
|
||||
auto list = GuiUtil::BrowseForFiles("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), MMC->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
||||
if(!list.empty())
|
||||
{
|
||||
m_version->installJarMods(list);
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
|
||||
#include "MultiMC.h"
|
||||
#include <GuiUtil.h>
|
||||
|
||||
WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QString id,
|
||||
QString iconName, QString displayName, QString helpPage,
|
||||
@ -67,8 +68,6 @@ WorldListPage::~WorldListPage()
|
||||
|
||||
bool WorldListPage::shouldDisplay() const
|
||||
{
|
||||
if (m_inst)
|
||||
return !m_inst->isRunning();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -200,3 +199,20 @@ void WorldListPage::worldChanged(const QModelIndex ¤t, const QModelIndex &
|
||||
ui->mcEditBtn->setEnabled(enable);
|
||||
ui->rmWorldBtn->setEnabled(enable);
|
||||
}
|
||||
|
||||
void WorldListPage::on_addBtn_clicked()
|
||||
{
|
||||
auto list = GuiUtil::BrowseForFiles(
|
||||
m_helpName,
|
||||
tr("Select a Minecraft world zip"),
|
||||
tr("Minecraft World Zip File (*.zip)"), QString(), this->parentWidget());
|
||||
if (!list.empty())
|
||||
{
|
||||
m_worlds->stopWatching();
|
||||
for (auto filename : list)
|
||||
{
|
||||
m_worlds->installWorld(QFileInfo(filename));
|
||||
}
|
||||
m_worlds->startWatching();
|
||||
}
|
||||
}
|
@ -81,6 +81,7 @@ private slots:
|
||||
void on_copySeedBtn_clicked();
|
||||
void on_mcEditBtn_clicked();
|
||||
void on_rmWorldBtn_clicked();
|
||||
void on_addBtn_clicked();
|
||||
void on_viewFolderBtn_clicked();
|
||||
void worldChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
};
|
||||
|
@ -48,7 +48,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DropOnly</enum>
|
||||
<enum>QAbstractItemView::DragDrop</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
@ -63,6 +63,23 @@
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="addBtn">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="rmWorldBtn">
|
||||
<property name="text">
|
||||
<string>&Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LineSeparator" name="separator" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="mcEditBtn">
|
||||
<property name="text">
|
||||
@ -77,13 +94,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="rmWorldBtn">
|
||||
<property name="text">
|
||||
<string>&Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@ -112,12 +122,21 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineSeparator</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/LineSeparator.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>worldTreeView</tabstop>
|
||||
<tabstop>addBtn</tabstop>
|
||||
<tabstop>rmWorldBtn</tabstop>
|
||||
<tabstop>mcEditBtn</tabstop>
|
||||
<tabstop>copySeedBtn</tabstop>
|
||||
<tabstop>rmWorldBtn</tabstop>
|
||||
<tabstop>viewFolderBtn</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
|
Reference in New Issue
Block a user