Add java checker to the instance settings
This commit is contained in:
parent
088b039cf7
commit
d6b09f7c13
@ -17,10 +17,19 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "MultiMC.h"
|
||||||
#include "InstanceSettings.h"
|
#include "InstanceSettings.h"
|
||||||
#include "ui_InstanceSettings.h"
|
#include "ui_InstanceSettings.h"
|
||||||
#include "gui/Platform.h"
|
#include "gui/Platform.h"
|
||||||
|
#include "gui/dialogs/VersionSelectDialog.h"
|
||||||
|
|
||||||
|
#include "logic/JavaUtils.h"
|
||||||
#include "logic/NagUtils.h"
|
#include "logic/NagUtils.h"
|
||||||
|
#include "logic/lists/JavaVersionList.h"
|
||||||
|
#include "logic/JavaChecker.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
InstanceSettings::InstanceSettings(SettingsObject *obj, QWidget *parent)
|
InstanceSettings::InstanceSettings(SettingsObject *obj, QWidget *parent)
|
||||||
: m_obj(obj), QDialog(parent), ui(new Ui::InstanceSettings)
|
: m_obj(obj), QDialog(parent), ui(new Ui::InstanceSettings)
|
||||||
@ -181,3 +190,56 @@ void InstanceSettings::loadSettings()
|
|||||||
ui->preLaunchCmdTextBox->setText(m_obj->get("PreLaunchCommand").toString());
|
ui->preLaunchCmdTextBox->setText(m_obj->get("PreLaunchCommand").toString());
|
||||||
ui->postExitCmdTextBox->setText(m_obj->get("PostExitCommand").toString());
|
ui->postExitCmdTextBox->setText(m_obj->get("PostExitCommand").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceSettings::on_javaDetectBtn_clicked()
|
||||||
|
{
|
||||||
|
JavaVersionPtr java;
|
||||||
|
|
||||||
|
VersionSelectDialog vselect(MMC->javalist().get(), tr("Select a Java version"), this, true);
|
||||||
|
vselect.setResizeOn(2);
|
||||||
|
vselect.exec();
|
||||||
|
|
||||||
|
if (vselect.result() == QDialog::Accepted && vselect.selectedVersion())
|
||||||
|
{
|
||||||
|
java = std::dynamic_pointer_cast<JavaVersion>(vselect.selectedVersion());
|
||||||
|
ui->javaPathTextBox->setText(java->path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstanceSettings::on_javaBrowseBtn_clicked()
|
||||||
|
{
|
||||||
|
QString dir = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
|
||||||
|
if (!dir.isNull())
|
||||||
|
{
|
||||||
|
ui->javaPathTextBox->setText(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstanceSettings::on_javaTestBtn_clicked()
|
||||||
|
{
|
||||||
|
checker.reset(new JavaChecker());
|
||||||
|
connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
|
||||||
|
SLOT(checkFinished(JavaCheckResult)));
|
||||||
|
checker->performCheck(ui->javaPathTextBox->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstanceSettings::checkFinished(JavaCheckResult result)
|
||||||
|
{
|
||||||
|
if (result.valid)
|
||||||
|
{
|
||||||
|
QString text;
|
||||||
|
text += "Java test succeeded!\n";
|
||||||
|
if (result.is_64bit)
|
||||||
|
text += "Using 64bit java.\n";
|
||||||
|
text += "\n";
|
||||||
|
text += "Platform reported: " + result.realPlatform;
|
||||||
|
QMessageBox::information(this, tr("Java test success"), text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::warning(
|
||||||
|
this, tr("Java test failure"),
|
||||||
|
tr("The specified java binary didn't work. You should use the auto-detect feature, "
|
||||||
|
"or set the path to the java executable."));
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "settingsobject.h"
|
#include "settingsobject.h"
|
||||||
|
#include "logic/JavaChecker.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -44,7 +45,15 @@ slots:
|
|||||||
void on_buttonBox_accepted();
|
void on_buttonBox_accepted();
|
||||||
void on_buttonBox_rejected();
|
void on_buttonBox_rejected();
|
||||||
|
|
||||||
|
void on_javaDetectBtn_clicked();
|
||||||
|
|
||||||
|
void on_javaTestBtn_clicked();
|
||||||
|
|
||||||
|
void on_javaBrowseBtn_clicked();
|
||||||
|
|
||||||
|
void checkFinished(JavaCheckResult result);
|
||||||
private:
|
private:
|
||||||
Ui::InstanceSettings *ui;
|
Ui::InstanceSettings *ui;
|
||||||
SettingsObject *m_obj;
|
SettingsObject *m_obj;
|
||||||
|
std::shared_ptr<JavaChecker> checker;
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>526</width>
|
<width>526</width>
|
||||||
<height>590</height>
|
<height>622</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -278,6 +278,13 @@
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="2" column="4">
|
||||||
|
<widget class="QPushButton" name="javaTestBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Test</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="labelJavaPath">
|
<widget class="QLabel" name="labelJavaPath">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -285,25 +292,32 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="3" column="0">
|
||||||
<widget class="QLineEdit" name="javaPathTextBox"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="labelJVMArgs">
|
<widget class="QLabel" name="labelJVMArgs">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>JVM arguments:</string>
|
<string>JVM arguments:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="3" column="2" colspan="3">
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QLineEdit" name="jvmArgsTextBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2" colspan="3">
|
||||||
|
<widget class="QLineEdit" name="javaPathTextBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="3">
|
||||||
|
<widget class="QPushButton" name="javaBrowseBtn">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Auto-detect</string>
|
<string>Browse...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" colspan="2">
|
<item row="2" column="2">
|
||||||
<widget class="QLineEdit" name="jvmArgsTextBox"/>
|
<widget class="QPushButton" name="javaDetectBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Auto-detect...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@ -403,8 +417,6 @@
|
|||||||
<tabstop>maxMemSpinBox</tabstop>
|
<tabstop>maxMemSpinBox</tabstop>
|
||||||
<tabstop>permGenSpinBox</tabstop>
|
<tabstop>permGenSpinBox</tabstop>
|
||||||
<tabstop>javaSettingsGroupBox</tabstop>
|
<tabstop>javaSettingsGroupBox</tabstop>
|
||||||
<tabstop>javaPathTextBox</tabstop>
|
|
||||||
<tabstop>pushButton</tabstop>
|
|
||||||
<tabstop>jvmArgsTextBox</tabstop>
|
<tabstop>jvmArgsTextBox</tabstop>
|
||||||
<tabstop>customCommandsGroupBox</tabstop>
|
<tabstop>customCommandsGroupBox</tabstop>
|
||||||
<tabstop>preLaunchCmdTextBox</tabstop>
|
<tabstop>preLaunchCmdTextBox</tabstop>
|
||||||
|
@ -276,7 +276,7 @@ void SettingsDialog::checkFinished(JavaCheckResult result)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox::information(
|
QMessageBox::warning(
|
||||||
this, tr("Java test failure"),
|
this, tr("Java test failure"),
|
||||||
tr("The specified java binary didn't work. You should use the auto-detect feature, "
|
tr("The specified java binary didn't work. You should use the auto-detect feature, "
|
||||||
"or set the path to the java executable."));
|
"or set the path to the java executable."));
|
||||||
|
@ -394,7 +394,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="labelJVMArgs">
|
<widget class="QLabel" name="labelJVMArgs">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
@ -410,13 +410,26 @@
|
|||||||
<item row="0" column="1" colspan="5">
|
<item row="0" column="1" colspan="5">
|
||||||
<widget class="QLineEdit" name="javaPathTextBox"/>
|
<widget class="QLineEdit" name="javaPathTextBox"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" colspan="5">
|
<item row="3" column="1" colspan="5">
|
||||||
<widget class="QLineEdit" name="jvmArgsTextBox"/>
|
<widget class="QLineEdit" name="jvmArgsTextBox"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="5">
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="javaDetectBtn">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Auto-detect...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="4" colspan="2">
|
||||||
<widget class="QPushButton" name="javaTestBtn">
|
<widget class="QPushButton" name="javaTestBtn">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -426,10 +439,10 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="4">
|
<item row="1" column="2" colspan="2">
|
||||||
<widget class="QPushButton" name="javaBrowseBtn">
|
<widget class="QPushButton" name="javaBrowseBtn">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -439,19 +452,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="3">
|
|
||||||
<widget class="QPushButton" name="javaDetectBtn">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Auto-detect...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -84,6 +84,5 @@ void JavaChecker::timeout()
|
|||||||
{
|
{
|
||||||
process->kill();
|
process->kill();
|
||||||
process.reset();
|
process.reset();
|
||||||
emit checkFinished({});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user