aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/instance
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/ui/pages/instance')
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.cpp45
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.h1
-rw-r--r--launcher/ui/pages/instance/ScreenshotsPage.cpp47
-rw-r--r--launcher/ui/pages/instance/ScreenshotsPage.h2
-rw-r--r--launcher/ui/pages/instance/ScreenshotsPage.ui18
5 files changed, 113 insertions, 0 deletions
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp
index e63b1434..494d32f0 100644
--- a/launcher/ui/pages/instance/ModFolderPage.cpp
+++ b/launcher/ui/pages/instance/ModFolderPage.cpp
@@ -26,6 +26,7 @@
#include "Application.h"
#include "ui/dialogs/CustomMessageBox.h"
+#include "ui/dialogs/ModDownloadDialog.h"
#include "ui/GuiUtil.h"
#include "DesktopServices.h"
@@ -36,6 +37,7 @@
#include "minecraft/PackProfile.h"
#include "Version.h"
+#include "ui/dialogs/ProgressDialog.h"
namespace {
// FIXME: wasteful
@@ -141,6 +143,11 @@ ModFolderPage::ModFolderPage(
ui(new Ui::ModFolderPage)
{
ui->setupUi(this);
+ if(id == "mods") {
+ auto act = new QAction(tr("Install Mods"), this);
+ ui->actionsToolbar->insertActionBefore(ui->actionView_configs,act);
+ connect(act, &QAction::triggered, this, &ModFolderPage::on_actionInstall_mods_triggered);
+ }
ui->actionsToolbar->insertSpacer(ui->actionView_configs);
m_inst = inst;
@@ -342,6 +349,44 @@ void ModFolderPage::on_actionRemove_triggered()
m_mods->deleteMods(selection.indexes());
}
+void ModFolderPage::on_actionInstall_mods_triggered()
+{
+ if(!m_controlsEnabled) {
+ return;
+ }
+ if(m_inst->typeName() != "Minecraft"){
+ return; //this is a null instance or a legacy instance
+ }
+ bool hasFabric = !((MinecraftInstance *)m_inst)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
+ bool hasForge = !((MinecraftInstance *)m_inst)->getPackProfile()->getComponentVersion("net.minecraftforge").isEmpty();
+ if (!hasFabric && !hasForge) {
+ QMessageBox::critical(this,tr("Error"),tr("Please install a mod loader first!"));
+ return;
+ }
+ ModDownloadDialog mdownload(m_mods, this, m_inst);
+ if(mdownload.exec()) {
+ ModDownloadTask *task = mdownload.getTask();
+ if (task) {
+ connect(task, &Task::failed, [this, task](QString reason) {
+ task->deleteLater();
+ CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
+ });
+ connect(task, &Task::succeeded, [this, task]() {
+ QStringList warnings = task->warnings();
+ if (warnings.count()) {
+ CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'),
+ QMessageBox::Warning)->show();
+ }
+ task->deleteLater();
+ });
+ ProgressDialog loadDialog(this);
+ loadDialog.setSkipButton(true, tr("Abort"));
+ loadDialog.execWithTask(task);
+ m_mods->update();
+ }
+ }
+}
+
void ModFolderPage::on_actionView_configs_triggered()
{
DesktopServices::openDirectory(m_inst->instanceConfigFolder(), true);
diff --git a/launcher/ui/pages/instance/ModFolderPage.h b/launcher/ui/pages/instance/ModFolderPage.h
index 8ef7559b..fbda3cd8 100644
--- a/launcher/ui/pages/instance/ModFolderPage.h
+++ b/launcher/ui/pages/instance/ModFolderPage.h
@@ -102,6 +102,7 @@ slots:
void on_actionRemove_triggered();
void on_actionEnable_triggered();
void on_actionDisable_triggered();
+ void on_actionInstall_mods_triggered();
void on_actionView_Folder_triggered();
void on_actionView_configs_triggered();
void ShowContextMenu(const QPoint &pos);
diff --git a/launcher/ui/pages/instance/ScreenshotsPage.cpp b/launcher/ui/pages/instance/ScreenshotsPage.cpp
index f568ef0d..4011d88c 100644
--- a/launcher/ui/pages/instance/ScreenshotsPage.cpp
+++ b/launcher/ui/pages/instance/ScreenshotsPage.cpp
@@ -250,6 +250,12 @@ bool ScreenshotsPage::eventFilter(QObject *obj, QEvent *evt)
return QWidget::eventFilter(obj, evt);
}
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(evt);
+
+ if (keyEvent->matches(QKeySequence::Copy)) {
+ on_actionCopy_File_s_triggered();
+ return true;
+ }
+
switch (keyEvent->key())
{
case Qt::Key_Delete:
@@ -272,6 +278,11 @@ ScreenshotsPage::~ScreenshotsPage()
void ScreenshotsPage::ShowContextMenu(const QPoint& pos)
{
auto menu = ui->toolBar->createContextMenu(this, tr("Context menu"));
+
+ if (ui->listView->selectionModel()->selectedRows().size() > 1) {
+ menu->removeAction( ui->actionCopy_Image );
+ }
+
menu->exec(ui->listView->mapToGlobal(pos));
delete menu;
}
@@ -377,6 +388,42 @@ void ScreenshotsPage::on_actionUpload_triggered()
m_uploadActive = false;
}
+void ScreenshotsPage::on_actionCopy_Image_triggered()
+{
+ auto selection = ui->listView->selectionModel()->selectedRows();
+ if(selection.size() < 1)
+ {
+ return;
+ }
+
+ // You can only copy one image to the clipboard. In the case of multiple selected files, only the first one gets copied.
+ auto item = selection[0];
+ auto info = m_model->fileInfo(item);
+ QImage image(info.absoluteFilePath());
+ Q_ASSERT(!image.isNull());
+ QApplication::clipboard()->setImage(image, QClipboard::Clipboard);
+}
+
+void ScreenshotsPage::on_actionCopy_File_s_triggered()
+{
+ auto selection = ui->listView->selectionModel()->selectedRows();
+ if(selection.size() < 1)
+ {
+ // Don't do anything so we don't empty the users clipboard
+ return;
+ }
+
+ QString buf = "";
+ for (auto item : selection)
+ {
+ auto info = m_model->fileInfo(item);
+ buf += "file:///" + info.absoluteFilePath() + "\r\n";
+ }
+ QMimeData* mimeData = new QMimeData();
+ mimeData->setData("text/uri-list", buf.toLocal8Bit());
+ QApplication::clipboard()->setMimeData(mimeData);
+}
+
void ScreenshotsPage::on_actionDelete_triggered()
{
auto mbox = CustomMessageBox::selectable(
diff --git a/launcher/ui/pages/instance/ScreenshotsPage.h b/launcher/ui/pages/instance/ScreenshotsPage.h
index d2f44837..2a1fdeee 100644
--- a/launcher/ui/pages/instance/ScreenshotsPage.h
+++ b/launcher/ui/pages/instance/ScreenshotsPage.h
@@ -73,6 +73,8 @@ protected:
private slots:
void on_actionUpload_triggered();
+ void on_actionCopy_Image_triggered();
+ void on_actionCopy_File_s_triggered();
void on_actionDelete_triggered();
void on_actionRename_triggered();
void on_actionView_Folder_triggered();
diff --git a/launcher/ui/pages/instance/ScreenshotsPage.ui b/launcher/ui/pages/instance/ScreenshotsPage.ui
index ec461087..2e2227a2 100644
--- a/launcher/ui/pages/instance/ScreenshotsPage.ui
+++ b/launcher/ui/pages/instance/ScreenshotsPage.ui
@@ -50,6 +50,8 @@
<bool>false</bool>
</attribute>
<addaction name="actionUpload"/>
+ <addaction name="actionCopy_Image"/>
+ <addaction name="actionCopy_File_s"/>
<addaction name="actionDelete"/>
<addaction name="actionRename"/>
<addaction name="actionView_Folder"/>
@@ -74,6 +76,22 @@
<string>View Folder</string>
</property>
</action>
+ <action name="actionCopy_Image">
+ <property name="text">
+ <string>Copy Image</string>
+ </property>
+ <property name="toolTip">
+ <string>Copy Image</string>
+ </property>
+ </action>
+ <action name="actionCopy_File_s">
+ <property name="text">
+ <string>Copy File(s)</string>
+ </property>
+ <property name="toolTip">
+ <string>Copy File(s)</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>