File indexing completed on 2024-05-19 04:55:56

0001 /**
0002  * \file kid3settings.h
0003  * Wrapper for Qt application settings.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 07 Apr 2013
0008  *
0009  * Copyright (C) 2013-2024  Urs Fleisch
0010  *
0011  * This file is part of Kid3.
0012  *
0013  * Kid3 is free software; you can redistribute it and/or modify
0014  * it under the terms of the GNU General Public License as published by
0015  * the Free Software Foundation; either version 2 of the License, or
0016  * (at your option) any later version.
0017  *
0018  * Kid3 is distributed in the hope that it will be useful,
0019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0021  * GNU General Public License for more details.
0022  *
0023  * You should have received a copy of the GNU General Public License
0024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0025  */
0026 
0027 #pragma once
0028 
0029 #include "isettings.h"
0030 
0031 class QSettings;
0032 
0033 /**
0034  * Wrapper for KDE application settings.
0035  */
0036 class KID3_CORE_EXPORT Kid3Settings : public ISettings {
0037 public:
0038   /**
0039    * Constructor.
0040    * @param config Qt settings
0041    */
0042   explicit Kid3Settings(QSettings* config);
0043 
0044   /**
0045    * Destructor.
0046    */
0047   ~Kid3Settings() override = default;
0048 
0049   /**
0050    * Use settings subgroup.
0051    * @param prefix group name
0052    * @param forState true if this group stores state information
0053    */
0054   void beginGroup(const QString& prefix, bool forState = false) override;
0055 
0056   /**
0057    * Finnish using settings subgroup.
0058    */
0059   void endGroup() override;
0060 
0061   /**
0062    * Set value for setting.
0063    * @param key name of setting
0064    * @param value value for setting
0065    */
0066   void setValue(const QString& key, const QVariant& value) override;
0067 
0068   /**
0069    * Get value for setting.
0070    * @param key name of setting
0071    * @param defaultValue default value
0072    * @return value of setting as variant.
0073    */
0074   QVariant value(const QString& key,
0075                  const QVariant& defaultValue) const override;
0076 
0077   /**
0078    * Remove setting.
0079    * @param key name of setting
0080    */
0081   void remove(const QString& key) override;
0082 
0083   /**
0084    * Check if setting exists.
0085    * @param key name of setting
0086    * @return true if setting exists.
0087    */
0088   bool contains(const QString& key) const override;
0089 
0090   /**
0091    * Write unsaved changes to permanent storage.
0092    */
0093   void sync() override;
0094 
0095 private:
0096   QSettings* m_config;
0097 };