From 312009513d0b3b3a8e08d386bd249ea85aa8bdef Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sat, 14 Sep 2024 18:27:12 +0300 Subject: [PATCH] add open java folder action Signed-off-by: Trial97 --- launcher/Application.cpp | 1 + launcher/LaunchController.cpp | 1 + launcher/ui/MainWindow.cpp | 7 +++++++ launcher/ui/MainWindow.h | 2 +- launcher/ui/MainWindow.ui | 15 ++++++++++++++- launcher/ui/themes/ThemeManager.h | 4 +++- 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 35eb6e91e..3bed11db2 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -1870,6 +1870,7 @@ QUrl Application::normalizeImportUrl(QString const& url) return QUrl::fromUserInput(url); } } + const QString Application::javaPath() { return m_settings->get("JavaDir").toString(); diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index 73800574f..687da1322 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include "BuildConfig.h" diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index a5ccbc19a..f19ac85d2 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -233,6 +233,8 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi if (qgetenv("XDG_CURRENT_DESKTOP") == "gamescope") { ui->mainToolBar->addAction(ui->actionCloseWindow); } + + ui->actionViewJavaFolder->setVisible(BuildConfig.JAVA_DOWNLOADER_ENABLED); } // add the toolbar toggles to the view menu @@ -1223,6 +1225,11 @@ void MainWindow::on_actionViewLogsFolder_triggered() DesktopServices::openPath("logs", true); } +void MainWindow::on_actionViewJavaFolder_triggered() +{ + DesktopServices::openPath(APPLICATION->javaPath(), true); +} + void MainWindow::refreshInstances() { APPLICATION->instances()->loadList(); diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index 41bef9980..0e692eda7 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -48,7 +48,6 @@ #include "BaseInstance.h" #include "minecraft/auth/MinecraftAccount.h" -#include "net/NetJob.h" class LaunchController; class NewsChecker; @@ -119,6 +118,7 @@ class MainWindow : public QMainWindow { void on_actionViewCatPackFolder_triggered(); void on_actionViewIconsFolder_triggered(); void on_actionViewLogsFolder_triggered(); + void on_actionViewJavaFolder_triggered(); void on_actionViewSkinsFolder_triggered(); diff --git a/launcher/ui/MainWindow.ui b/launcher/ui/MainWindow.ui index bad8762ad..819a1efe7 100644 --- a/launcher/ui/MainWindow.ui +++ b/launcher/ui/MainWindow.ui @@ -131,7 +131,7 @@ 0 0 800 - 22 + 27 @@ -192,6 +192,7 @@ + @@ -788,6 +789,18 @@ Open the cat packs folder in a file browser. + + + + .. + + + Java + + + Open the java folder in a file browser. + + diff --git a/launcher/ui/themes/ThemeManager.h b/launcher/ui/themes/ThemeManager.h index c7e32bc8c..a9036107c 100644 --- a/launcher/ui/themes/ThemeManager.h +++ b/launcher/ui/themes/ThemeManager.h @@ -18,10 +18,12 @@ */ #pragma once +#include +#include #include +#include #include "IconTheme.h" -#include "ui/MainWindow.h" #include "ui/themes/CatPack.h" #include "ui/themes/ITheme.h"