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_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
if(UNIX AND APPLE)
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;
}
#if ENABLE_JAVA_DOWNLOADER
JAVA_DOWNLOADER_ENABLED = true;
#endif
GIT_COMMIT = "@Launcher_GIT_COMMIT@";
GIT_TAG = "@Launcher_GIT_TAG@";
GIT_REFSPEC = "@Launcher_GIT_REFSPEC@";

View File

@ -67,6 +67,7 @@ class Config {
QString VERSION_CHANNEL;
bool UPDATER_ENABLED = false;
bool JAVA_DOWNLOADER_ENABLED = false;
/// A short string identifying this build's platform or distribution.
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})
endif()
if(ENABLE_JAVA_DOWNLOADER)
target_compile_definitions(Launcher_logic PUBLIC ENABLE_JAVA_DOWNLOADER)
endif()
install(TARGETS ${Launcher_Name}
BUNDLE DESTINATION "." COMPONENT Runtime
LIBRARY DESTINATION ${LIBRARY_DEST_DIR} COMPONENT Runtime

View File

@ -35,6 +35,7 @@
*/
#include "JavaPage.h"
#include "BuildConfig.h"
#include "JavaCommon.h"
#include "java/JavaInstall.h"
#include "ui/dialogs/CustomMessageBox.h"
@ -62,15 +63,21 @@ JavaPage::JavaPage(QWidget* parent) : QWidget(parent), ui(new Ui::JavaPage)
{
ui->setupUi(this);
ui->managedJavaList->initialize(new JavaInstallList(this, true));
ui->managedJavaList->selectCurrent();
ui->managedJavaList->setEmptyString(tr("No java versions are currently available in the meta"));
ui->managedJavaList->setEmptyErrorString(tr("Couldn't load or download the java version lists!"));
connect(ui->autodetectJavaCheckBox, &QCheckBox::stateChanged, this, [this] {
ui->autodownloadCheckBox->setEnabled(ui->autodetectJavaCheckBox->isChecked());
if (!ui->autodetectJavaCheckBox->isChecked())
ui->autodownloadCheckBox->setChecked(false);
});
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
ui->managedJavaList->initialize(new JavaInstallList(this, true));
ui->managedJavaList->selectCurrent();
ui->managedJavaList->setEmptyString(tr("No java versions are currently available in the meta"));
ui->managedJavaList->setEmptyErrorString(tr("Couldn't load or download the java version lists!"));
connect(ui->autodetectJavaCheckBox, &QCheckBox::stateChanged, this, [this] {
ui->autodownloadCheckBox->setEnabled(ui->autodetectJavaCheckBox->isChecked());
if (!ui->autodetectJavaCheckBox->isChecked())
ui->autodownloadCheckBox->setChecked(false);
});
} else {
ui->autodownloadCheckBox->setHidden(true);
ui->javaDownloadBtn->setHidden(true);
ui->tabWidget->tabBar()->hide();
}
loadSettings();
updateThresholds();

View File

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

View File

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