File indexing completed on 2024-11-24 03:56:28
0001 /* 0002 * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <vector> 0010 0011 #include <QIcon> 0012 0013 #include "app/utils/translated_string.hpp" 0014 #include "app/settings/setting.hpp" 0015 #include "custom_settings_group.hpp" 0016 0017 namespace app::settings { 0018 0019 class SettingsGroup : public CustomSettingsGroupBase 0020 { 0021 public: 0022 using iterator = SettingList::const_iterator; 0023 0024 SettingsGroup(QString slug, utils::TranslatedString label, const QString& icon, SettingList settings); 0025 SettingsGroup(SettingList settings); 0026 0027 QString slug() const override; 0028 0029 QString label() const override; 0030 0031 QIcon icon() const override; 0032 0033 void load(QSettings& settings) override; 0034 0035 void save(QSettings& settings) override; 0036 0037 QWidget* make_widget(QWidget* parent) override; 0038 0039 bool has_visible_settings() const override; 0040 0041 QVariant get_variant(const QString& setting_slug) const override; 0042 0043 bool set_variant(const QString& setting_slug, const QVariant& value) override; 0044 0045 QVariant get_default(const QString& setting_slug) const override; 0046 0047 QVariant define(const QString& setting_slug, const QVariant& default_value) override; 0048 0049 0050 iterator begin() const { return settings_.begin(); } 0051 iterator end() const { return settings_.end(); } 0052 0053 SettingList& settings() { return settings_; } 0054 QVariantMap& values() { return values_; } 0055 0056 private: 0057 QString slug_; 0058 utils::TranslatedString label_; 0059 QString icon_; 0060 SettingList settings_; 0061 QVariantMap values_; 0062 }; 0063 0064 } // namespace app::settings 0065