From 33b9b25da7d3d29f949c9418295de257d437c9f8 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 14 Jul 2013 18:33:31 +0200 Subject: More work on the downloader and 1.6 instance creation --- gui/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/mainwindow.cpp') diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 5336b12c..8ba988c5 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -416,7 +416,7 @@ void MainWindow::onLoginComplete(LoginResponse response) { Q_ASSERT_X(m_activeInst != NULL, "onLoginComplete", "no active instance is set"); - if (!m_activeInst->shouldUpdateGame()) + if (!m_activeInst->shouldUpdate()) { launchInstance(m_activeInst, response); } -- cgit From ce253ded0e0d2ae90a971c2e074d561f5e7baeb2 Mon Sep 17 00:00:00 2001 From: Stiepen Date: Sun, 14 Jul 2013 20:26:53 +0200 Subject: Added Per-Instance settings --- MultiMC.pro | 9 +- gui/instancesettings.cpp | 89 +++++++++++ gui/instancesettings.h | 32 ++++ gui/instancesettings.ui | 386 +++++++++++++++++++++++++++++++++++++++++++++++ gui/mainwindow.cpp | 16 ++ 5 files changed, 529 insertions(+), 3 deletions(-) create mode 100644 gui/instancesettings.cpp create mode 100644 gui/instancesettings.h create mode 100644 gui/instancesettings.ui (limited to 'gui/mainwindow.cpp') diff --git a/MultiMC.pro b/MultiMC.pro index 3f480529..6af1ec0d 100644 --- a/MultiMC.pro +++ b/MultiMC.pro @@ -21,7 +21,8 @@ SOURCES += main.cpp\ data/inifile.cpp \ gui/settingsdialog.cpp \ gui/modeditwindow.cpp \ - util/appsettings.cpp + util/appsettings.cpp \ + gui/instancesettings.cpp HEADERS += gui/mainwindow.h \ data/instancebase.h \ @@ -32,11 +33,13 @@ HEADERS += gui/mainwindow.h \ gui/settingsdialog.h \ gui/modeditwindow.h \ util/apputils.h \ - util/appsettings.h + util/appsettings.h \ + gui/instancesettings.h FORMS += gui/mainwindow.ui \ gui/settingsdialog.ui \ - gui/modeditwindow.ui + gui/modeditwindow.ui \ + gui/instancesettings.ui RESOURCES += \ multimc.qrc diff --git a/gui/instancesettings.cpp b/gui/instancesettings.cpp new file mode 100644 index 00000000..7e82e1d6 --- /dev/null +++ b/gui/instancesettings.cpp @@ -0,0 +1,89 @@ +#include "instancesettings.h" +#include "ui_instancesettings.h" + +InstanceSettings::InstanceSettings(QWidget *parent) : + QDialog(parent), + ui(new Ui::InstanceSettings) +{ + ui->setupUi(this); +} + +InstanceSettings::~InstanceSettings() +{ + delete ui; +} + +void InstanceSettings::on_customCommandsGroupBox_toggled(bool state) +{ + ui->labelCustomCmdsDescription->setEnabled(state); +} + + +void InstanceSettings::applySettings(SettingsObject *s) +{ + + // Console + s->set("ShowConsole", ui->showConsoleCheck->isChecked()); + s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); + s->set("OverrideConsole", ui->consoleSettingsBox->isChecked()); + + // Window Size + s->set("LaunchCompatMode", ui->compatModeCheckBox->isChecked()); + s->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); + s->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); + s->set("MinecraftWinHeight", ui->windowHeightSpinBox->value()); + s->set("OverrideWindow", ui->windowSizeGroupBox->isChecked()); + + // Auto Login + s->set("AutoLogin", ui->autoLoginCheckBox->isChecked()); + s->set("OverrideLogin", ui->accountSettingsGroupBox->isChecked()); + + // Memory + s->set("MinMemAlloc", ui->minMemSpinBox->value()); + s->set("MaxMemAlloc", ui->maxMemSpinBox->value()); + s->set("OverrideMemory", ui->memoryGroupBox->isChecked()); + + // Java Settings + s->set("JavaPath", ui->javaPathTextBox->text()); + s->set("JvmArgs", ui->jvmArgsTextBox->text()); + s->set("OverrideJava", ui->javaSettingsGroupBox->isChecked()); + + // Custom Commands + s->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text()); + s->set("PostExitCommand", ui->postExitCmdTextBox->text()); + s->set("OverrideCommands", ui->customCommandsGroupBox->isChecked()); +} + +void InstanceSettings::loadSettings(SettingsObject *s) +{ + // Console + ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool()); + ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool()); + ui->consoleSettingsBox->setChecked(s->get("OverrideConsole").toBool()); + + // Window Size + ui->compatModeCheckBox->setChecked(s->get("LaunchCompatMode").toBool()); + ui->maximizedCheckBox->setChecked(s->get("LaunchMaximized").toBool()); + ui->windowWidthSpinBox->setValue(s->get("MinecraftWinWidth").toInt()); + ui->windowHeightSpinBox->setValue(s->get("MinecraftWinHeight").toInt()); + ui->windowSizeGroupBox->setChecked(s->get("OverrideWindow").toBool()); + + // Auto Login + ui->autoLoginCheckBox->setChecked(s->get("AutoLogin").toBool()); + ui->accountSettingsGroupBox->setChecked(s->get("OverrideLogin").toBool()); + + // Memory + ui->minMemSpinBox->setValue(s->get("MinMemAlloc").toInt()); + ui->maxMemSpinBox->setValue(s->get("MaxMemAlloc").toInt()); + ui->memoryGroupBox->setChecked(s->get("OverrideMemory").toBool()); + + // Java Settings + ui->javaPathTextBox->setText(s->get("JavaPath").toString()); + ui->jvmArgsTextBox->setText(s->get("JvmArgs").toString()); + ui->javaSettingsGroupBox->setChecked(s->get("OverrideJava").toBool()); + + // Custom Commands + ui->preLaunchCmdTextBox->setText(s->get("PreLaunchCommand").toString()); + ui->postExitCmdTextBox->setText(s->get("PostExitCommand").toString()); + ui->customCommandsGroupBox->setChecked(s->get("OverrideCommands").toBool()); +} diff --git a/gui/instancesettings.h b/gui/instancesettings.h new file mode 100644 index 00000000..af75a0f1 --- /dev/null +++ b/gui/instancesettings.h @@ -0,0 +1,32 @@ +#ifndef INSTANCESETTINGS_H +#define INSTANCESETTINGS_H + +#include + +namespace Ui { +class InstanceSettings; +} + +class InstanceSettings : public QDialog +{ + Q_OBJECT + +public: + explicit InstanceSettings(QWidget *parent = 0); + ~InstanceSettings(); + + void updateCheckboxStuff(); + + void applySettings(SettingsObject *s); + void loadSettings(SettingsObject* s); + +private slots: + void on_overrideGlobalMcCheck_clicked(bool checked); + + void on_customCommandsGroupBox_toggled(bool arg1); + +private: + Ui::InstanceSettings *ui; +}; + +#endif // INSTANCESETTINGS_H diff --git a/gui/instancesettings.ui b/gui/instancesettings.ui new file mode 100644 index 00000000..1fb8b023 --- /dev/null +++ b/gui/instancesettings.ui @@ -0,0 +1,386 @@ + + + InstanceSettings + + + + 0 + 0 + 453 + 563 + + + + Dialog + + + + + 9 + 9 + 435 + 516 + + + + QTabWidget::Rounded + + + 0 + + + + Minecraft + + + + + + true + + + Window Size + + + true + + + false + + + + + + Compatibility mode? + + + + + + + Start Minecraft maximized? + + + + + + + + + Window height: + + + + + + + Window width: + + + + + + + 854 + + + 65536 + + + 1 + + + 854 + + + + + + + 480 + + + 65536 + + + 480 + + + + + + + + + + + + true + + + Console Settings + + + true + + + false + + + + + + Show console while the game is running? + + + + + + + Automatically close console when the game quits? + + + + + + + + + + true + + + Account Settings + + + true + + + false + + + + + + false + + + Login automatically when an instance icon is double clicked? + + + false + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Java + + + + + + true + + + Memory + + + true + + + false + + + + + + 512 + + + 65536 + + + 128 + + + 1024 + + + + + + + Minimum memory allocation: + + + + + + + Maximum memory allocation: + + + + + + + 256 + + + 65536 + + + 128 + + + 256 + + + + + + + + + + true + + + Java Settings + + + true + + + false + + + + + + Java path: + + + + + + + + + + JVM arguments: + + + + + + + Auto-detect + + + + + + + + + + + + + true + + + Custom Commands + + + true + + + false + + + + + + Post-exit command: + + + + + + + Pre-launch command: + + + + + + + + + + + + + + + + false + + + + 0 + 0 + + + + Pre-launch command runs before the instance launches and post-exit command runs after it exits. Both will be run in MultiMC's working directory with INST_ID, INST_DIR, and INST_NAME as environment variables. + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + + + 270 + 530 + 166 + 23 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 8ba988c5..0b592cf0 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -553,3 +553,19 @@ void MainWindow::on_actionChangeInstLWJGLVersion_triggered() } } + +void MainWindow::on_actionInstanceSettings_triggered() +{ + if (view->selectionModel()->selectedIndexes().count() < 1) + return; + + Instance *inst = selectedInstance(); + SettingsObject *s; + s = &inst->settings(); + InstanceSettings *settings = new InstanceSettings (this); + settings->loadSettings(s); + if (settings->exec()) { + settings->applySettings(s); + } + delete settings; +} -- cgit From b5450042b5f9ddaad7585f644591b7d009aeb5cb Mon Sep 17 00:00:00 2001 From: Stiepen Date: Sun, 14 Jul 2013 22:01:30 +0200 Subject: Broke instance loading(?), also attempted to make Toolbar grayed out when no instance is selected. For debug purposes it is initially not grayed out --- CMakeLists.txt | 3 +++ gui/instancesettings.cpp | 24 ++++++++++++++++++++++-- gui/instancesettings.h | 3 +-- gui/instancesettings.ui | 11 +++++++---- gui/mainwindow.cpp | 9 +++++++++ gui/mainwindow.h | 4 ++++ gui/mainwindow.ui | 5 ++++- 7 files changed, 50 insertions(+), 9 deletions(-) (limited to 'gui/mainwindow.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt index e0a2123e..7463e063 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,6 +175,7 @@ gui/instancedelegate.h gui/versionselectdialog.h gui/lwjglselectdialog.h gui/iconcache.h +gui/instancesettings.h multimc_pragma.h @@ -206,6 +207,7 @@ gui/instancedelegate.cpp gui/versionselectdialog.cpp gui/lwjglselectdialog.cpp gui/iconcache.cpp +gui/instancesettings.cpp java/javautils.cpp java/annotations.cpp @@ -225,6 +227,7 @@ gui/aboutdialog.ui gui/consolewindow.ui gui/versionselectdialog.ui gui/lwjglselectdialog.ui +gui/instancesettings.ui ) diff --git a/gui/instancesettings.cpp b/gui/instancesettings.cpp index 7e82e1d6..d0e02b8e 100644 --- a/gui/instancesettings.cpp +++ b/gui/instancesettings.cpp @@ -1,3 +1,22 @@ +/* Copyright 2013 MultiMC Contributors + * + * Authors: Andrew Okin + * Peterix + * Orochimarufan + * + * 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 + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "instancesettings.h" #include "ui_instancesettings.h" @@ -35,7 +54,7 @@ void InstanceSettings::applySettings(SettingsObject *s) s->set("OverrideWindow", ui->windowSizeGroupBox->isChecked()); // Auto Login - s->set("AutoLogin", ui->autoLoginCheckBox->isChecked()); + s->set("AutoLogin", ui->autoLoginChecBox->isChecked()); s->set("OverrideLogin", ui->accountSettingsGroupBox->isChecked()); // Memory @@ -56,6 +75,7 @@ void InstanceSettings::applySettings(SettingsObject *s) void InstanceSettings::loadSettings(SettingsObject *s) { + // Console ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool()); ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool()); @@ -69,7 +89,7 @@ void InstanceSettings::loadSettings(SettingsObject *s) ui->windowSizeGroupBox->setChecked(s->get("OverrideWindow").toBool()); // Auto Login - ui->autoLoginCheckBox->setChecked(s->get("AutoLogin").toBool()); + ui->autoLoginChecBox->setChecked(s->get("AutoLogin").toBool()); ui->accountSettingsGroupBox->setChecked(s->get("OverrideLogin").toBool()); // Memory diff --git a/gui/instancesettings.h b/gui/instancesettings.h index af75a0f1..abd63199 100644 --- a/gui/instancesettings.h +++ b/gui/instancesettings.h @@ -2,6 +2,7 @@ #define INSTANCESETTINGS_H #include +#include "settingsobject.h" namespace Ui { class InstanceSettings; @@ -21,8 +22,6 @@ public: void loadSettings(SettingsObject* s); private slots: - void on_overrideGlobalMcCheck_clicked(bool checked); - void on_customCommandsGroupBox_toggled(bool arg1); private: diff --git a/gui/instancesettings.ui b/gui/instancesettings.ui index 1fb8b023..187275de 100644 --- a/gui/instancesettings.ui +++ b/gui/instancesettings.ui @@ -11,7 +11,7 @@ - Dialog + @@ -162,7 +162,7 @@ - false + true Login automatically when an instance icon is double clicked? @@ -370,12 +370,15 @@ - 270 + 9 530 - 166 + 435 23 + + Qt::Horizontal + QDialogButtonBox::Cancel|QDialogButtonBox::Ok diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 0b592cf0..4326431e 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -43,6 +43,7 @@ #include "gui/lwjglselectdialog.h" #include "gui/consolewindow.h" #include "gui/modeditwindow.h" +#include "gui/instancesettings.h" #include "kcategorizedview.h" #include "kcategorydrawer.h" @@ -130,6 +131,9 @@ MainWindow::MainWindow ( QWidget *parent ) : view->setModel ( proxymodel ); connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(instanceActivated(const QModelIndex &))); + + connect(view, SIGNAL(clicked(const QModelIndex &)), + this, SLOT(instanceChanged(const QModelIndex &))); // Load the instances. instList.loadList(); @@ -563,9 +567,14 @@ void MainWindow::on_actionInstanceSettings_triggered() SettingsObject *s; s = &inst->settings(); InstanceSettings *settings = new InstanceSettings (this); + settings->setWindowTitle(QString("Instance settings")); settings->loadSettings(s); if (settings->exec()) { settings->applySettings(s); } delete settings; } + +void MainWindow::instanceChanged(QModelIndex idx) { + ui->instanceToolBar->setEnabled(idx.isValid()); +} diff --git a/gui/mainwindow.h b/gui/mainwindow.h index f13d9395..a10d570c 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -108,8 +108,12 @@ private slots: void on_actionChangeInstLWJGLVersion_triggered(); + void on_actionInstanceSettings_triggered(); + public slots: void instanceActivated ( QModelIndex ); + + void instanceChanged ( QModelIndex ); void startTask(Task *task); diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 771e7096..e6a82635 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -65,6 +65,9 @@ + + true + Instance Toolbar @@ -300,7 +303,7 @@ - false + true Settings -- cgit From e2ee6d6d254285284f07b07cb60409fbda0bf7ad Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Tue, 16 Jul 2013 00:30:32 +0200 Subject: Finalize the instance settings dialog, add setting reset mechanism --- gui/instancesettings.cpp | 209 +++++++++++++++++++++----------- gui/instancesettings.h | 19 +-- gui/instancesettings.ui | 35 +++++- gui/mainwindow.cpp | 22 ++-- libmultimc/src/instance.cpp | 12 ++ libsettings/include/inisettingsobject.h | 1 + libsettings/include/setting.h | 13 ++ libsettings/include/settingsobject.h | 22 ++++ libsettings/src/inisettingsobject.cpp | 9 ++ libsettings/src/setting.cpp | 5 + libsettings/src/settingsobject.cpp | 18 +++ 11 files changed, 271 insertions(+), 94 deletions(-) (limited to 'gui/mainwindow.cpp') diff --git a/gui/instancesettings.cpp b/gui/instancesettings.cpp index d0e02b8e..eea61ce8 100644 --- a/gui/instancesettings.cpp +++ b/gui/instancesettings.cpp @@ -20,90 +20,161 @@ #include "instancesettings.h" #include "ui_instancesettings.h" -InstanceSettings::InstanceSettings(QWidget *parent) : - QDialog(parent), - ui(new Ui::InstanceSettings) +InstanceSettings::InstanceSettings( SettingsObject * obj, QWidget *parent) : + m_obj(obj), + QDialog(parent), + ui(new Ui::InstanceSettings) { - ui->setupUi(this); + ui->setupUi(this); + loadSettings(); } InstanceSettings::~InstanceSettings() { - delete ui; + delete ui; } void InstanceSettings::on_customCommandsGroupBox_toggled(bool state) { - ui->labelCustomCmdsDescription->setEnabled(state); + ui->labelCustomCmdsDescription->setEnabled(state); } - -void InstanceSettings::applySettings(SettingsObject *s) +void InstanceSettings::on_buttonBox_accepted() { + applySettings(); + accept(); +} - // Console - s->set("ShowConsole", ui->showConsoleCheck->isChecked()); - s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); - s->set("OverrideConsole", ui->consoleSettingsBox->isChecked()); - - // Window Size - s->set("LaunchCompatMode", ui->compatModeCheckBox->isChecked()); - s->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); - s->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); - s->set("MinecraftWinHeight", ui->windowHeightSpinBox->value()); - s->set("OverrideWindow", ui->windowSizeGroupBox->isChecked()); - - // Auto Login - s->set("AutoLogin", ui->autoLoginChecBox->isChecked()); - s->set("OverrideLogin", ui->accountSettingsGroupBox->isChecked()); - - // Memory - s->set("MinMemAlloc", ui->minMemSpinBox->value()); - s->set("MaxMemAlloc", ui->maxMemSpinBox->value()); - s->set("OverrideMemory", ui->memoryGroupBox->isChecked()); - - // Java Settings - s->set("JavaPath", ui->javaPathTextBox->text()); - s->set("JvmArgs", ui->jvmArgsTextBox->text()); - s->set("OverrideJava", ui->javaSettingsGroupBox->isChecked()); - - // Custom Commands - s->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text()); - s->set("PostExitCommand", ui->postExitCmdTextBox->text()); - s->set("OverrideCommands", ui->customCommandsGroupBox->isChecked()); +void InstanceSettings::on_buttonBox_rejected() +{ + reject(); } -void InstanceSettings::loadSettings(SettingsObject *s) + +void InstanceSettings::applySettings() { + // Console + bool console = ui->consoleSettingsBox->isChecked(); + m_obj->set("OverrideConsole", console); + if(console) + { + m_obj->set("ShowConsole", ui->showConsoleCheck->isChecked()); + m_obj->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); + } + else + { + m_obj->reset("ShowConsole"); + m_obj->reset("AutoCloseConsole"); + } + + // Window Size + bool window = ui->windowSizeGroupBox->isChecked(); + m_obj->set("OverrideWindow", window); + if(window) + { + m_obj->set("LaunchCompatMode", ui->compatModeCheckBox->isChecked()); + m_obj->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); + m_obj->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); + m_obj->set("MinecraftWinHeight", ui->windowHeightSpinBox->value()); + } + else + { + m_obj->reset("LaunchCompatMode"); + m_obj->reset("LaunchMaximized"); + m_obj->reset("MinecraftWinWidth"); + m_obj->reset("MinecraftWinHeight"); + } + + + // Auto Login + bool login = ui->accountSettingsGroupBox->isChecked(); + m_obj->set("OverrideLogin", login); + if(login) + { + m_obj->set("AutoLogin", ui->autoLoginChecBox->isChecked()); + } + else + { + m_obj->reset("AutoLogin"); + } + + + // Memory + bool memory = ui->memoryGroupBox->isChecked(); + m_obj->set("OverrideMemory", memory); + if(memory) + { + m_obj->set("MinMemAlloc", ui->minMemSpinBox->value()); + m_obj->set("MaxMemAlloc", ui->maxMemSpinBox->value()); + } + else + { + m_obj->reset("MinMemAlloc"); + m_obj->reset("MaxMemAlloc"); + } + + + // Java Settings + bool java = ui->javaSettingsGroupBox->isChecked(); + m_obj->set("OverrideJava", java); + if(java) + { + m_obj->set("JavaPath", ui->javaPathTextBox->text()); + m_obj->set("JvmArgs", ui->jvmArgsTextBox->text()); + } + else + { + m_obj->reset("JavaPath"); + m_obj->reset("JvmArgs"); + } + + + // Custom Commands + bool custcmd = ui->customCommandsGroupBox->isChecked(); + m_obj->set("OverrideCommands", custcmd); + if(custcmd) + { + m_obj->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text()); + m_obj->set("PostExitCommand", ui->postExitCmdTextBox->text()); + } + else + { + m_obj->reset("PreLaunchCommand"); + m_obj->reset("PostExitCommand"); + } + +} - // Console - ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool()); - ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool()); - ui->consoleSettingsBox->setChecked(s->get("OverrideConsole").toBool()); - - // Window Size - ui->compatModeCheckBox->setChecked(s->get("LaunchCompatMode").toBool()); - ui->maximizedCheckBox->setChecked(s->get("LaunchMaximized").toBool()); - ui->windowWidthSpinBox->setValue(s->get("MinecraftWinWidth").toInt()); - ui->windowHeightSpinBox->setValue(s->get("MinecraftWinHeight").toInt()); - ui->windowSizeGroupBox->setChecked(s->get("OverrideWindow").toBool()); - - // Auto Login - ui->autoLoginChecBox->setChecked(s->get("AutoLogin").toBool()); - ui->accountSettingsGroupBox->setChecked(s->get("OverrideLogin").toBool()); - - // Memory - ui->minMemSpinBox->setValue(s->get("MinMemAlloc").toInt()); - ui->maxMemSpinBox->setValue(s->get("MaxMemAlloc").toInt()); - ui->memoryGroupBox->setChecked(s->get("OverrideMemory").toBool()); - - // Java Settings - ui->javaPathTextBox->setText(s->get("JavaPath").toString()); - ui->jvmArgsTextBox->setText(s->get("JvmArgs").toString()); - ui->javaSettingsGroupBox->setChecked(s->get("OverrideJava").toBool()); - - // Custom Commands - ui->preLaunchCmdTextBox->setText(s->get("PreLaunchCommand").toString()); - ui->postExitCmdTextBox->setText(s->get("PostExitCommand").toString()); - ui->customCommandsGroupBox->setChecked(s->get("OverrideCommands").toBool()); +void InstanceSettings::loadSettings() +{ + // Console + ui->showConsoleCheck->setChecked(m_obj->get("ShowConsole").toBool()); + ui->autoCloseConsoleCheck->setChecked(m_obj->get("AutoCloseConsole").toBool()); + ui->consoleSettingsBox->setChecked(m_obj->get("OverrideConsole").toBool()); + + // Window Size + ui->compatModeCheckBox->setChecked(m_obj->get("LaunchCompatMode").toBool()); + ui->maximizedCheckBox->setChecked(m_obj->get("LaunchMaximized").toBool()); + ui->windowWidthSpinBox->setValue(m_obj->get("MinecraftWinWidth").toInt()); + ui->windowHeightSpinBox->setValue(m_obj->get("MinecraftWinHeight").toInt()); + ui->windowSizeGroupBox->setChecked(m_obj->get("OverrideWindow").toBool()); + + // Auto Login + ui->autoLoginChecBox->setChecked(m_obj->get("AutoLogin").toBool()); + ui->accountSettingsGroupBox->setChecked(m_obj->get("OverrideLogin").toBool()); + + // Memory + ui->minMemSpinBox->setValue(m_obj->get("MinMemAlloc").toInt()); + ui->maxMemSpinBox->setValue(m_obj->get("MaxMemAlloc").toInt()); + ui->memoryGroupBox->setChecked(m_obj->get("OverrideMemory").toBool()); + + // Java Settings + ui->javaPathTextBox->setText(m_obj->get("JavaPath").toString()); + ui->jvmArgsTextBox->setText(m_obj->get("JvmArgs").toString()); + ui->javaSettingsGroupBox->setChecked(m_obj->get("OverrideJava").toBool()); + + // Custom Commands + ui->preLaunchCmdTextBox->setText(m_obj->get("PreLaunchCommand").toString()); + ui->postExitCmdTextBox->setText(m_obj->get("PostExitCommand").toString()); + ui->customCommandsGroupBox->setChecked(m_obj->get("OverrideCommands").toBool()); } diff --git a/gui/instancesettings.h b/gui/instancesettings.h index abd63199..afbd0c16 100644 --- a/gui/instancesettings.h +++ b/gui/instancesettings.h @@ -10,22 +10,25 @@ class InstanceSettings; class InstanceSettings : public QDialog { - Q_OBJECT + Q_OBJECT public: - explicit InstanceSettings(QWidget *parent = 0); - ~InstanceSettings(); + explicit InstanceSettings(SettingsObject *s, QWidget *parent = 0); + ~InstanceSettings(); - void updateCheckboxStuff(); + void updateCheckboxStuff(); - void applySettings(SettingsObject *s); - void loadSettings(SettingsObject* s); + void applySettings(); + void loadSettings(); private slots: - void on_customCommandsGroupBox_toggled(bool arg1); + void on_customCommandsGroupBox_toggled(bool arg1); + void on_buttonBox_accepted(); + void on_buttonBox_rejected(); private: - Ui::InstanceSettings *ui; + Ui::InstanceSettings *ui; + SettingsObject * m_obj; }; #endif // INSTANCESETTINGS_H diff --git a/gui/instancesettings.ui b/gui/instancesettings.ui index 187275de..16e64100 100644 --- a/gui/instancesettings.ui +++ b/gui/instancesettings.ui @@ -162,7 +162,7 @@ - true + false Login automatically when an instance icon is double clicked? @@ -319,6 +319,9 @@ false + + + @@ -333,9 +336,6 @@ - - - @@ -362,6 +362,9 @@ true + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + @@ -384,6 +387,30 @@ + + settingsTabs + windowSizeGroupBox + compatModeCheckBox + maximizedCheckBox + windowWidthSpinBox + windowHeightSpinBox + consoleSettingsBox + showConsoleCheck + autoCloseConsoleCheck + accountSettingsGroupBox + autoLoginChecBox + memoryGroupBox + minMemSpinBox + maxMemSpinBox + javaSettingsGroupBox + javaPathTextBox + pushButton + jvmArgsTextBox + customCommandsGroupBox + preLaunchCmdTextBox + postExitCmdTextBox + buttonBox + diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 4326431e..4bf38424 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -560,19 +560,15 @@ void MainWindow::on_actionChangeInstLWJGLVersion_triggered() void MainWindow::on_actionInstanceSettings_triggered() { - if (view->selectionModel()->selectedIndexes().count() < 1) - return; - - Instance *inst = selectedInstance(); - SettingsObject *s; - s = &inst->settings(); - InstanceSettings *settings = new InstanceSettings (this); - settings->setWindowTitle(QString("Instance settings")); - settings->loadSettings(s); - if (settings->exec()) { - settings->applySettings(s); - } - delete settings; + if (view->selectionModel()->selectedIndexes().count() < 1) + return; + + Instance *inst = selectedInstance(); + SettingsObject *s; + s = &inst->settings(); + InstanceSettings settings(s, this); + settings.setWindowTitle(QString("Instance settings")); + settings.exec(); } void MainWindow::instanceChanged(QModelIndex idx) { diff --git a/libmultimc/src/instance.cpp b/libmultimc/src/instance.cpp index fde31cf3..c1506a02 100644 --- a/libmultimc/src/instance.cpp +++ b/libmultimc/src/instance.cpp @@ -62,6 +62,18 @@ Instance::Instance(const QString &rootDir, QObject *parent) : // Auto login settings().registerSetting(new OverrideSetting("AutoLogin", globalSettings->getSetting("AutoLogin"))); + + // Console + settings().registerSetting(new OverrideSetting("ShowConsole", globalSettings->getSetting("ShowConsole"))); + settings().registerSetting(new OverrideSetting("AutoCloseConsole", globalSettings->getSetting("AutoCloseConsole"))); + + // Overrides + settings().registerSetting(new Setting("OverrideConsole", false)); + settings().registerSetting(new Setting("OverrideWindow", false)); + settings().registerSetting(new Setting("OverrideLogin", false)); + settings().registerSetting(new Setting("OverrideMemory", false)); + settings().registerSetting(new Setting("OverrideJava", false)); + settings().registerSetting(new Setting("OverrideCommands", false)); } QString Instance::id() const diff --git a/libsettings/include/inisettingsobject.h b/libsettings/include/inisettingsobject.h index 36c8e4bd..03d6fe05 100644 --- a/libsettings/include/inisettingsobject.h +++ b/libsettings/include/inisettingsobject.h @@ -47,6 +47,7 @@ public: protected slots: virtual void changeSetting(const Setting &setting, QVariant value); + virtual void resetSetting ( const Setting& setting ); protected: virtual QVariant retrieveValue(const Setting &setting); diff --git a/libsettings/include/setting.h b/libsettings/include/setting.h index 36709729..a161ab50 100644 --- a/libsettings/include/setting.h +++ b/libsettings/include/setting.h @@ -84,6 +84,12 @@ signals: */ void settingChanged(const Setting &setting, QVariant value); + /*! + * \brief Signal emitted when this Setting object's value resets to default. + * \param setting A reference to the Setting that changed. + */ + void settingReset(const Setting &setting); + public slots: /*! * \brief Changes the setting's value. @@ -93,6 +99,13 @@ public slots: */ virtual void set(QVariant value); + /*! + * \brief Reset the setting to default + * This is done by emitting the settingReset() signal which will then be + * handled by the SettingsObject object and cause the setting to change. + * \param value The new value. + */ + virtual void reset(); protected: QString m_id; QVariant m_defVal; diff --git a/libsettings/include/settingsobject.h b/libsettings/include/settingsobject.h index 23f0d644..a2f03699 100644 --- a/libsettings/include/settingsobject.h +++ b/libsettings/include/settingsobject.h @@ -100,6 +100,11 @@ public: */ virtual bool set(const QString &id, QVariant value); + /*! + * \brief Reverts the setting with the given ID to default. + * \param id The ID of the setting to reset. + */ + virtual void reset(const QString &id) const; /*! * \brief Gets a QList with pointers to all of the registered settings. @@ -125,6 +130,14 @@ signals: */ void settingChanged(const Setting &setting, QVariant value); + /*! + * \brief Signal emitted when one of this SettingsObject object's settings resets. + * This is usually just connected directly to each Setting object's + * settingReset() signals. + * \param setting A reference to the Setting object that changed. + */ + void settingReset(const Setting &setting); + protected slots: /*! * \brief Changes a setting. @@ -136,6 +149,15 @@ protected slots: */ virtual void changeSetting(const Setting &setting, QVariant value) = 0; + /*! + * \brief Resets a setting. + * This slot is usually connected to each Setting object's + * settingReset() signal. The signal is emitted, causing this slot + * to update the setting's value in the config file. + * \param setting A reference to the Setting object that changed. + */ + virtual void resetSetting(const Setting &setting) = 0; + protected: /*! * \brief Connects the necessary signals to the given Setting. diff --git a/libsettings/src/inisettingsobject.cpp b/libsettings/src/inisettingsobject.cpp index 17b132a3..854421b6 100644 --- a/libsettings/src/inisettingsobject.cpp +++ b/libsettings/src/inisettingsobject.cpp @@ -40,6 +40,15 @@ void INISettingsObject::changeSetting(const Setting &setting, QVariant value) } } +void INISettingsObject::resetSetting ( const Setting& setting ) +{ + if (contains(setting.id())) + { + m_ini.remove(setting.configKey()); + m_ini.saveFile(m_filePath); + } +} + QVariant INISettingsObject::retrieveValue(const Setting &setting) { if (contains(setting.id())) diff --git a/libsettings/src/setting.cpp b/libsettings/src/setting.cpp index 1a4f9e13..8e60af06 100644 --- a/libsettings/src/setting.cpp +++ b/libsettings/src/setting.cpp @@ -47,3 +47,8 @@ void Setting::set(QVariant value) { emit settingChanged(*this, value); } + +void Setting::reset() +{ + emit settingReset(*this); +} diff --git a/libsettings/src/settingsobject.cpp b/libsettings/src/settingsobject.cpp index f94a6552..bf7b8825 100644 --- a/libsettings/src/settingsobject.cpp +++ b/libsettings/src/settingsobject.cpp @@ -98,6 +98,14 @@ bool SettingsObject::set(const QString &id, QVariant value) } } +void SettingsObject::reset(const QString &id) const +{ + Setting *setting = getSetting(id); + if(setting) + setting->reset(); +} + + QList SettingsObject::getSettings() { return m_settings.values(); @@ -115,6 +123,11 @@ void SettingsObject::connectSignals(const Setting &setting) SLOT(changeSetting(const Setting &, QVariant))); connect(&setting, SIGNAL(settingChanged(const Setting &, QVariant)), SIGNAL(settingChanged(const Setting &, QVariant))); + + connect(&setting, SIGNAL(settingReset(Setting)), + SLOT(resetSetting(const Setting &))); + connect(&setting, SIGNAL(settingReset(Setting)), + SIGNAL(settingReset(const Setting &))); } void SettingsObject::disconnectSignals(const Setting &setting) @@ -123,4 +136,9 @@ void SettingsObject::disconnectSignals(const Setting &setting) this, SLOT(changeSetting(const Setting &, QVariant))); setting.disconnect(SIGNAL(settingChanged(const Setting &, QVariant)), this, SIGNAL(settingChanged(const Setting &, QVariant))); + + setting.disconnect(SIGNAL(settingReset(const Setting &, QVariant)), + this, SLOT(resetSetting(const Setting &, QVariant))); + setting.disconnect(SIGNAL(settingReset(const Setting &, QVariant)), + this, SIGNAL(settingReset(const Setting &, QVariant))); } -- cgit