summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/GuiUtil.cpp22
-rw-r--r--application/GuiUtil.h2
-rw-r--r--application/pages/LegacyJarModPage.cpp2
-rw-r--r--application/pages/ModFolderPage.cpp7
-rw-r--r--application/pages/VersionPage.cpp2
-rw-r--r--application/pages/WorldListPage.cpp20
-rw-r--r--application/pages/WorldListPage.h1
-rw-r--r--application/pages/WorldListPage.ui35
8 files changed, 69 insertions, 22 deletions
diff --git a/application/GuiUtil.cpp b/application/GuiUtil.cpp
index 922d38fa..edfe9951 100644
--- a/application/GuiUtil.cpp
+++ b/application/GuiUtil.cpp
@@ -51,14 +51,13 @@ void GuiUtil::setClipboardText(const QString &text)
QApplication::clipboard()->setText(text);
}
-QStringList GuiUtil::BrowseForMods(QString context, QString caption, QString filter,
- QWidget *parentWidget)
+
+QStringList GuiUtil::BrowseForFiles(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget)
{
static QMap<QString, QString> savedPaths;
QFileDialog w(parentWidget, caption);
QSet<QString> locations;
- QString modsFolder = MMC->settings()->get("CentralModsDir").toString();
auto f = [&](QStandardPaths::StandardLocation l)
{
QString location = QStandardPaths::writableLocation(l);
@@ -76,19 +75,30 @@ QStringList GuiUtil::BrowseForMods(QString context, QString caption, QString fil
{
urls.append(QUrl::fromLocalFile(location));
}
- urls.append(QUrl::fromLocalFile(modsFolder));
+ urls.append(QUrl::fromLocalFile(defaultPath));
w.setFileMode(QFileDialog::ExistingFiles);
w.setAcceptMode(QFileDialog::AcceptOpen);
w.setNameFilter(filter);
+
+ QString pathToOpen;
if(savedPaths.contains(context))
{
- w.setDirectory(savedPaths[context]);
+ pathToOpen = savedPaths[context];
}
else
{
- w.setDirectory(modsFolder);
+ pathToOpen = defaultPath;
}
+ if(!pathToOpen.isEmpty())
+ {
+ QFileInfo finfo(pathToOpen);
+ if(finfo.exists() && finfo.isDir())
+ {
+ w.setDirectory(finfo.absoluteFilePath());
+ }
+ }
+
w.setSidebarUrls(urls);
if (w.exec())
diff --git a/application/GuiUtil.h b/application/GuiUtil.h
index 4c8bdaa7..381683e4 100644
--- a/application/GuiUtil.h
+++ b/application/GuiUtil.h
@@ -6,5 +6,5 @@ namespace GuiUtil
{
void uploadPaste(const QString &text, QWidget *parentWidget);
void setClipboardText(const QString &text);
-QStringList BrowseForMods(QString context, QString caption, QString filter, QWidget *parentWidget);
+QStringList BrowseForFiles(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget);
}
diff --git a/application/pages/LegacyJarModPage.cpp b/application/pages/LegacyJarModPage.cpp
index 92977de9..87a9f3b5 100644
--- a/application/pages/LegacyJarModPage.cpp
+++ b/application/pages/LegacyJarModPage.cpp
@@ -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();
diff --git a/application/pages/ModFolderPage.cpp b/application/pages/ModFolderPage.cpp
index a70c1620..9a2a43a4 100644
--- a/application/pages/ModFolderPage.cpp
+++ b/application/pages/ModFolderPage.cpp
@@ -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;
diff --git a/application/pages/VersionPage.cpp b/application/pages/VersionPage.cpp
index d56bbd28..36091630 100644
--- a/application/pages/VersionPage.cpp
+++ b/application/pages/VersionPage.cpp
@@ -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);
diff --git a/application/pages/WorldListPage.cpp b/application/pages/WorldListPage.cpp
index 8b95b2b0..be1d58b8 100644
--- a/application/pages/WorldListPage.cpp
+++ b/application/pages/WorldListPage.cpp
@@ -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 &current, 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();
+ }
+} \ No newline at end of file
diff --git a/application/pages/WorldListPage.h b/application/pages/WorldListPage.h
index c79f1be6..f3111f93 100644
--- a/application/pages/WorldListPage.h
+++ b/application/pages/WorldListPage.h
@@ -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 &current, const QModelIndex &previous);
};
diff --git a/application/pages/WorldListPage.ui b/application/pages/WorldListPage.ui
index 9d396fa6..ecd9709f 100644
--- a/application/pages/WorldListPage.ui
+++ b/application/pages/WorldListPage.ui
@@ -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>
@@ -64,23 +64,33 @@
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QPushButton" name="mcEditBtn">
+ <widget class="QPushButton" name="addBtn">
<property name="text">
- <string>MCEdit</string>
+ <string>Add</string>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="copySeedBtn">
+ <widget class="QPushButton" name="rmWorldBtn">
<property name="text">
- <string>Copy Seed</string>
+ <string>&amp;Remove</string>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="rmWorldBtn">
+ <widget class="LineSeparator" name="separator" native="true"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="mcEditBtn">
<property name="text">
- <string>&amp;Remove</string>
+ <string>MCEdit</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="copySeedBtn">
+ <property name="text">
+ <string>Copy Seed</string>
</property>
</widget>
</item>
@@ -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/>