summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/dialogs/InstanceSettings.cpp62
-rw-r--r--gui/dialogs/InstanceSettings.h9
-rw-r--r--gui/dialogs/InstanceSettings.ui36
-rw-r--r--gui/dialogs/SettingsDialog.cpp2
-rw-r--r--gui/dialogs/SettingsDialog.ui28
5 files changed, 110 insertions, 27 deletions
diff --git a/gui/dialogs/InstanceSettings.cpp b/gui/dialogs/InstanceSettings.cpp
index add135b4..f059047f 100644
--- a/gui/dialogs/InstanceSettings.cpp
+++ b/gui/dialogs/InstanceSettings.cpp
@@ -17,10 +17,19 @@
* limitations under the License.
*/
+#include "MultiMC.h"
#include "InstanceSettings.h"
#include "ui_InstanceSettings.h"
#include "gui/Platform.h"
+#include "gui/dialogs/VersionSelectDialog.h"
+
+#include "logic/JavaUtils.h"
#include "logic/NagUtils.h"
+#include "logic/lists/JavaVersionList.h"
+#include "logic/JavaChecker.h"
+
+#include <QFileDialog>
+#include <QMessageBox>
InstanceSettings::InstanceSettings(SettingsObject *obj, QWidget *parent)
: 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->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."));
+ }
+} \ No newline at end of file
diff --git a/gui/dialogs/InstanceSettings.h b/gui/dialogs/InstanceSettings.h
index 452e7a58..1e7b9f6e 100644
--- a/gui/dialogs/InstanceSettings.h
+++ b/gui/dialogs/InstanceSettings.h
@@ -17,6 +17,7 @@
#include <QDialog>
#include "settingsobject.h"
+#include "logic/JavaChecker.h"
namespace Ui
{
@@ -44,7 +45,15 @@ slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
+ void on_javaDetectBtn_clicked();
+
+ void on_javaTestBtn_clicked();
+
+ void on_javaBrowseBtn_clicked();
+
+ void checkFinished(JavaCheckResult result);
private:
Ui::InstanceSettings *ui;
SettingsObject *m_obj;
+ std::shared_ptr<JavaChecker> checker;
};
diff --git a/gui/dialogs/InstanceSettings.ui b/gui/dialogs/InstanceSettings.ui
index 27004ed8..04c32108 100644
--- a/gui/dialogs/InstanceSettings.ui
+++ b/gui/dialogs/InstanceSettings.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>526</width>
- <height>590</height>
+ <height>622</height>
</rect>
</property>
<property name="windowTitle">
@@ -278,6 +278,13 @@
<bool>false</bool>
</property>
<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">
<widget class="QLabel" name="labelJavaPath">
<property name="text">
@@ -285,25 +292,32 @@
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="javaPathTextBox"/>
- </item>
- <item row="1" column="0">
+ <item row="3" column="0">
<widget class="QLabel" name="labelJVMArgs">
<property name="text">
<string>JVM arguments:</string>
</property>
</widget>
</item>
- <item row="0" column="2">
- <widget class="QPushButton" name="pushButton">
+ <item row="3" column="2" colspan="3">
+ <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">
- <string>Auto-detect</string>
+ <string>Browse...</string>
</property>
</widget>
</item>
- <item row="1" column="1" colspan="2">
- <widget class="QLineEdit" name="jvmArgsTextBox"/>
+ <item row="2" column="2">
+ <widget class="QPushButton" name="javaDetectBtn">
+ <property name="text">
+ <string>Auto-detect...</string>
+ </property>
+ </widget>
</item>
</layout>
</widget>
@@ -403,8 +417,6 @@
<tabstop>maxMemSpinBox</tabstop>
<tabstop>permGenSpinBox</tabstop>
<tabstop>javaSettingsGroupBox</tabstop>
- <tabstop>javaPathTextBox</tabstop>
- <tabstop>pushButton</tabstop>
<tabstop>jvmArgsTextBox</tabstop>
<tabstop>customCommandsGroupBox</tabstop>
<tabstop>preLaunchCmdTextBox</tabstop>
diff --git a/gui/dialogs/SettingsDialog.cpp b/gui/dialogs/SettingsDialog.cpp
index 57e15a5b..5dcf60f8 100644
--- a/gui/dialogs/SettingsDialog.cpp
+++ b/gui/dialogs/SettingsDialog.cpp
@@ -276,7 +276,7 @@ void SettingsDialog::checkFinished(JavaCheckResult result)
}
else
{
- QMessageBox::information(
+ 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."));
diff --git a/gui/dialogs/SettingsDialog.ui b/gui/dialogs/SettingsDialog.ui
index 6a44a631..0dbc8def 100644
--- a/gui/dialogs/SettingsDialog.ui
+++ b/gui/dialogs/SettingsDialog.ui
@@ -394,7 +394,7 @@
</property>
</widget>
</item>
- <item row="2" column="0">
+ <item row="3" column="0">
<widget class="QLabel" name="labelJVMArgs">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
@@ -410,45 +410,45 @@
<item row="0" column="1" colspan="5">
<widget class="QLineEdit" name="javaPathTextBox"/>
</item>
- <item row="2" column="1" colspan="5">
+ <item row="3" column="1" colspan="5">
<widget class="QLineEdit" name="jvmArgsTextBox"/>
</item>
- <item row="1" column="5">
- <widget class="QPushButton" name="javaTestBtn">
+ <item row="1" column="1">
+ <widget class="QPushButton" name="javaDetectBtn">
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
- <string>Test</string>
+ <string>Auto-detect...</string>
</property>
</widget>
</item>
- <item row="1" column="4">
- <widget class="QPushButton" name="javaBrowseBtn">
+ <item row="1" column="4" colspan="2">
+ <widget class="QPushButton" name="javaTestBtn">
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
- <string>Browse...</string>
+ <string>Test</string>
</property>
</widget>
</item>
- <item row="1" column="3">
- <widget class="QPushButton" name="javaDetectBtn">
+ <item row="1" column="2" colspan="2">
+ <widget class="QPushButton" name="javaBrowseBtn">
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
- <string>Auto-detect...</string>
+ <string>Browse...</string>
</property>
</widget>
</item>