File indexing completed on 2024-11-24 03:56:27
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 <memory> 0010 #include <QSettings> 0011 #include <QIcon> 0012 0013 namespace app::settings { 0014 0015 class CustomSettingsGroupBase 0016 { 0017 public: 0018 virtual ~CustomSettingsGroupBase() = default; 0019 virtual QString slug() const = 0; 0020 virtual QString label() const = 0; 0021 virtual QIcon icon() const = 0; 0022 virtual void load(QSettings& settings) = 0; 0023 virtual void save(QSettings& settings) = 0; 0024 virtual QWidget* make_widget(QWidget* parent) = 0; 0025 virtual bool has_visible_settings() const { return true; } 0026 virtual QVariant get_variant(const QString& setting) const 0027 { 0028 Q_UNUSED(setting); 0029 return {}; 0030 0031 } 0032 virtual bool set_variant(const QString& setting_slug, const QVariant& value) 0033 { 0034 Q_UNUSED(setting_slug); 0035 Q_UNUSED(value); 0036 return false; 0037 } 0038 0039 virtual QVariant get_default(const QString& setting_slug) const 0040 { 0041 Q_UNUSED(setting_slug); 0042 return {}; 0043 } 0044 virtual QVariant define(const QString& setting_slug, const QVariant& default_value) 0045 { 0046 Q_UNUSED(setting_slug); 0047 Q_UNUSED(default_value); 0048 return {}; 0049 } 0050 }; 0051 0052 0053 using CustomSettingsGroup = std::unique_ptr<CustomSettingsGroupBase>; 0054 0055 } // namespace app::settings