Implemented settings dialog.
This commit is contained in:
@ -16,13 +16,19 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "ui_settingsdialog.h"
|
||||
|
||||
#include "data/appsettings.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
SettingsDialog::SettingsDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::SettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
loadSettings(settings);
|
||||
updateCheckboxStuff();
|
||||
}
|
||||
|
||||
SettingsDialog::~SettingsDialog()
|
||||
@ -32,10 +38,10 @@ SettingsDialog::~SettingsDialog()
|
||||
|
||||
void SettingsDialog::updateCheckboxStuff()
|
||||
{
|
||||
ui->minMemSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() ||
|
||||
ui->maximizedCheckBox->isChecked()));
|
||||
ui->maxMemSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() ||
|
||||
ui->maximizedCheckBox->isChecked()));
|
||||
ui->windowWidthSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() ||
|
||||
ui->maximizedCheckBox->isChecked()));
|
||||
ui->windowHeightSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() ||
|
||||
ui->maximizedCheckBox->isChecked()));
|
||||
|
||||
ui->maximizedCheckBox->setEnabled(!ui->compatModeCheckBox->isChecked());
|
||||
}
|
||||
@ -75,3 +81,101 @@ void SettingsDialog::on_maximizedCheckBox_clicked(bool checked)
|
||||
Q_UNUSED(checked);
|
||||
updateCheckboxStuff();
|
||||
}
|
||||
|
||||
void SettingsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
applySettings(settings);
|
||||
}
|
||||
|
||||
void SettingsDialog::applySettings(SettingsBase *s)
|
||||
{
|
||||
// Special cases
|
||||
|
||||
// Warn about dev builds.
|
||||
if (!ui->devBuildsCheckBox->isChecked())
|
||||
{
|
||||
s->setUseDevBuilds(false);
|
||||
}
|
||||
else if (!s->getUseDevBuilds())
|
||||
{
|
||||
int response = QMessageBox::question(this, "Development builds",
|
||||
"Development builds contain experimental features "
|
||||
"and may be unstable. Are you sure you want to enable them?");
|
||||
if (response == QMessageBox::Yes)
|
||||
{
|
||||
s->setUseDevBuilds(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updates
|
||||
s->setAutoUpdate(ui->autoUpdateCheckBox->isChecked());
|
||||
|
||||
// Folders
|
||||
// TODO: Offer to move instances to new instance folder.
|
||||
s->setInstanceDir(ui->instDirTextBox->text());
|
||||
s->setCentralModsDir(ui->modsDirTextBox->text());
|
||||
s->setLWJGLDir(ui->lwjglDirTextBox->text());
|
||||
|
||||
// Console
|
||||
s->setShowConsole(ui->showConsoleCheck->isChecked());
|
||||
s->setAutoCloseConsole(ui->autoCloseConsoleCheck->isChecked());
|
||||
|
||||
// Window Size
|
||||
s->setLaunchCompatMode(ui->compatModeCheckBox->isChecked());
|
||||
s->setLaunchMaximized(ui->maximizedCheckBox->isChecked());
|
||||
s->setMinecraftWinWidth(ui->windowWidthSpinBox->value());
|
||||
s->setMinecraftWinHeight(ui->windowHeightSpinBox->value());
|
||||
|
||||
// Auto Login
|
||||
s->setAutoLogin(ui->autoLoginCheckBox->isChecked());
|
||||
|
||||
// Memory
|
||||
s->setMinMemAlloc(ui->minMemSpinBox->value());
|
||||
s->setMaxMemAlloc(ui->maxMemSpinBox->value());
|
||||
|
||||
// Java Settings
|
||||
s->setJavaPath(ui->javaPathTextBox->text());
|
||||
s->setJvmArgs(ui->jvmArgsTextBox->text());
|
||||
|
||||
// Custom Commands
|
||||
s->setPreLaunchCommand(ui->preLaunchCmdTextBox->text());
|
||||
s->setPostExitCommand(ui->postExitCmdTextBox->text());
|
||||
}
|
||||
|
||||
void SettingsDialog::loadSettings(SettingsBase *s)
|
||||
{
|
||||
// Updates
|
||||
ui->autoUpdateCheckBox->setChecked(s->getAutoUpdate());
|
||||
ui->devBuildsCheckBox->setChecked(s->getUseDevBuilds());
|
||||
|
||||
// Folders
|
||||
ui->instDirTextBox->setText(s->getInstanceDir());
|
||||
ui->modsDirTextBox->setText(s->getCentralModsDir());
|
||||
ui->lwjglDirTextBox->setText(s->getLWJGLDir());
|
||||
|
||||
// Console
|
||||
ui->showConsoleCheck->setChecked(s->getShowConsole());
|
||||
ui->autoCloseConsoleCheck->setChecked(s->getAutoCloseConsole());
|
||||
|
||||
// Window Size
|
||||
ui->compatModeCheckBox->setChecked(s->getLaunchCompatMode());
|
||||
ui->maximizedCheckBox->setChecked(s->getLaunchMaximized());
|
||||
ui->windowWidthSpinBox->setValue(s->getMinecraftWinWidth());
|
||||
ui->windowHeightSpinBox->setValue(s->getMinecraftWinHeight());
|
||||
|
||||
// Auto Login
|
||||
ui->autoLoginCheckBox->setChecked(s->getAutoLogin());
|
||||
|
||||
// Memory
|
||||
ui->minMemSpinBox->setValue(s->getMinMemAlloc());
|
||||
ui->maxMemSpinBox->setValue(s->getMaxMemAlloc());
|
||||
|
||||
// Java Settings
|
||||
ui->javaPathTextBox->setText(s->getJavaPath());
|
||||
ui->jvmArgsTextBox->setText(s->getJvmArgs());
|
||||
|
||||
// Custom Commands
|
||||
ui->preLaunchCmdTextBox->setText(s->getPreLaunchCommand());
|
||||
ui->postExitCmdTextBox->setText(s->getPostExitCommand());
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class SettingsBase;
|
||||
|
||||
namespace Ui {
|
||||
class SettingsDialog;
|
||||
}
|
||||
@ -32,6 +34,9 @@ public:
|
||||
|
||||
void updateCheckboxStuff();
|
||||
|
||||
void applySettings(SettingsBase* s);
|
||||
void loadSettings(SettingsBase* s);
|
||||
|
||||
private slots:
|
||||
void on_instDirBrowseBtn_clicked();
|
||||
|
||||
@ -43,6 +48,8 @@ private slots:
|
||||
|
||||
void on_maximizedCheckBox_clicked(bool checked);
|
||||
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
private:
|
||||
Ui::SettingsDialog *ui;
|
||||
};
|
||||
|
@ -158,88 +158,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="consoleTab">
|
||||
<attribute name="title">
|
||||
<string>Console</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="consoleSettingsBox">
|
||||
<property name="title">
|
||||
<string>Console Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="showConsoleCheck">
|
||||
<property name="text">
|
||||
<string>Show console while the game is running?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autoCloseConsoleCheck">
|
||||
<property name="text">
|
||||
<string>Automatically close console when the game quits?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="consoleColorsBox">
|
||||
<property name="title">
|
||||
<string>Instance Console Colors</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelSysMessageColor">
|
||||
<property name="text">
|
||||
<string>System message color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="sysMsgColorTextBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelOutputMsgColor">
|
||||
<property name="text">
|
||||
<string>Output message color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="outMsgColorTextBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelErrorMessageColor">
|
||||
<property name="text">
|
||||
<string>Error message color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="errMsgColorTextBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="consoleVerticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="minecraftTab">
|
||||
<attribute name="title">
|
||||
<string>Minecraft</string>
|
||||
@ -315,10 +233,33 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="consoleSettingsBox">
|
||||
<property name="title">
|
||||
<string>Console Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="showConsoleCheck">
|
||||
<property name="text">
|
||||
<string>Show console while the game is running?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autoCloseConsoleCheck">
|
||||
<property name="text">
|
||||
<string>Automatically close console when the game quits?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autoLoginCheckBox">
|
||||
<property name="text">
|
||||
<string>Login automatically when an instance launches?</string>
|
||||
<string>Login automatically when an instance icon is double clicked?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Reference in New Issue
Block a user