Save/restore settings dialog (and instance specific settings) window geometry
This commit is contained in:
		| @@ -427,6 +427,8 @@ void MultiMC::initGlobalSettings() | ||||
|  | ||||
| 	m_settings->registerSetting("ConsoleWindowState", ""); | ||||
| 	m_settings->registerSetting("ConsoleWindowGeometry", ""); | ||||
|  | ||||
| 	m_settings->registerSetting("SettingsGeometry", ""); | ||||
| } | ||||
|  | ||||
| void MultiMC::initHttpMetaCache() | ||||
|   | ||||
| @@ -36,6 +36,9 @@ InstanceSettings::InstanceSettings(SettingsObject *obj, QWidget *parent) | ||||
| { | ||||
| 	MultiMCPlatform::fixWM_CLASS(this); | ||||
| 	ui->setupUi(this); | ||||
|  | ||||
| 	restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("SettingsGeometry").toByteArray())); | ||||
|  | ||||
| 	loadSettings(); | ||||
| } | ||||
|  | ||||
| @@ -47,7 +50,13 @@ InstanceSettings::~InstanceSettings() | ||||
| void InstanceSettings::showEvent(QShowEvent *ev) | ||||
| { | ||||
| 	QDialog::showEvent(ev); | ||||
| 	adjustSize(); | ||||
| } | ||||
|  | ||||
| void InstanceSettings::closeEvent(QCloseEvent *ev) | ||||
| { | ||||
| 	MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64()); | ||||
|  | ||||
| 	QDialog::closeEvent(ev); | ||||
| } | ||||
|  | ||||
| void InstanceSettings::on_customCommandsGroupBox_toggled(bool state) | ||||
| @@ -57,12 +66,16 @@ void InstanceSettings::on_customCommandsGroupBox_toggled(bool state) | ||||
|  | ||||
| void InstanceSettings::on_buttonBox_accepted() | ||||
| { | ||||
| 	MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64()); | ||||
|  | ||||
| 	applySettings(); | ||||
| 	accept(); | ||||
| } | ||||
|  | ||||
| void InstanceSettings::on_buttonBox_rejected() | ||||
| { | ||||
| 	MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64()); | ||||
|  | ||||
| 	reject(); | ||||
| } | ||||
|  | ||||
| @@ -227,4 +240,4 @@ void InstanceSettings::checkFinished(JavaCheckResult result) | ||||
| 			tr("The specified java binary didn't work. You should use the auto-detect feature, " | ||||
| 			   "or set the path to the java executable.")); | ||||
| 	} | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -39,6 +39,7 @@ public: | ||||
|  | ||||
| protected: | ||||
| 	virtual void showEvent(QShowEvent *); | ||||
| 	virtual void closeEvent(QCloseEvent *); | ||||
| private | ||||
| slots: | ||||
| 	void on_customCommandsGroupBox_toggled(bool arg1); | ||||
|   | ||||
| @@ -44,6 +44,8 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Se | ||||
| 	ui->jsonEditorTextBox->setClearButtonEnabled(true); | ||||
| #endif | ||||
|  | ||||
| 	restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("SettingsGeometry").toByteArray())); | ||||
|  | ||||
| 	loadSettings(MMC->settings().get()); | ||||
| 	updateCheckboxStuff(); | ||||
| } | ||||
| @@ -55,7 +57,13 @@ SettingsDialog::~SettingsDialog() | ||||
| void SettingsDialog::showEvent(QShowEvent *ev) | ||||
| { | ||||
| 	QDialog::showEvent(ev); | ||||
| 	adjustSize(); | ||||
| } | ||||
|  | ||||
| void SettingsDialog::closeEvent(QCloseEvent *ev) | ||||
| { | ||||
| 	MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64()); | ||||
|  | ||||
| 	QDialog::closeEvent(ev); | ||||
| } | ||||
|  | ||||
| void SettingsDialog::updateCheckboxStuff() | ||||
| @@ -180,6 +188,13 @@ void SettingsDialog::on_maximizedCheckBox_clicked(bool checked) | ||||
| void SettingsDialog::on_buttonBox_accepted() | ||||
| { | ||||
| 	applySettings(MMC->settings().get()); | ||||
|  | ||||
| 	MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64()); | ||||
| } | ||||
|  | ||||
| void SettingsDialog::on_buttonBox_rejected() | ||||
| { | ||||
| 	MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64()); | ||||
| } | ||||
|  | ||||
| void SettingsDialog::applySettings(SettingsObject *s) | ||||
|   | ||||
| @@ -41,7 +41,8 @@ public: | ||||
| 	void loadSettings(SettingsObject *s); | ||||
|  | ||||
| protected: | ||||
| 	virtual void showEvent(QShowEvent *); | ||||
| 	virtual void showEvent(QShowEvent *ev); | ||||
| 	virtual void closeEvent(QCloseEvent *ev); | ||||
|  | ||||
| private | ||||
| slots: | ||||
| @@ -64,6 +65,8 @@ slots: | ||||
|  | ||||
| 	void on_buttonBox_accepted(); | ||||
|  | ||||
| 	void on_buttonBox_rejected(); | ||||
|  | ||||
| 	void on_javaDetectBtn_clicked(); | ||||
|  | ||||
| 	void on_javaTestBtn_clicked(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user