From 7f438425aa84db51211123b47622a828be0aeb96 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Thu, 29 Dec 2022 19:47:19 -0700
Subject: refactor: add an `identify` function to make easy to reuse
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/minecraft/mod/tasks/LocalResourceParse.h | 31 +++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 launcher/minecraft/mod/tasks/LocalResourceParse.h
(limited to 'launcher/minecraft/mod/tasks/LocalResourceParse.h')
diff --git a/launcher/minecraft/mod/tasks/LocalResourceParse.h b/launcher/minecraft/mod/tasks/LocalResourceParse.h
new file mode 100644
index 00000000..b3e2829d
--- /dev/null
+++ b/launcher/minecraft/mod/tasks/LocalResourceParse.h
@@ -0,0 +1,31 @@
+// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+//
+// SPDX-License-Identifier: GPL-3.0-only
+
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+
+#include
+#include
+#include
+
+enum class PackedResourceType { DataPack, ResourcePack, TexturePack, ShaderPack, WorldSave, Mod, UNKNOWN };
+namespace ResourceUtils {
+PackedResourceType identify(QFileInfo file);
+} // namespace ResourceUtils
\ No newline at end of file
--
cgit
From 0ebf04a021c633cd6a3cdd76514aa728dc253714 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Fri, 30 Dec 2022 10:21:49 -0700
Subject: fix newlines
Co-authored-by: flow
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/minecraft/mod/tasks/LocalResourceParse.cpp | 2 +-
launcher/minecraft/mod/tasks/LocalResourceParse.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'launcher/minecraft/mod/tasks/LocalResourceParse.h')
diff --git a/launcher/minecraft/mod/tasks/LocalResourceParse.cpp b/launcher/minecraft/mod/tasks/LocalResourceParse.cpp
index 244b2f54..19ddc899 100644
--- a/launcher/minecraft/mod/tasks/LocalResourceParse.cpp
+++ b/launcher/minecraft/mod/tasks/LocalResourceParse.cpp
@@ -57,4 +57,4 @@ PackedResourceType identify(QFileInfo file){
}
return PackedResourceType::UNKNOWN;
}
-}
\ No newline at end of file
+}
diff --git a/launcher/minecraft/mod/tasks/LocalResourceParse.h b/launcher/minecraft/mod/tasks/LocalResourceParse.h
index b3e2829d..b07a874c 100644
--- a/launcher/minecraft/mod/tasks/LocalResourceParse.h
+++ b/launcher/minecraft/mod/tasks/LocalResourceParse.h
@@ -28,4 +28,4 @@
enum class PackedResourceType { DataPack, ResourcePack, TexturePack, ShaderPack, WorldSave, Mod, UNKNOWN };
namespace ResourceUtils {
PackedResourceType identify(QFileInfo file);
-} // namespace ResourceUtils
\ No newline at end of file
+} // namespace ResourceUtils
--
cgit
From 03b75bf2a98edd4114be4799f974bb10fe9b82c4 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Fri, 30 Dec 2022 18:06:17 -0700
Subject: feat: Import all the things!
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/Application.cpp | 35 ++++++----
launcher/Application.h | 2 +-
launcher/CMakeLists.txt | 6 +-
.../minecraft/mod/tasks/LocalDataPackParseTask.cpp | 4 +-
.../minecraft/mod/tasks/LocalResourceParse.cpp | 21 ++++++
launcher/minecraft/mod/tasks/LocalResourceParse.h | 6 ++
launcher/ui/MainWindow.cpp | 56 ++++++++++-----
launcher/ui/MainWindow.h | 2 +-
launcher/ui/dialogs/ImportResourceDialog.cpp | 70 +++++++++++++++++++
launcher/ui/dialogs/ImportResourceDialog.h | 30 ++++++++
launcher/ui/dialogs/ImportResourceDialog.ui | 81 ++++++++++++++++++++++
launcher/ui/dialogs/ImportResourcePackDialog.cpp | 65 -----------------
launcher/ui/dialogs/ImportResourcePackDialog.h | 27 --------
launcher/ui/dialogs/ImportResourcePackDialog.ui | 74 --------------------
14 files changed, 277 insertions(+), 202 deletions(-)
create mode 100644 launcher/ui/dialogs/ImportResourceDialog.cpp
create mode 100644 launcher/ui/dialogs/ImportResourceDialog.h
create mode 100644 launcher/ui/dialogs/ImportResourceDialog.ui
delete mode 100644 launcher/ui/dialogs/ImportResourcePackDialog.cpp
delete mode 100644 launcher/ui/dialogs/ImportResourcePackDialog.h
delete mode 100644 launcher/ui/dialogs/ImportResourcePackDialog.ui
(limited to 'launcher/minecraft/mod/tasks/LocalResourceParse.h')
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index ff34a168..581e51ae 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -259,9 +259,18 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
m_serverToJoin = parser.value("server");
m_profileToUse = parser.value("profile");
m_liveCheck = parser.isSet("alive");
- m_zipToImport = parser.value("import");
+
m_instanceIdToShowWindowOf = parser.value("show");
+ for (auto zip_path : parser.values("import")){
+ m_zipsToImport.append(QUrl(zip_path));
+ }
+
+ for (auto zip_path : parser.positionalArguments()){ // treat unspesified positional arguments as import urls
+ m_zipsToImport.append(QUrl(zip_path));
+ }
+
+
// error if --launch is missing with --server or --profile
if((!m_serverToJoin.isEmpty() || !m_profileToUse.isEmpty()) && m_instanceIdToLaunch.isEmpty())
{
@@ -345,7 +354,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
}
/*
- * Establish the mechanism for communication with an already running PolyMC that uses the same data path.
+ * Establish the mechanism for communication with an already running PrismLauncher that uses the same data path.
* If there is one, tell it what the user actually wanted to do and exit.
* We want to initialize this before logging to avoid messing with the log of a potential already running copy.
*/
@@ -363,12 +372,14 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
activate.command = "activate";
m_peerInstance->sendMessage(activate.serialize(), timeout);
- if(!m_zipToImport.isEmpty())
+ if(!m_zipsToImport.isEmpty())
{
- ApplicationMessage import;
- import.command = "import";
- import.args.insert("path", m_zipToImport.toString());
- m_peerInstance->sendMessage(import.serialize(), timeout);
+ for (auto zip_url : m_zipsToImport) {
+ ApplicationMessage import;
+ import.command = "import";
+ import.args.insert("path", zip_url.toString());
+ m_peerInstance->sendMessage(import.serialize(), timeout);
+ }
}
}
else
@@ -938,7 +949,7 @@ bool Application::event(QEvent* event)
if (event->type() == QEvent::FileOpen) {
auto ev = static_cast(event);
- m_mainWindow->droppedURLs({ ev->url() });
+ m_mainWindow->processURLs({ ev->url() });
}
return QApplication::event(event);
@@ -998,10 +1009,10 @@ void Application::performMainStartupAction()
showMainWindow(false);
qDebug() << "<> Main window shown.";
}
- if(!m_zipToImport.isEmpty())
+ if(!m_zipsToImport.isEmpty())
{
- qDebug() << "<> Importing instance from zip:" << m_zipToImport;
- m_mainWindow->droppedURLs({ m_zipToImport });
+ qDebug() << "<> Importing from zip:" << m_zipsToImport;
+ m_mainWindow->processURLs( m_zipsToImport );
}
}
@@ -1054,7 +1065,7 @@ void Application::messageReceived(const QByteArray& message)
qWarning() << "Received" << command << "message without a zip path/URL.";
return;
}
- m_mainWindow->droppedURLs({ QUrl(path) });
+ m_mainWindow->processURLs({ QUrl(path) });
}
else if(command == "launch")
{
diff --git a/launcher/Application.h b/launcher/Application.h
index 7884227a..cd90088e 100644
--- a/launcher/Application.h
+++ b/launcher/Application.h
@@ -303,7 +303,7 @@ public:
QString m_serverToJoin;
QString m_profileToUse;
bool m_liveCheck = false;
- QUrl m_zipToImport;
+ QList m_zipsToImport;
QString m_instanceIdToShowWindowOf;
std::unique_ptr logFile;
};
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 8b5c63ff..a3520e72 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -841,8 +841,8 @@ SET(LAUNCHER_SOURCES
ui/dialogs/ExportInstanceDialog.h
ui/dialogs/IconPickerDialog.cpp
ui/dialogs/IconPickerDialog.h
- ui/dialogs/ImportResourcePackDialog.cpp
- ui/dialogs/ImportResourcePackDialog.h
+ ui/dialogs/ImportResourceDialog.cpp
+ ui/dialogs/ImportResourceDialog.h
ui/dialogs/LoginDialog.cpp
ui/dialogs/LoginDialog.h
ui/dialogs/MSALoginDialog.cpp
@@ -992,7 +992,7 @@ qt_wrap_ui(LAUNCHER_UI
ui/dialogs/SkinUploadDialog.ui
ui/dialogs/ExportInstanceDialog.ui
ui/dialogs/IconPickerDialog.ui
- ui/dialogs/ImportResourcePackDialog.ui
+ ui/dialogs/ImportResourceDialog.ui
ui/dialogs/MSALoginDialog.ui
ui/dialogs/OfflineLoginDialog.ui
ui/dialogs/AboutDialog.ui
diff --git a/launcher/minecraft/mod/tasks/LocalDataPackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalDataPackParseTask.cpp
index 3fcb2110..5bb44877 100644
--- a/launcher/minecraft/mod/tasks/LocalDataPackParseTask.cpp
+++ b/launcher/minecraft/mod/tasks/LocalDataPackParseTask.cpp
@@ -50,7 +50,7 @@ bool processFolder(DataPack& pack, ProcessingLevel level)
Q_ASSERT(pack.type() == ResourceType::FOLDER);
auto mcmeta_invalid = [&pack]() {
- qWarning() << "Resource pack at" << pack.fileinfo().filePath() << "does not have a valid pack.mcmeta";
+ qWarning() << "Data pack at" << pack.fileinfo().filePath() << "does not have a valid pack.mcmeta";
return false; // the mcmeta is not optional
};
@@ -95,7 +95,7 @@ bool processZIP(DataPack& pack, ProcessingLevel level)
QuaZipFile file(&zip);
auto mcmeta_invalid = [&pack]() {
- qWarning() << "Resource pack at" << pack.fileinfo().filePath() << "does not have a valid pack.mcmeta";
+ qWarning() << "Data pack at" << pack.fileinfo().filePath() << "does not have a valid pack.mcmeta";
return false; // the mcmeta is not optional
};
diff --git a/launcher/minecraft/mod/tasks/LocalResourceParse.cpp b/launcher/minecraft/mod/tasks/LocalResourceParse.cpp
index 19ddc899..63833832 100644
--- a/launcher/minecraft/mod/tasks/LocalResourceParse.cpp
+++ b/launcher/minecraft/mod/tasks/LocalResourceParse.cpp
@@ -19,6 +19,8 @@
* along with this program. If not, see .
*/
+#include
+
#include "LocalResourceParse.h"
#include "LocalDataPackParseTask.h"
@@ -28,6 +30,17 @@
#include "LocalTexturePackParseTask.h"
#include "LocalWorldSaveParseTask.h"
+
+static const QMap s_packed_type_names = {
+ {PackedResourceType::ResourcePack, QObject::tr("resource pack")},
+ {PackedResourceType::TexturePack, QObject::tr("texture pack")},
+ {PackedResourceType::DataPack, QObject::tr("data pack")},
+ {PackedResourceType::ShaderPack, QObject::tr("shader pack")},
+ {PackedResourceType::WorldSave, QObject::tr("world save")},
+ {PackedResourceType::Mod , QObject::tr("mod")},
+ {PackedResourceType::UNKNOWN, QObject::tr("unknown")}
+};
+
namespace ResourceUtils {
PackedResourceType identify(QFileInfo file){
if (file.exists() && file.isFile()) {
@@ -57,4 +70,12 @@ PackedResourceType identify(QFileInfo file){
}
return PackedResourceType::UNKNOWN;
}
+
+QString getPackedTypeName(PackedResourceType type) {
+ return s_packed_type_names.constFind(type).value();
}
+
+}
+
+
+
diff --git a/launcher/minecraft/mod/tasks/LocalResourceParse.h b/launcher/minecraft/mod/tasks/LocalResourceParse.h
index b07a874c..7385d24b 100644
--- a/launcher/minecraft/mod/tasks/LocalResourceParse.h
+++ b/launcher/minecraft/mod/tasks/LocalResourceParse.h
@@ -21,11 +21,17 @@
#pragma once
+#include
+
#include
#include
#include
enum class PackedResourceType { DataPack, ResourcePack, TexturePack, ShaderPack, WorldSave, Mod, UNKNOWN };
namespace ResourceUtils {
+static const std::set ValidResourceTypes = { PackedResourceType::DataPack, PackedResourceType::ResourcePack,
+ PackedResourceType::TexturePack, PackedResourceType::ShaderPack,
+ PackedResourceType::WorldSave, PackedResourceType::Mod };
PackedResourceType identify(QFileInfo file);
+QString getPackedTypeName(PackedResourceType type);
} // namespace ResourceUtils
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index e913849d..1d2e44e5 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -109,13 +109,12 @@
#include "ui/dialogs/UpdateDialog.h"
#include "ui/dialogs/EditAccountDialog.h"
#include "ui/dialogs/ExportInstanceDialog.h"
-#include "ui/dialogs/ImportResourcePackDialog.h"
+#include "ui/dialogs/ImportResourceDialog.h"
#include "ui/themes/ITheme.h"
-#include
-#include
-#include
-#include
+#include "minecraft/mod/tasks/LocalResourceParse.h"
+#include "minecraft/mod/ModFolderModel.h"
+#include "minecraft/WorldList.h"
#include "UpdateController.h"
#include "KonamiCode.h"
@@ -954,7 +953,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
view->installEventFilter(this);
view->setContextMenuPolicy(Qt::CustomContextMenu);
connect(view, &QWidget::customContextMenuRequested, this, &MainWindow::showInstanceContextMenu);
- connect(view, &InstanceView::droppedURLs, this, &MainWindow::droppedURLs, Qt::QueuedConnection);
+ connect(view, &InstanceView::droppedURLs, this, &MainWindow::processURLs, Qt::QueuedConnection);
proxymodel = new InstanceProxyModel(this);
proxymodel->setSourceModel(APPLICATION->instances().get());
@@ -1813,10 +1812,12 @@ void MainWindow::on_actionAddInstance_triggered()
addInstance();
}
-void MainWindow::droppedURLs(QList urls)
+void MainWindow::processURLs(QList urls)
{
// NOTE: This loop only processes one dropped file!
for (auto& url : urls) {
+ qDebug() << "Processing :" << url;
+
// The isLocalFile() check below doesn't work as intended without an explicit scheme.
if (url.scheme().isEmpty())
url.setScheme("file");
@@ -1829,28 +1830,49 @@ void MainWindow::droppedURLs(QList urls)
auto localFileName = url.toLocalFile();
QFileInfo localFileInfo(localFileName);
- bool isResourcePack = ResourcePackUtils::validate(localFileInfo);
- bool isTexturePack = TexturePackUtils::validate(localFileInfo);
+ auto type = ResourceUtils::identify(localFileInfo);
+
+ // bool is_resource = type;
- if (!isResourcePack && !isTexturePack) { // probably instance/modpack
+ if (!(ResourceUtils::ValidResourceTypes.count(type) > 0)) { // probably instance/modpack
addInstance(localFileName);
- break;
+ continue;
}
- ImportResourcePackDialog dlg(this);
+ ImportResourceDialog dlg(localFileName, type, this);
if (dlg.exec() != QDialog::Accepted)
- break;
+ continue;
- qDebug() << "Adding resource/texture pack" << localFileName << "to" << dlg.selectedInstanceKey;
+ qDebug() << "Adding resource" << localFileName << "to" << dlg.selectedInstanceKey;
auto inst = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey);
auto minecraftInst = std::dynamic_pointer_cast(inst);
- if (isResourcePack)
+
+ switch (type) {
+ case PackedResourceType::ResourcePack:
minecraftInst->resourcePackList()->installResource(localFileName);
- else if (isTexturePack)
+ break;
+ case PackedResourceType::TexturePack:
minecraftInst->texturePackList()->installResource(localFileName);
- break;
+ break;
+ case PackedResourceType::DataPack:
+ qWarning() << "Importing of Data Packs not supported at this time. Ignoring" << localFileName;
+ break;
+ case PackedResourceType::Mod:
+ minecraftInst->loaderModList()->installMod(localFileName);
+ break;
+ case PackedResourceType::ShaderPack:
+ minecraftInst->shaderPackList()->installResource(localFileName);
+ break;
+ case PackedResourceType::WorldSave:
+ minecraftInst->worldList()->installWorld(localFileName);
+ break;
+ case PackedResourceType::UNKNOWN:
+ default:
+ qDebug() << "Can't Identify" << localFileName << "Ignoring it.";
+ break;
+ }
}
}
diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h
index f96f641d..6bf5f428 100644
--- a/launcher/ui/MainWindow.h
+++ b/launcher/ui/MainWindow.h
@@ -80,7 +80,7 @@ public:
void updatesAllowedChanged(bool allowed);
- void droppedURLs(QList urls);
+ void processURLs(QList urls);
signals:
void isClosing();
diff --git a/launcher/ui/dialogs/ImportResourceDialog.cpp b/launcher/ui/dialogs/ImportResourceDialog.cpp
new file mode 100644
index 00000000..84b69273
--- /dev/null
+++ b/launcher/ui/dialogs/ImportResourceDialog.cpp
@@ -0,0 +1,70 @@
+#include "ImportResourceDialog.h"
+#include "ui_ImportResourceDialog.h"
+
+#include
+#include
+
+#include "Application.h"
+#include "InstanceList.h"
+
+#include
+#include "ui/instanceview/InstanceDelegate.h"
+#include "ui/instanceview/InstanceProxyModel.h"
+
+ImportResourceDialog::ImportResourceDialog(QString file_path, PackedResourceType type, QWidget* parent)
+ : QDialog(parent), ui(new Ui::ImportResourceDialog), m_resource_type(type), m_file_path(file_path)
+{
+ ui->setupUi(this);
+ setWindowModality(Qt::WindowModal);
+
+ auto contentsWidget = ui->instanceView;
+ contentsWidget->setViewMode(QListView::ListMode);
+ contentsWidget->setFlow(QListView::LeftToRight);
+ contentsWidget->setIconSize(QSize(48, 48));
+ contentsWidget->setMovement(QListView::Static);
+ contentsWidget->setResizeMode(QListView::Adjust);
+ contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+ contentsWidget->setSpacing(5);
+ contentsWidget->setWordWrap(true);
+ contentsWidget->setWrapping(true);
+ // NOTE: We can't have uniform sizes because the text may wrap if it's too long. If we set this, it will cut off the wrapped text.
+ contentsWidget->setUniformItemSizes(false);
+ contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
+ contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ contentsWidget->setItemDelegate(new ListViewDelegate());
+
+ proxyModel = new InstanceProxyModel(this);
+ proxyModel->setSourceModel(APPLICATION->instances().get());
+ proxyModel->sort(0);
+ contentsWidget->setModel(proxyModel);
+
+ connect(contentsWidget, SIGNAL(doubleClicked(QModelIndex)), SLOT(activated(QModelIndex)));
+ connect(contentsWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
+ SLOT(selectionChanged(QItemSelection, QItemSelection)));
+
+ ui->label->setText(
+ tr("Choose the instance you would like to import this %1 to.").arg(ResourceUtils::getPackedTypeName(m_resource_type)));
+ ui->label_file_path->setText(tr("File: %1").arg(m_file_path));
+}
+
+void ImportResourceDialog::activated(QModelIndex index)
+{
+ selectedInstanceKey = index.data(InstanceList::InstanceIDRole).toString();
+ accept();
+}
+
+void ImportResourceDialog::selectionChanged(QItemSelection selected, QItemSelection deselected)
+{
+ if (selected.empty())
+ return;
+
+ QString key = selected.first().indexes().first().data(InstanceList::InstanceIDRole).toString();
+ if (!key.isEmpty()) {
+ selectedInstanceKey = key;
+ }
+}
+
+ImportResourceDialog::~ImportResourceDialog()
+{
+ delete ui;
+}
diff --git a/launcher/ui/dialogs/ImportResourceDialog.h b/launcher/ui/dialogs/ImportResourceDialog.h
new file mode 100644
index 00000000..c9e3f956
--- /dev/null
+++ b/launcher/ui/dialogs/ImportResourceDialog.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include
+#include
+
+#include "ui/instanceview/InstanceProxyModel.h"
+#include "minecraft/mod/tasks/LocalResourceParse.h"
+
+namespace Ui {
+class ImportResourceDialog;
+}
+
+class ImportResourceDialog : public QDialog {
+ Q_OBJECT
+
+ public:
+ explicit ImportResourceDialog(QString file_path, PackedResourceType type, QWidget* parent = 0);
+ ~ImportResourceDialog();
+ InstanceProxyModel* proxyModel;
+ QString selectedInstanceKey;
+
+ private:
+ Ui::ImportResourceDialog* ui;
+ PackedResourceType m_resource_type;
+ QString m_file_path;
+
+ private slots:
+ void selectionChanged(QItemSelection, QItemSelection);
+ void activated(QModelIndex);
+};
diff --git a/launcher/ui/dialogs/ImportResourceDialog.ui b/launcher/ui/dialogs/ImportResourceDialog.ui
new file mode 100644
index 00000000..cc3f4ec1
--- /dev/null
+++ b/launcher/ui/dialogs/ImportResourceDialog.ui
@@ -0,0 +1,81 @@
+
+
+ ImportResourceDialog
+
+
+
+ 0
+ 0
+ 676
+ 555
+
+
+
+ Choose instance to import to
+
+
+ -
+
+
+ Choose the instance you would like to import this resource pack to.
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ ImportResourceDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ ImportResourceDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.cpp b/launcher/ui/dialogs/ImportResourcePackDialog.cpp
deleted file mode 100644
index e8902656..00000000
--- a/launcher/ui/dialogs/ImportResourcePackDialog.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-#include "ImportResourcePackDialog.h"
-#include "ui_ImportResourcePackDialog.h"
-
-#include
-#include
-
-#include "Application.h"
-#include "InstanceList.h"
-
-#include
-#include "ui/instanceview/InstanceProxyModel.h"
-#include "ui/instanceview/InstanceDelegate.h"
-
-ImportResourcePackDialog::ImportResourcePackDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ImportResourcePackDialog)
-{
- ui->setupUi(this);
- setWindowModality(Qt::WindowModal);
-
- auto contentsWidget = ui->instanceView;
- contentsWidget->setViewMode(QListView::ListMode);
- contentsWidget->setFlow(QListView::LeftToRight);
- contentsWidget->setIconSize(QSize(48, 48));
- contentsWidget->setMovement(QListView::Static);
- contentsWidget->setResizeMode(QListView::Adjust);
- contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection);
- contentsWidget->setSpacing(5);
- contentsWidget->setWordWrap(true);
- contentsWidget->setWrapping(true);
- // NOTE: We can't have uniform sizes because the text may wrap if it's too long. If we set this, it will cut off the wrapped text.
- contentsWidget->setUniformItemSizes(false);
- contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
- contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- contentsWidget->setItemDelegate(new ListViewDelegate());
-
- proxyModel = new InstanceProxyModel(this);
- proxyModel->setSourceModel(APPLICATION->instances().get());
- proxyModel->sort(0);
- contentsWidget->setModel(proxyModel);
-
- connect(contentsWidget, SIGNAL(doubleClicked(QModelIndex)), SLOT(activated(QModelIndex)));
- connect(contentsWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
- SLOT(selectionChanged(QItemSelection, QItemSelection)));
-}
-
-void ImportResourcePackDialog::activated(QModelIndex index)
-{
- selectedInstanceKey = index.data(InstanceList::InstanceIDRole).toString();
- accept();
-}
-
-void ImportResourcePackDialog::selectionChanged(QItemSelection selected, QItemSelection deselected)
-{
- if (selected.empty())
- return;
-
- QString key = selected.first().indexes().first().data(InstanceList::InstanceIDRole).toString();
- if (!key.isEmpty()) {
- selectedInstanceKey = key;
- }
-}
-
-ImportResourcePackDialog::~ImportResourcePackDialog()
-{
- delete ui;
-}
diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.h b/launcher/ui/dialogs/ImportResourcePackDialog.h
deleted file mode 100644
index 8356f204..00000000
--- a/launcher/ui/dialogs/ImportResourcePackDialog.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include
-#include
-
-#include "ui/instanceview/InstanceProxyModel.h"
-
-namespace Ui {
-class ImportResourcePackDialog;
-}
-
-class ImportResourcePackDialog : public QDialog {
- Q_OBJECT
-
- public:
- explicit ImportResourcePackDialog(QWidget* parent = 0);
- ~ImportResourcePackDialog();
- InstanceProxyModel* proxyModel;
- QString selectedInstanceKey;
-
- private:
- Ui::ImportResourcePackDialog* ui;
-
- private slots:
- void selectionChanged(QItemSelection, QItemSelection);
- void activated(QModelIndex);
-};
diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.ui b/launcher/ui/dialogs/ImportResourcePackDialog.ui
deleted file mode 100644
index 20cb9177..00000000
--- a/launcher/ui/dialogs/ImportResourcePackDialog.ui
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
- ImportResourcePackDialog
-
-
-
- 0
- 0
- 676
- 555
-
-
-
- Choose instance to import
-
-
- -
-
-
- Choose the instance you would like to import this resource pack to.
-
-
-
- -
-
-
- -
-
-
- Qt::Horizontal
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
-
-
-
-
-
-
- buttonBox
- accepted()
- ImportResourcePackDialog
- accept()
-
-
- 248
- 254
-
-
- 157
- 274
-
-
-
-
- buttonBox
- rejected()
- ImportResourcePackDialog
- reject()
-
-
- 316
- 260
-
-
- 286
- 274
-
-
-
-
-
--
cgit