Made java downloader as a build option

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2024-03-06 19:33:14 +02:00
parent 24fd07861b
commit 9120848278
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
7 changed files with 45 additions and 20 deletions

View File

@ -219,6 +219,9 @@ set(Launcher_SUBREDDIT_URL "https://prismlauncher.org/reddit" CACHE STRING "URL
set(Launcher_FORCE_BUNDLED_LIBS OFF CACHE BOOL "Prevent using system libraries, if they are available as submodules") set(Launcher_FORCE_BUNDLED_LIBS OFF CACHE BOOL "Prevent using system libraries, if they are available as submodules")
set(Launcher_QT_VERSION_MAJOR "6" CACHE STRING "Major Qt version to build against") set(Launcher_QT_VERSION_MAJOR "6" CACHE STRING "Major Qt version to build against")
# Java downloader
option(ENABLE_JAVA_DOWNLOADER "Build the java downloader feature" ON)
# Native libraries # Native libraries
if(UNIX AND APPLE) if(UNIX AND APPLE)
set(Launcher_GLFW_LIBRARY_NAME "libglfw.dylib" CACHE STRING "Name of native glfw library") set(Launcher_GLFW_LIBRARY_NAME "libglfw.dylib" CACHE STRING "Name of native glfw library")

View File

@ -81,6 +81,10 @@ Config::Config()
UPDATER_ENABLED = true; UPDATER_ENABLED = true;
} }
#if ENABLE_JAVA_DOWNLOADER
JAVA_DOWNLOADER_ENABLED = true;
#endif
GIT_COMMIT = "@Launcher_GIT_COMMIT@"; GIT_COMMIT = "@Launcher_GIT_COMMIT@";
GIT_TAG = "@Launcher_GIT_TAG@"; GIT_TAG = "@Launcher_GIT_TAG@";
GIT_REFSPEC = "@Launcher_GIT_REFSPEC@"; GIT_REFSPEC = "@Launcher_GIT_REFSPEC@";

View File

@ -67,6 +67,7 @@ class Config {
QString VERSION_CHANNEL; QString VERSION_CHANNEL;
bool UPDATER_ENABLED = false; bool UPDATER_ENABLED = false;
bool JAVA_DOWNLOADER_ENABLED = false;
/// A short string identifying this build's platform or distribution. /// A short string identifying this build's platform or distribution.
QString BUILD_PLATFORM; QString BUILD_PLATFORM;

View File

@ -1320,6 +1320,10 @@ if(DEFINED Launcher_APP_BINARY_DEFS)
target_compile_definitions(Launcher_logic PRIVATE ${Launcher_APP_BINARY_DEFS}) target_compile_definitions(Launcher_logic PRIVATE ${Launcher_APP_BINARY_DEFS})
endif() endif()
if(ENABLE_JAVA_DOWNLOADER)
target_compile_definitions(Launcher_logic PUBLIC ENABLE_JAVA_DOWNLOADER)
endif()
install(TARGETS ${Launcher_Name} install(TARGETS ${Launcher_Name}
BUNDLE DESTINATION "." COMPONENT Runtime BUNDLE DESTINATION "." COMPONENT Runtime
LIBRARY DESTINATION ${LIBRARY_DEST_DIR} COMPONENT Runtime LIBRARY DESTINATION ${LIBRARY_DEST_DIR} COMPONENT Runtime

View File

@ -35,6 +35,7 @@
*/ */
#include "JavaPage.h" #include "JavaPage.h"
#include "BuildConfig.h"
#include "JavaCommon.h" #include "JavaCommon.h"
#include "java/JavaInstall.h" #include "java/JavaInstall.h"
#include "ui/dialogs/CustomMessageBox.h" #include "ui/dialogs/CustomMessageBox.h"
@ -62,6 +63,7 @@ JavaPage::JavaPage(QWidget* parent) : QWidget(parent), ui(new Ui::JavaPage)
{ {
ui->setupUi(this); ui->setupUi(this);
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
ui->managedJavaList->initialize(new JavaInstallList(this, true)); ui->managedJavaList->initialize(new JavaInstallList(this, true));
ui->managedJavaList->selectCurrent(); ui->managedJavaList->selectCurrent();
ui->managedJavaList->setEmptyString(tr("No java versions are currently available in the meta")); ui->managedJavaList->setEmptyString(tr("No java versions are currently available in the meta"));
@ -71,6 +73,11 @@ JavaPage::JavaPage(QWidget* parent) : QWidget(parent), ui(new Ui::JavaPage)
if (!ui->autodetectJavaCheckBox->isChecked()) if (!ui->autodetectJavaCheckBox->isChecked())
ui->autodownloadCheckBox->setChecked(false); ui->autodownloadCheckBox->setChecked(false);
}); });
} else {
ui->autodownloadCheckBox->setHidden(true);
ui->javaDownloadBtn->setHidden(true);
ui->tabWidget->tabBar()->hide();
}
loadSettings(); loadSettings();
updateThresholds(); updateThresholds();

View File

@ -64,6 +64,8 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance* inst, QWidget* parent)
m_settings = inst->settings(); m_settings = inst->settings();
ui->setupUi(this); ui->setupUi(this);
ui->javaDownloadBtn->setHidden(!BuildConfig.JAVA_DOWNLOADER_ENABLED);
connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked); connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked);
connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings); connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings);
connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings); connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings);

View File

@ -129,8 +129,10 @@ void JavaSettingsWidget::setupUi()
m_horizontalBtnLayout = new QHBoxLayout(); m_horizontalBtnLayout = new QHBoxLayout();
m_horizontalBtnLayout->setObjectName(QStringLiteral("horizontalBtnLayout")); m_horizontalBtnLayout->setObjectName(QStringLiteral("horizontalBtnLayout"));
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
m_javaDownloadBtn = new QPushButton(tr("Download Java"), this); m_javaDownloadBtn = new QPushButton(tr("Download Java"), this);
m_horizontalBtnLayout->addWidget(m_javaDownloadBtn); m_horizontalBtnLayout->addWidget(m_javaDownloadBtn);
}
m_verticalLayout->addLayout(m_horizontalBtnLayout); m_verticalLayout->addLayout(m_horizontalBtnLayout);
@ -143,6 +145,7 @@ void JavaSettingsWidget::setupUi()
m_autodetectJavaCheckBox->setObjectName("autodetectJavaCheckBox"); m_autodetectJavaCheckBox->setObjectName("autodetectJavaCheckBox");
m_veriticalJavaLayout->addWidget(m_autodetectJavaCheckBox); m_veriticalJavaLayout->addWidget(m_autodetectJavaCheckBox);
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
m_autodownloadCheckBox = new QCheckBox(m_autoJavaGroupBox); m_autodownloadCheckBox = new QCheckBox(m_autoJavaGroupBox);
m_autodownloadCheckBox->setObjectName("autodownloadCheckBox"); m_autodownloadCheckBox->setObjectName("autodownloadCheckBox");
m_autodownloadCheckBox->setEnabled(false); m_autodownloadCheckBox->setEnabled(false);
@ -152,6 +155,7 @@ void JavaSettingsWidget::setupUi()
if (!m_autodetectJavaCheckBox->isChecked()) if (!m_autodetectJavaCheckBox->isChecked())
m_autodownloadCheckBox->setChecked(false); m_autodownloadCheckBox->setChecked(false);
}); });
}
m_verticalLayout->addWidget(m_autoJavaGroupBox); m_verticalLayout->addWidget(m_autoJavaGroupBox);
retranslate(); retranslate();