File indexing completed on 2024-11-10 04:56:46

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include <KCModule>
0013 #include <KConfigGroup>
0014 #include <KPluginFactory>
0015 
0016 class KLocalizedTranslator;
0017 
0018 namespace KWin
0019 {
0020 
0021 class GenericScriptedConfigFactory : public KPluginFactory
0022 {
0023     Q_OBJECT
0024     Q_PLUGIN_METADATA(IID "org.kde.KPluginFactory" FILE "genericscriptedconfig.json")
0025     Q_INTERFACES(KPluginFactory)
0026 
0027 protected:
0028     QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args) override;
0029 };
0030 
0031 class GenericScriptedConfig : public KCModule
0032 {
0033     Q_OBJECT
0034 
0035 public:
0036     GenericScriptedConfig(const QString &keyword, QWidget *parent, const QVariantList &args);
0037     ~GenericScriptedConfig() override;
0038 
0039 public Q_SLOTS:
0040     void save() override;
0041 
0042 protected:
0043     const QString &packageName() const;
0044     void createUi();
0045     virtual QString typeName() const = 0;
0046     virtual KConfigGroup configGroup() = 0;
0047     virtual void reload();
0048 
0049 private:
0050     QString m_packageName;
0051     KLocalizedTranslator *m_translator;
0052 };
0053 
0054 class ScriptedEffectConfig : public GenericScriptedConfig
0055 {
0056     Q_OBJECT
0057 public:
0058     ScriptedEffectConfig(const QString &keyword, QWidget *parent, const QVariantList &args);
0059     ~ScriptedEffectConfig() override;
0060 
0061 protected:
0062     QString typeName() const override;
0063     KConfigGroup configGroup() override;
0064     void reload() override;
0065 };
0066 
0067 class ScriptingConfig : public GenericScriptedConfig
0068 {
0069     Q_OBJECT
0070 public:
0071     ScriptingConfig(const QString &keyword, QWidget *parent, const QVariantList &args);
0072     ~ScriptingConfig() override;
0073 
0074 protected:
0075     QString typeName() const override;
0076     KConfigGroup configGroup() override;
0077     void reload() override;
0078 };
0079 
0080 inline const QString &GenericScriptedConfig::packageName() const
0081 {
0082     return m_packageName;
0083 }
0084 
0085 }