diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-10-28 20:55:12 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-10-28 20:55:12 +0100 |
commit | 6ecb833dbf4c4930c8354dcce7967ad44c16c217 (patch) | |
tree | 268120b4b8f7716b6468a655909e1db210dfe3dc /gui/settingsdialog.cpp | |
parent | 923347729557eed76e4f7e9f6f5f1a79216de0a4 (diff) | |
download | MultiMC-6ecb833dbf4c4930c8354dcce7967ad44c16c217.tar MultiMC-6ecb833dbf4c4930c8354dcce7967ad44c16c217.tar.gz MultiMC-6ecb833dbf4c4930c8354dcce7967ad44c16c217.tar.lz MultiMC-6ecb833dbf4c4930c8354dcce7967ad44c16c217.tar.xz MultiMC-6ecb833dbf4c4930c8354dcce7967ad44c16c217.zip |
Fix problem with instance list not using the instance folder path
Diffstat (limited to 'gui/settingsdialog.cpp')
-rw-r--r-- | gui/settingsdialog.cpp | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index 14eba492..b2fbd898 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -3,7 +3,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -22,16 +22,16 @@ #include "logic/lists/JavaVersionList.h" #include <settingsobject.h> +#include <pathutils.h> #include <QFileDialog> #include <QMessageBox> +#include <QDir> -SettingsDialog::SettingsDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::SettingsDialog) +SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SettingsDialog) { - MultiMCPlatform::fixWM_CLASS(this); + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); - + loadSettings(MMC->settings().get()); updateCheckboxStuff(); } @@ -40,7 +40,7 @@ SettingsDialog::~SettingsDialog() { delete ui; } -void SettingsDialog::showEvent ( QShowEvent* ev ) +void SettingsDialog::showEvent(QShowEvent *ev) { QDialog::showEvent(ev); adjustSize(); @@ -49,31 +49,40 @@ void SettingsDialog::showEvent ( QShowEvent* ev ) void SettingsDialog::updateCheckboxStuff() { ui->windowWidthSpinBox->setEnabled(!ui->maximizedCheckBox->isChecked()); - ui->windowHeightSpinBox->setEnabled(! ui->maximizedCheckBox->isChecked()); + ui->windowHeightSpinBox->setEnabled(!ui->maximizedCheckBox->isChecked()); } void SettingsDialog::on_instDirBrowseBtn_clicked() { - QString dir = QFileDialog::getExistingDirectory(this, tr("Instance Directory"), + QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Directory"), ui->instDirTextBox->text()); - if (!dir.isEmpty()) - ui->instDirTextBox->setText(dir); + QString cooked_dir = NormalizePath(raw_dir); + + // do not allow current dir - it's dirty. Do not allow dirs that don't exist + if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) + { + ui->instDirTextBox->setText(cooked_dir); + } } void SettingsDialog::on_modsDirBrowseBtn_clicked() { - QString dir = QFileDialog::getExistingDirectory(this, tr("Mods Directory"), + QString dir = QFileDialog::getExistingDirectory(this, tr("Mods Directory"), ui->modsDirTextBox->text()); if (!dir.isEmpty()) + { ui->modsDirTextBox->setText(dir); + } } void SettingsDialog::on_lwjglDirBrowseBtn_clicked() { - QString dir = QFileDialog::getExistingDirectory(this, tr("LWJGL Directory"), + QString dir = QFileDialog::getExistingDirectory(this, tr("LWJGL Directory"), ui->lwjglDirTextBox->text()); if (!dir.isEmpty()) + { ui->lwjglDirTextBox->setText(dir); + } } void SettingsDialog::on_compatModeCheckBox_clicked(bool checked) @@ -96,7 +105,7 @@ void SettingsDialog::on_buttonBox_accepted() void SettingsDialog::applySettings(SettingsObject *s) { // Special cases - + // Warn about dev builds. if (!ui->devBuildsCheckBox->isChecked()) { @@ -104,46 +113,46 @@ void SettingsDialog::applySettings(SettingsObject *s) } else if (!s->get("UseDevBuilds").toBool()) { - int response = QMessageBox::question(this, tr("Development builds"), - tr("Development builds contain experimental features " - "and may be unstable. Are you sure you want to enable them?")); + int response = QMessageBox::question( + this, tr("Development builds"), + tr("Development builds contain experimental features " + "and may be unstable. Are you sure you want to enable them?")); if (response == QMessageBox::Yes) { s->set("UseDevBuilds", true); } } - - + // Updates s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked()); - + // Folders // TODO: Offer to move instances to new instance folder. s->set("InstanceDir", ui->instDirTextBox->text()); s->set("CentralModsDir", ui->modsDirTextBox->text()); s->set("LWJGLDir", ui->lwjglDirTextBox->text()); - + // Console s->set("ShowConsole", ui->showConsoleCheck->isChecked()); s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); - + // Window Size s->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); s->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); s->set("MinecraftWinHeight", ui->windowHeightSpinBox->value()); - + // Auto Login s->set("AutoLogin", ui->autoLoginCheckBox->isChecked()); - + // Memory s->set("MinMemAlloc", ui->minMemSpinBox->value()); s->set("MaxMemAlloc", ui->maxMemSpinBox->value()); s->set("PermGen", ui->permGenSpinBox->value()); - + // Java Settings s->set("JavaPath", ui->javaPathTextBox->text()); s->set("JvmArgs", ui->jvmArgsTextBox->text()); - + // Custom Commands s->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text()); s->set("PostExitCommand", ui->postExitCmdTextBox->text()); @@ -154,33 +163,33 @@ void SettingsDialog::loadSettings(SettingsObject *s) // Updates ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool()); ui->devBuildsCheckBox->setChecked(s->get("UseDevBuilds").toBool()); - + // Folders ui->instDirTextBox->setText(s->get("InstanceDir").toString()); ui->modsDirTextBox->setText(s->get("CentralModsDir").toString()); ui->lwjglDirTextBox->setText(s->get("LWJGLDir").toString()); - + // Console ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool()); ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool()); - + // Window Size ui->maximizedCheckBox->setChecked(s->get("LaunchMaximized").toBool()); ui->windowWidthSpinBox->setValue(s->get("MinecraftWinWidth").toInt()); ui->windowHeightSpinBox->setValue(s->get("MinecraftWinHeight").toInt()); - + // Auto Login ui->autoLoginCheckBox->setChecked(s->get("AutoLogin").toBool()); - + // Memory ui->minMemSpinBox->setValue(s->get("MinMemAlloc").toInt()); ui->maxMemSpinBox->setValue(s->get("MaxMemAlloc").toInt()); ui->permGenSpinBox->setValue(s->get("PermGen").toInt()); - + // Java Settings ui->javaPathTextBox->setText(s->get("JavaPath").toString()); ui->jvmArgsTextBox->setText(s->get("JvmArgs").toString()); - + // Custom Commands ui->preLaunchCmdTextBox->setText(s->get("PreLaunchCommand").toString()); ui->postExitCmdTextBox->setText(s->get("PostExitCommand").toString()); @@ -204,7 +213,7 @@ void SettingsDialog::on_pushButton_clicked() void SettingsDialog::on_btnBrowse_clicked() { QString dir = QFileDialog::getOpenFileName(this, tr("Find Java executable")); - if(!dir.isNull()) + if (!dir.isNull()) { ui->javaPathTextBox->setText(dir); } |