mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-10-04 01:00:22 +00:00
GH-899 clean up mod browse buttons and dead legacy forge
This commit is contained in:
@@ -3,11 +3,15 @@
|
||||
#include <QClipboard>
|
||||
#include <QDesktopServices>
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "dialogs/ProgressDialog.h"
|
||||
#include "net/PasteUpload.h"
|
||||
#include "dialogs/CustomMessageBox.h"
|
||||
|
||||
#include "MultiMC.h"
|
||||
#include <settings/SettingsObject.h>
|
||||
|
||||
void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)
|
||||
{
|
||||
ProgressDialog dialog(parentWidget);
|
||||
@@ -46,3 +50,52 @@ void GuiUtil::setClipboardText(const QString &text)
|
||||
{
|
||||
QApplication::clipboard()->setText(text);
|
||||
}
|
||||
|
||||
QStringList GuiUtil::BrowseForMods(QString context, QString caption, QString filter,
|
||||
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);
|
||||
QFileInfo finfo(location);
|
||||
if (!finfo.exists())
|
||||
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(filter);
|
||||
if(savedPaths.contains(context))
|
||||
{
|
||||
w.setDirectory(savedPaths[context]);
|
||||
}
|
||||
else
|
||||
{
|
||||
w.setDirectory(modsFolder);
|
||||
}
|
||||
w.setSidebarUrls(urls);
|
||||
|
||||
if (w.exec())
|
||||
{
|
||||
savedPaths[context] = w.directory().absolutePath();
|
||||
return w.getOpenFileNames();
|
||||
}
|
||||
savedPaths[context] = w.directory().absolutePath();
|
||||
return {};
|
||||
}
|
||||
|
Reference in New Issue
Block a user