mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-13 05:37:42 +02:00
Added extra java search paths
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -629,6 +629,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||
m_settings->registerSetting("JvmArgs", "");
|
||||
m_settings->registerSetting("IgnoreJavaCompatibility", false);
|
||||
m_settings->registerSetting("IgnoreJavaWizard", false);
|
||||
m_settings->registerSetting("JavaExtraSearchPaths", QStringList());
|
||||
|
||||
// Legacy settings
|
||||
m_settings->registerSetting("OnlineFixes", false);
|
||||
|
@ -492,21 +492,34 @@ QStringList getMinecraftJavaBundle()
|
||||
QStringList getPrismJavaBundle()
|
||||
{
|
||||
QList<QString> javas;
|
||||
QDir dir(APPLICATION->javaPath());
|
||||
if (!dir.exists())
|
||||
return javas;
|
||||
|
||||
QString executable = "java";
|
||||
#if defined(Q_OS_WIN32)
|
||||
executable += "w.exe";
|
||||
#endif
|
||||
|
||||
auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (auto& entry : entries) {
|
||||
QString prefix;
|
||||
prefix = entry.canonicalFilePath();
|
||||
auto scanDir = [&](QString prefix) {
|
||||
javas.append(FS::PathCombine(prefix, "jre", "bin", executable));
|
||||
javas.append(FS::PathCombine(prefix, "bin", executable));
|
||||
javas.append(FS::PathCombine(prefix, executable));
|
||||
};
|
||||
auto scanJavaDir = [&](const QString& dirPath) {
|
||||
QDir dir(dirPath);
|
||||
if (!dir.exists())
|
||||
return;
|
||||
auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (auto& entry : entries) {
|
||||
scanDir(entry.canonicalFilePath());
|
||||
}
|
||||
};
|
||||
|
||||
scanJavaDir(APPLICATION->javaPath());
|
||||
|
||||
auto extra_paths = APPLICATION->settings()->get("JavaExtraSearchPaths").toStringList();
|
||||
for (auto& entry : extra_paths) {
|
||||
scanDir(entry);
|
||||
scanJavaDir(entry);
|
||||
}
|
||||
|
||||
return javas;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QStringListModel>
|
||||
#include <QTabBar>
|
||||
|
||||
#include "ui/dialogs/VersionSelectDialog.h"
|
||||
@ -57,7 +58,6 @@
|
||||
JavaPage::JavaPage(QWidget* parent) : QWidget(parent), ui(new Ui::JavaPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tabWidget->tabBar()->hide();
|
||||
|
||||
loadSettings();
|
||||
updateThresholds();
|
||||
@ -95,6 +95,7 @@ void JavaPage::applySettings()
|
||||
s->set("JvmArgs", ui->jvmArgsTextBox->toPlainText().replace("\n", " "));
|
||||
s->set("IgnoreJavaCompatibility", ui->skipCompatibilityCheckbox->isChecked());
|
||||
s->set("IgnoreJavaWizard", ui->skipJavaWizardCheckbox->isChecked());
|
||||
s->set("JavaExtraSearchPaths", m_extra_paths->stringList());
|
||||
JavaCommon::checkJVMArgs(s->get("JvmArgs").toString(), this->parentWidget());
|
||||
}
|
||||
void JavaPage::loadSettings()
|
||||
@ -117,6 +118,8 @@ void JavaPage::loadSettings()
|
||||
ui->jvmArgsTextBox->setPlainText(s->get("JvmArgs").toString());
|
||||
ui->skipCompatibilityCheckbox->setChecked(s->get("IgnoreJavaCompatibility").toBool());
|
||||
ui->skipJavaWizardCheckbox->setChecked(s->get("IgnoreJavaWizard").toBool());
|
||||
m_extra_paths = new QStringListModel(s->get("JavaExtraSearchPaths").toStringList());
|
||||
ui->extraJavaPathsList->setModel(m_extra_paths);
|
||||
}
|
||||
|
||||
void JavaPage::on_javaDetectBtn_clicked()
|
||||
@ -217,3 +220,27 @@ void JavaPage::updateThresholds()
|
||||
ui->labelMaxMemIcon->setPixmap(pix);
|
||||
}
|
||||
}
|
||||
|
||||
void JavaPage::on_addExtraPathButton_clicked()
|
||||
{
|
||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Add Extra Java Folder"));
|
||||
|
||||
if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) {
|
||||
QString cooked_dir = FS::NormalizePath(raw_dir);
|
||||
auto currentList = m_extra_paths->stringList();
|
||||
if (!currentList.contains(cooked_dir)) {
|
||||
currentList << cooked_dir;
|
||||
m_extra_paths->setStringList(currentList);
|
||||
}
|
||||
}
|
||||
APPLICATION->settings()->set("JavaExtraSearchPaths", m_extra_paths->stringList());
|
||||
}
|
||||
|
||||
void JavaPage::on_removeExtraPathButton_clicked()
|
||||
{
|
||||
auto indexes = ui->extraJavaPathsList->selectionModel()->selectedIndexes();
|
||||
if (indexes.size()) {
|
||||
m_extra_paths->removeRow(indexes.first().row());
|
||||
}
|
||||
APPLICATION->settings()->set("JavaExtraSearchPaths", m_extra_paths->stringList());
|
||||
}
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <Application.h>
|
||||
#include <QObjectPtr.h>
|
||||
#include <QDialog>
|
||||
#include <memory>
|
||||
#include <QStringListModel>
|
||||
#include "JavaCommon.h"
|
||||
#include "ui/pages/BasePage.h"
|
||||
|
||||
@ -73,10 +73,13 @@ class JavaPage : public QWidget, public BasePage {
|
||||
void on_javaTestBtn_clicked();
|
||||
void on_javaBrowseBtn_clicked();
|
||||
void on_javaDownloadBtn_clicked();
|
||||
void on_addExtraPathButton_clicked();
|
||||
void on_removeExtraPathButton_clicked();
|
||||
void on_maxMemSpinBox_valueChanged(int i);
|
||||
void checkerFinished();
|
||||
|
||||
private:
|
||||
Ui::JavaPage* ui;
|
||||
unique_qobject_ptr<JavaCommon::TestCheck> checker;
|
||||
QStringListModel* m_extra_paths;
|
||||
};
|
||||
|
@ -32,11 +32,11 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<widget class="QWidget" name="general">
|
||||
<attribute name="title">
|
||||
<string notr="true">Tab 1</string>
|
||||
<string notr="true">General</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
@ -312,6 +312,69 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="management">
|
||||
<attribute name="title">
|
||||
<string>Management</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="extraJavaPathsGroupBox">
|
||||
<property name="title">
|
||||
<string>Java extra paths</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QListView" name="extraJavaPathsList"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="extraJavaPathsButtonsLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="addExtraPathButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeExtraPathButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="extraPathSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="managementSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Reference in New Issue
Block a user