summaryrefslogtreecommitdiffstats
path: root/gui/dialogs/InstanceSettings.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-11-25 01:14:30 +0100
committerPetr Mrázek <peterix@gmail.com>2013-11-25 01:14:30 +0100
commitd6b09f7c139c73379976a9d179dd05b66afe13a6 (patch)
treeab980425296d8f65bb52bdbad6f8af96b7d12f0c /gui/dialogs/InstanceSettings.cpp
parent088b039cf7de6b217a289499a8efe5a47e861829 (diff)
downloadMultiMC-d6b09f7c139c73379976a9d179dd05b66afe13a6.tar
MultiMC-d6b09f7c139c73379976a9d179dd05b66afe13a6.tar.gz
MultiMC-d6b09f7c139c73379976a9d179dd05b66afe13a6.tar.lz
MultiMC-d6b09f7c139c73379976a9d179dd05b66afe13a6.tar.xz
MultiMC-d6b09f7c139c73379976a9d179dd05b66afe13a6.zip
Add java checker to the instance settings
Diffstat (limited to 'gui/dialogs/InstanceSettings.cpp')
-rw-r--r--gui/dialogs/InstanceSettings.cpp62
1 files changed, 62 insertions, 0 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