Port QML KCMs away from setAboutData

Let them use the JSON metadata instead
This commit is contained in:
Nicolas Fella 2023-02-17 16:29:36 +01:00 committed by Vlad Zahorodnii
parent d203d3b370
commit 61718d9017
12 changed files with 18 additions and 68 deletions

View file

@ -11,7 +11,6 @@
#include "declarative-plugin/buttonsmodel.h" #include "declarative-plugin/buttonsmodel.h"
#include "decorationmodel.h" #include "decorationmodel.h"
#include <KAboutData>
#include <KConfigGroup> #include <KConfigGroup>
#include <KLocalizedString> #include <KLocalizedString>
#include <KNSCore/Engine> #include <KNSCore/Engine>
@ -36,8 +35,8 @@ namespace
const KDecoration2::BorderSize s_defaultRecommendedBorderSize = KDecoration2::BorderSize::Normal; const KDecoration2::BorderSize s_defaultRecommendedBorderSize = KDecoration2::BorderSize::Normal;
} }
KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &arguments) KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const KPluginMetaData &metaData, const QVariantList &arguments)
: KQuickAddons::ManagedConfigModule(parent, arguments) : KQuickAddons::ManagedConfigModule(parent, metaData, arguments)
, m_themesModel(new KDecoration2::Configuration::DecorationsModel(this)) , m_themesModel(new KDecoration2::Configuration::DecorationsModel(this))
, m_proxyThemesModel(new QSortFilterProxyModel(this)) , m_proxyThemesModel(new QSortFilterProxyModel(this))
, m_leftButtonsModel(new KDecoration2::Preview::ButtonsModel(DecorationButtonsList(), this)) , m_leftButtonsModel(new KDecoration2::Preview::ButtonsModel(DecorationButtonsList(), this))
@ -45,15 +44,6 @@ KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &argume
, m_availableButtonsModel(new KDecoration2::Preview::ButtonsModel(this)) , m_availableButtonsModel(new KDecoration2::Preview::ButtonsModel(this))
, m_data(new KWinDecorationData(this)) , m_data(new KWinDecorationData(this))
{ {
auto about = new KAboutData(QStringLiteral("kcm_kwindecoration"),
i18n("Window Decorations"),
QStringLiteral("1.0"),
QString(),
KAboutLicense::GPL);
about->addAuthor(i18n("Valerio Pilo"),
i18n("Author"),
QStringLiteral("vpilo@coldshock.net"));
setAboutData(about);
setButtons(Apply | Default | Help); setButtons(Apply | Default | Help);
qmlRegisterAnonymousType<QAbstractListModel>("org.kde.kwin.KWinDecoration", 1); qmlRegisterAnonymousType<QAbstractListModel>("org.kde.kwin.KWinDecoration", 1);
qmlRegisterAnonymousType<QSortFilterProxyModel>("org.kde.kwin.KWinDecoration", 1); qmlRegisterAnonymousType<QSortFilterProxyModel>("org.kde.kwin.KWinDecoration", 1);

View file

@ -47,7 +47,7 @@ class KCMKWinDecoration : public KQuickAddons::ManagedConfigModule
Q_PROPERTY(QAbstractListModel *availableButtonsModel READ availableButtonsModel CONSTANT) Q_PROPERTY(QAbstractListModel *availableButtonsModel READ availableButtonsModel CONSTANT)
public: public:
KCMKWinDecoration(QObject *parent, const QVariantList &arguments); KCMKWinDecoration(QObject *parent, const KPluginMetaData &metaData, const QVariantList &arguments);
KWinDecorationSettings *settings() const; KWinDecorationSettings *settings() const;
QSortFilterProxyModel *themesModel() const; QSortFilterProxyModel *themesModel() const;

View file

@ -25,15 +25,10 @@ K_PLUGIN_FACTORY_WITH_JSON(VirtualDesktopsFactory,
namespace KWin namespace KWin
{ {
VirtualDesktops::VirtualDesktops(QObject *parent, const QVariantList &args) VirtualDesktops::VirtualDesktops(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
: KQuickAddons::ManagedConfigModule(parent, args) : KQuickAddons::ManagedConfigModule(parent, metaData, args)
, m_data(new VirtualDesktopsData(this)) , m_data(new VirtualDesktopsData(this))
{ {
KAboutData *about = new KAboutData(QStringLiteral("kcm_kwin_virtualdesktops"),
i18n("Virtual Desktops"),
QStringLiteral("2.0"), QString(), KAboutLicense::GPL);
setAboutData(about);
qmlRegisterAnonymousType<VirtualDesktopsSettings>("org.kde.kwin.kcm.desktop", 0); qmlRegisterAnonymousType<VirtualDesktopsSettings>("org.kde.kwin.kcm.desktop", 0);
setButtons(Apply | Default | Help); setButtons(Apply | Default | Help);

View file

@ -27,7 +27,7 @@ class VirtualDesktops : public KQuickAddons::ManagedConfigModule
Q_PROPERTY(VirtualDesktopsSettings *virtualDesktopsSettings READ virtualDesktopsSettings CONSTANT) Q_PROPERTY(VirtualDesktopsSettings *virtualDesktopsSettings READ virtualDesktopsSettings CONSTANT)
public: public:
explicit VirtualDesktops(QObject *parent = nullptr, const QVariantList &list = QVariantList()); explicit VirtualDesktops(QObject *parent, const KPluginMetaData &metaData, const QVariantList &list);
~VirtualDesktops() override; ~VirtualDesktops() override;
QAbstractItemModel *desktopsModel() const; QAbstractItemModel *desktopsModel() const;

View file

@ -9,7 +9,6 @@
#include "effectsfilterproxymodel.h" #include "effectsfilterproxymodel.h"
#include "effectsmodel.h" #include "effectsmodel.h"
#include <KAboutData>
#include <KLocalizedString> #include <KLocalizedString>
#include <KPluginFactory> #include <KPluginFactory>
@ -24,21 +23,12 @@ K_PLUGIN_FACTORY_WITH_JSON(DesktopEffectsKCMFactory,
namespace KWin namespace KWin
{ {
DesktopEffectsKCM::DesktopEffectsKCM(QObject *parent, const QVariantList &args) DesktopEffectsKCM::DesktopEffectsKCM(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
: KQuickAddons::ConfigModule(parent, args) : KQuickAddons::ConfigModule(parent, metaData, args)
, m_model(new EffectsModel(this)) , m_model(new EffectsModel(this))
{ {
qmlRegisterType<EffectsFilterProxyModel>("org.kde.private.kcms.kwin.effects", 1, 0, "EffectsFilterProxyModel"); qmlRegisterType<EffectsFilterProxyModel>("org.kde.private.kcms.kwin.effects", 1, 0, "EffectsFilterProxyModel");
auto about = new KAboutData(
QStringLiteral("kcm_kwin_effects"),
i18n("Desktop Effects"),
QStringLiteral("2.0"),
QString(),
KAboutLicense::GPL);
about->addAuthor(i18n("Vlad Zahorodnii"), QString(), QStringLiteral("vlad.zahorodnii@kde.org"));
setAboutData(about);
setButtons(Apply | Default | Help); setButtons(Apply | Default | Help);
connect(m_model, &EffectsModel::dataChanged, this, &DesktopEffectsKCM::updateNeedsSave); connect(m_model, &EffectsModel::dataChanged, this, &DesktopEffectsKCM::updateNeedsSave);

View file

@ -22,7 +22,7 @@ class DesktopEffectsKCM : public KQuickAddons::ConfigModule
Q_PROPERTY(QAbstractItemModel *effectsModel READ effectsModel CONSTANT) Q_PROPERTY(QAbstractItemModel *effectsModel READ effectsModel CONSTANT)
public: public:
explicit DesktopEffectsKCM(QObject *parent = nullptr, const QVariantList &list = {}); explicit DesktopEffectsKCM(QObject *parent, const KPluginMetaData &metaData, const QVariantList &list);
~DesktopEffectsKCM() override; ~DesktopEffectsKCM() override;
QAbstractItemModel *effectsModel() const; QAbstractItemModel *effectsModel() const;

View file

@ -11,7 +11,6 @@
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusMessage> #include <QDBusMessage>
#include <KAboutData>
#include <KConfig> #include <KConfig>
#include <KLocalizedString> #include <KLocalizedString>
#include <KPluginFactory> #include <KPluginFactory>
@ -19,21 +18,11 @@
namespace KWin namespace KWin
{ {
KCMKWinRules::KCMKWinRules(QObject *parent, const QVariantList &arguments) KCMKWinRules::KCMKWinRules(QObject *parent, const KPluginMetaData &metaData, const QVariantList &arguments)
: KQuickAddons::ConfigModule(parent, arguments) : KQuickAddons::ConfigModule(parent, metaData, arguments)
, m_ruleBookModel(new RuleBookModel(this)) , m_ruleBookModel(new RuleBookModel(this))
, m_rulesModel(new RulesModel(this)) , m_rulesModel(new RulesModel(this))
{ {
auto about = new KAboutData(QStringLiteral("kcm_kwinrules"),
i18n("Window Rules"),
QStringLiteral("1.0"),
QString(),
KAboutLicense::GPL);
about->addAuthor(i18n("Ismael Asensio"),
i18n("Author"),
QStringLiteral("isma.af@gmail.com"));
setAboutData(about);
setQuickHelp(i18n("<p><h1>Window-specific Settings</h1> Here you can customize window settings specifically only" setQuickHelp(i18n("<p><h1>Window-specific Settings</h1> Here you can customize window settings specifically only"
" for some windows.</p>" " for some windows.</p>"
" <p>Please note that this configuration will not take effect if you do not use" " <p>Please note that this configuration will not take effect if you do not use"

View file

@ -24,7 +24,7 @@ class KCMKWinRules : public KQuickAddons::ConfigModule
Q_PROPERTY(int editIndex READ editIndex NOTIFY editIndexChanged) Q_PROPERTY(int editIndex READ editIndex NOTIFY editIndexChanged)
public: public:
explicit KCMKWinRules(QObject *parent, const QVariantList &arguments); explicit KCMKWinRules(QObject *parent, const KPluginMetaData &metaData, const QVariantList &arguments);
Q_INVOKABLE void setRuleDescription(int index, const QString &description); Q_INVOKABLE void setRuleDescription(int index, const QString &description);
Q_INVOKABLE void editRule(int index); Q_INVOKABLE void editRule(int index);

View file

@ -6,7 +6,6 @@
#include "kcmvirtualkeyboard.h" #include "kcmvirtualkeyboard.h"
#include <KAboutData>
#include <KApplicationTrader> #include <KApplicationTrader>
#include <KConfigGroup> #include <KConfigGroup>
#include <KDesktopFile> #include <KDesktopFile>
@ -18,18 +17,12 @@
K_PLUGIN_FACTORY_WITH_JSON(KcmVirtualKeyboardFactory, "kcm_virtualkeyboard.json", registerPlugin<KcmVirtualKeyboard>(); registerPlugin<VirtualKeyboardData>();) K_PLUGIN_FACTORY_WITH_JSON(KcmVirtualKeyboardFactory, "kcm_virtualkeyboard.json", registerPlugin<KcmVirtualKeyboard>(); registerPlugin<VirtualKeyboardData>();)
KcmVirtualKeyboard::KcmVirtualKeyboard(QObject *parent, const QVariantList &args) KcmVirtualKeyboard::KcmVirtualKeyboard(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
: KQuickAddons::ManagedConfigModule(parent) : KQuickAddons::ManagedConfigModule(parent, metaData, args)
, m_data(new VirtualKeyboardData(this)) , m_data(new VirtualKeyboardData(this))
, m_model(new VirtualKeyboardsModel(this)) , m_model(new VirtualKeyboardsModel(this))
{ {
qmlRegisterAnonymousType<VirtualKeyboardSettings>("org.kde.kwin.virtualkeyboardsettings", 1); qmlRegisterAnonymousType<VirtualKeyboardSettings>("org.kde.kwin.virtualkeyboardsettings", 1);
setAboutData(new KAboutData(QStringLiteral("kcm_virtualkeyboard"),
i18n("Virtual Keyboard"),
QStringLiteral("1.0"),
i18n("Choose Virtual Keyboard"),
KAboutLicense::GPL));
} }
KcmVirtualKeyboard::~KcmVirtualKeyboard() = default; KcmVirtualKeyboard::~KcmVirtualKeyboard() = default;

View file

@ -42,7 +42,7 @@ class KcmVirtualKeyboard : public KQuickAddons::ManagedConfigModule
Q_PROPERTY(QAbstractItemModel *model READ keyboardsModel CONSTANT) Q_PROPERTY(QAbstractItemModel *model READ keyboardsModel CONSTANT)
public: public:
explicit KcmVirtualKeyboard(QObject *parent = nullptr, const QVariantList &list = QVariantList()); explicit KcmVirtualKeyboard(QObject *parent, const KPluginMetaData &metaData, const QVariantList &list);
~KcmVirtualKeyboard() override; ~KcmVirtualKeyboard() override;
VirtualKeyboardSettings *settings() const; VirtualKeyboardSettings *settings() const;

View file

@ -6,7 +6,6 @@
#include "kcmkwinxwayland.h" #include "kcmkwinxwayland.h"
#include <KAboutData>
#include <KApplicationTrader> #include <KApplicationTrader>
#include <KConfigGroup> #include <KConfigGroup>
#include <KDesktopFile> #include <KDesktopFile>
@ -18,19 +17,13 @@
K_PLUGIN_FACTORY_WITH_JSON(KcmXwaylandFactory, "kcm_kwinxwayland.json", registerPlugin<KcmXwayland>(); registerPlugin<KWinXwaylandData>();) K_PLUGIN_FACTORY_WITH_JSON(KcmXwaylandFactory, "kcm_kwinxwayland.json", registerPlugin<KcmXwayland>(); registerPlugin<KWinXwaylandData>();)
KcmXwayland::KcmXwayland(QObject *parent, const QVariantList &args) KcmXwayland::KcmXwayland(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
: KQuickAddons::ManagedConfigModule(parent) : KQuickAddons::ManagedConfigModule(parent, metaData, args)
, m_data(new KWinXwaylandData(this)) , m_data(new KWinXwaylandData(this))
, m_settings(new KWinXwaylandSettings(m_data)) , m_settings(new KWinXwaylandSettings(m_data))
{ {
registerSettings(m_settings); registerSettings(m_settings);
qmlRegisterAnonymousType<KWinXwaylandSettings>("org.kde.kwin.kwinxwaylandsettings", 1); qmlRegisterAnonymousType<KWinXwaylandSettings>("org.kde.kwin.kwinxwaylandsettings", 1);
setAboutData(new KAboutData(QStringLiteral("kcm_kwinxwayland"),
i18n("Legacy X11 App Support"),
QStringLiteral("1.0"),
i18n("Allow legacy X11 apps to read keystrokes typed in other apps"),
KAboutLicense::GPL));
} }
KcmXwayland::~KcmXwayland() = default; KcmXwayland::~KcmXwayland() = default;

View file

@ -19,7 +19,7 @@ class KcmXwayland : public KQuickAddons::ManagedConfigModule
Q_PROPERTY(KWinXwaylandSettings *settings READ settings CONSTANT) Q_PROPERTY(KWinXwaylandSettings *settings READ settings CONSTANT)
public: public:
explicit KcmXwayland(QObject *parent = nullptr, const QVariantList &list = QVariantList()); explicit KcmXwayland(QObject *parent, const KPluginMetaData &metaData, const QVariantList &list);
~KcmXwayland() override; ~KcmXwayland() override;
KWinXwaylandSettings *settings() const KWinXwaylandSettings *settings() const