1 /* Copyright 2013-2019 MultiMC Contributors 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #pragma once 17 18 #include <QObject> 19 20 #include "settings/INIFile.h" 21 22 #include "settings/SettingsObject.h" 23 24 #include "multimc_logic_export.h" 25 26 /*! 27 * \brief A settings object that stores its settings in an INIFile. 28 */ 29 class MULTIMC_LOGIC_EXPORT INISettingsObject : public SettingsObject 30 { 31 Q_OBJECT 32 public: 33 explicit INISettingsObject(const QString &path, QObject *parent = 0); 34 35 /*! 36 * \brief Gets the path to the INI file. 37 * \return The path to the INI file. 38 */ filePath()39 virtual QString filePath() const 40 { 41 return m_filePath; 42 } 43 44 /*! 45 * \brief Sets the path to the INI file and reloads it. 46 * \param filePath The INI file's new path. 47 */ 48 virtual void setFilePath(const QString &filePath); 49 50 bool reload() override; 51 52 void suspendSave() override; 53 void resumeSave() override; 54 55 protected slots: 56 virtual void changeSetting(const Setting &setting, QVariant value) override; 57 virtual void resetSetting(const Setting &setting) override; 58 59 protected: 60 virtual QVariant retrieveValue(const Setting &setting) override; 61 void doSave(); 62 63 protected: 64 INIFile m_ini; 65 QString m_filePath; 66 }; 67