2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2013 Antonis Tsiapaliokas <kok3rs@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
#include "effectsmodel.h"
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
|
|
|
#include <config-kwin.h>
|
|
|
|
#include <effect_builtins.h>
|
|
|
|
#include <kwin_effects_interface.h>
|
|
|
|
|
|
|
|
#include <KAboutData>
|
2019-02-03 15:18:42 +00:00
|
|
|
#include <KCModule>
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
#include <KLocalizedString>
|
|
|
|
#include <KPackage/PackageLoader>
|
|
|
|
#include <KPluginLoader>
|
|
|
|
#include <KPluginMetaData>
|
|
|
|
#include <KPluginTrader>
|
|
|
|
|
|
|
|
#include <QDBusConnection>
|
|
|
|
#include <QDBusInterface>
|
|
|
|
#include <QDBusMessage>
|
|
|
|
#include <QDBusPendingCall>
|
2019-02-03 15:18:42 +00:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
static QString translatedCategory(const QString &category)
|
|
|
|
{
|
|
|
|
static const QVector<QString> knownCategories = {
|
|
|
|
QStringLiteral("Accessibility"),
|
|
|
|
QStringLiteral("Appearance"),
|
|
|
|
QStringLiteral("Focus"),
|
|
|
|
QStringLiteral("Show Desktop Animation"),
|
|
|
|
QStringLiteral("Tools"),
|
|
|
|
QStringLiteral("Virtual Desktop Switching Animation"),
|
|
|
|
QStringLiteral("Window Management"),
|
|
|
|
QStringLiteral("Window Open/Close Animation")
|
|
|
|
};
|
|
|
|
|
|
|
|
static const QVector<QString> translatedCategories = {
|
|
|
|
i18nc("Category of Desktop Effects, used as section header", "Accessibility"),
|
|
|
|
i18nc("Category of Desktop Effects, used as section header", "Appearance"),
|
|
|
|
i18nc("Category of Desktop Effects, used as section header", "Focus"),
|
|
|
|
i18nc("Category of Desktop Effects, used as section header", "Show Desktop Animation"),
|
|
|
|
i18nc("Category of Desktop Effects, used as section header", "Tools"),
|
|
|
|
i18nc("Category of Desktop Effects, used as section header", "Virtual Desktop Switching Animation"),
|
|
|
|
i18nc("Category of Desktop Effects, used as section header", "Window Management"),
|
|
|
|
i18nc("Category of Desktop Effects, used as section header", "Window Open/Close Animation")
|
|
|
|
};
|
|
|
|
|
|
|
|
const int index = knownCategories.indexOf(category);
|
|
|
|
if (index == -1) {
|
|
|
|
qDebug() << "Unknown category '" << category << "' and thus not translated";
|
|
|
|
return category;
|
|
|
|
}
|
|
|
|
|
|
|
|
return translatedCategories[index];
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
static EffectsModel::Status effectStatus(bool enabled)
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
2019-02-03 20:04:09 +00:00
|
|
|
return enabled ? EffectsModel::Status::Enabled : EffectsModel::Status::Disabled;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
EffectsModel::EffectsModel(QObject *parent)
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
: QAbstractItemModel(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
QHash<int, QByteArray> EffectsModel::roleNames() const
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
QHash<int, QByteArray> roleNames;
|
|
|
|
roleNames[NameRole] = "NameRole";
|
|
|
|
roleNames[DescriptionRole] = "DescriptionRole";
|
|
|
|
roleNames[AuthorNameRole] = "AuthorNameRole";
|
|
|
|
roleNames[AuthorEmailRole] = "AuthorEmailRole";
|
|
|
|
roleNames[LicenseRole] = "LicenseRole";
|
|
|
|
roleNames[VersionRole] = "VersionRole";
|
|
|
|
roleNames[CategoryRole] = "CategoryRole";
|
|
|
|
roleNames[ServiceNameRole] = "ServiceNameRole";
|
|
|
|
roleNames[IconNameRole] = "IconNameRole";
|
2019-02-03 17:19:16 +00:00
|
|
|
roleNames[StatusRole] = "StatusRole";
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
roleNames[VideoRole] = "VideoRole";
|
|
|
|
roleNames[WebsiteRole] = "WebsiteRole";
|
|
|
|
roleNames[SupportedRole] = "SupportedRole";
|
|
|
|
roleNames[ExclusiveRole] = "ExclusiveRole";
|
|
|
|
roleNames[ConfigurableRole] = "ConfigurableRole";
|
|
|
|
roleNames[ScriptedRole] = QByteArrayLiteral("ScriptedRole");
|
|
|
|
roleNames[EnabledByDefaultRole] = "EnabledByDefaultRole";
|
2020-09-30 11:53:44 +00:00
|
|
|
roleNames[ConfigModuleRole] = "ConfigModuleRole";
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
return roleNames;
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
QModelIndex EffectsModel::index(int row, int column, const QModelIndex &parent) const
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
2019-02-03 20:27:47 +00:00
|
|
|
if (parent.isValid() || column > 0 || column < 0 || row < 0 || row >= m_effects.count()) {
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
return createIndex(row, column);
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
QModelIndex EffectsModel::parent(const QModelIndex &child) const
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(child)
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
int EffectsModel::columnCount(const QModelIndex &parent) const
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(parent)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
int EffectsModel::rowCount(const QModelIndex &parent) const
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
if (parent.isValid()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2019-02-03 20:27:47 +00:00
|
|
|
return m_effects.count();
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
QVariant EffectsModel::data(const QModelIndex &index, int role) const
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
if (!index.isValid()) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:27:47 +00:00
|
|
|
const EffectData effect = m_effects.at(index.row());
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
switch (role) {
|
|
|
|
case Qt::DisplayRole:
|
|
|
|
case NameRole:
|
|
|
|
return effect.name;
|
|
|
|
case DescriptionRole:
|
|
|
|
return effect.description;
|
|
|
|
case AuthorNameRole:
|
|
|
|
return effect.authorName;
|
|
|
|
case AuthorEmailRole:
|
|
|
|
return effect.authorEmail;
|
|
|
|
case LicenseRole:
|
|
|
|
return effect.license;
|
|
|
|
case VersionRole:
|
|
|
|
return effect.version;
|
|
|
|
case CategoryRole:
|
|
|
|
return effect.category;
|
|
|
|
case ServiceNameRole:
|
|
|
|
return effect.serviceName;
|
|
|
|
case IconNameRole:
|
|
|
|
return effect.iconName;
|
2019-02-03 17:19:16 +00:00
|
|
|
case StatusRole:
|
|
|
|
return static_cast<int>(effect.status);
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
case VideoRole:
|
|
|
|
return effect.video;
|
|
|
|
case WebsiteRole:
|
|
|
|
return effect.website;
|
|
|
|
case SupportedRole:
|
|
|
|
return effect.supported;
|
|
|
|
case ExclusiveRole:
|
|
|
|
return effect.exclusiveGroup;
|
|
|
|
case InternalRole:
|
|
|
|
return effect.internal;
|
|
|
|
case ConfigurableRole:
|
|
|
|
return effect.configurable;
|
|
|
|
case ScriptedRole:
|
|
|
|
return effect.kind == Kind::Scripted;
|
|
|
|
case EnabledByDefaultRole:
|
|
|
|
return effect.enabledByDefault;
|
2020-09-30 11:53:44 +00:00
|
|
|
case ConfigModuleRole:
|
|
|
|
return effect.configModule;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
default:
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
bool EffectsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
if (!index.isValid()) {
|
|
|
|
return QAbstractItemModel::setData(index, value, role);
|
|
|
|
}
|
|
|
|
|
2019-02-03 17:19:16 +00:00
|
|
|
if (role == StatusRole) {
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
// note: whenever the StatusRole is modified (even to the same value) the entry
|
|
|
|
// gets marked as changed and will get saved to the config file. This means the
|
|
|
|
// config file could get polluted
|
2019-02-03 20:27:47 +00:00
|
|
|
EffectData &data = m_effects[index.row()];
|
2019-02-03 17:19:16 +00:00
|
|
|
data.status = Status(value.toInt());
|
|
|
|
data.changed = data.status != data.originalStatus;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
emit dataChanged(index, index);
|
|
|
|
|
2019-02-03 17:19:16 +00:00
|
|
|
if (data.status == Status::Enabled && !data.exclusiveGroup.isEmpty()) {
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
// need to disable all other exclusive effects in the same category
|
2019-02-03 20:27:47 +00:00
|
|
|
for (int i = 0; i < m_effects.size(); ++i) {
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
if (i == index.row()) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-02-03 20:27:47 +00:00
|
|
|
EffectData &otherData = m_effects[i];
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
if (otherData.exclusiveGroup == data.exclusiveGroup) {
|
2019-02-03 17:19:16 +00:00
|
|
|
otherData.status = Status::Disabled;
|
|
|
|
otherData.changed = otherData.status != otherData.originalStatus;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
emit dataChanged(this->index(i, 0), this->index(i, 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QAbstractItemModel::setData(index, value, role);
|
|
|
|
}
|
|
|
|
|
2020-09-30 11:53:44 +00:00
|
|
|
void EffectsModel::loadBuiltInEffects(const KConfigGroup &kwinConfig)
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
const auto builtins = BuiltInEffects::availableEffects();
|
|
|
|
for (auto builtin : builtins) {
|
|
|
|
const BuiltInEffects::EffectData &data = BuiltInEffects::effectData(builtin);
|
|
|
|
EffectData effect;
|
|
|
|
effect.name = data.displayName;
|
|
|
|
effect.description = data.comment;
|
|
|
|
effect.authorName = i18n("KWin development team");
|
|
|
|
effect.authorEmail = QString(); // not used at all
|
|
|
|
effect.license = QStringLiteral("GPL");
|
|
|
|
effect.version = QStringLiteral(KWIN_VERSION_STRING);
|
|
|
|
effect.untranslatedCategory = data.category;
|
|
|
|
effect.category = translatedCategory(data.category);
|
|
|
|
effect.serviceName = data.name;
|
|
|
|
effect.iconName = QStringLiteral("preferences-system-windows");
|
|
|
|
effect.enabledByDefault = data.enabled;
|
|
|
|
effect.enabledByDefaultFunction = (data.enabledFunction != nullptr);
|
|
|
|
const QString enabledKey = QStringLiteral("%1Enabled").arg(effect.serviceName);
|
|
|
|
if (kwinConfig.hasKey(enabledKey)) {
|
2019-02-03 17:19:16 +00:00
|
|
|
effect.status = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", effect.enabledByDefault));
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
} else if (data.enabledFunction != nullptr) {
|
2019-02-03 17:19:16 +00:00
|
|
|
effect.status = Status::EnabledUndeterminded;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
} else {
|
2019-02-03 17:19:16 +00:00
|
|
|
effect.status = effectStatus(effect.enabledByDefault);
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
2019-02-03 17:19:16 +00:00
|
|
|
effect.originalStatus = effect.status;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
effect.video = data.video;
|
|
|
|
effect.website = QUrl();
|
|
|
|
effect.supported = true;
|
|
|
|
effect.exclusiveGroup = data.exclusiveCategory;
|
|
|
|
effect.internal = data.internal;
|
|
|
|
effect.kind = Kind::BuiltIn;
|
2020-09-30 11:53:44 +00:00
|
|
|
effect.configModule = data.configModule;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
2020-09-30 11:53:44 +00:00
|
|
|
effect.configurable = !effect.configModule.isEmpty();
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
|
|
|
if (shouldStore(effect)) {
|
2019-02-04 14:20:33 +00:00
|
|
|
m_pendingEffects << effect;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
void EffectsModel::loadJavascriptEffects(const KConfigGroup &kwinConfig)
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
const auto plugins = KPackage::PackageLoader::self()->listPackages(
|
|
|
|
QStringLiteral("KWin/Effect"),
|
|
|
|
QStringLiteral("kwin/effects")
|
|
|
|
);
|
|
|
|
for (const KPluginMetaData &metaData : plugins) {
|
|
|
|
KPluginInfo plugin(metaData);
|
|
|
|
EffectData effect;
|
|
|
|
|
|
|
|
effect.name = plugin.name();
|
|
|
|
effect.description = plugin.comment();
|
|
|
|
effect.authorName = plugin.author();
|
|
|
|
effect.authorEmail = plugin.email();
|
|
|
|
effect.license = plugin.license();
|
|
|
|
effect.version = plugin.version();
|
|
|
|
effect.untranslatedCategory = plugin.category();
|
|
|
|
effect.category = translatedCategory(plugin.category());
|
|
|
|
effect.serviceName = plugin.pluginName();
|
|
|
|
effect.iconName = plugin.icon();
|
2019-02-03 17:19:16 +00:00
|
|
|
effect.status = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", plugin.isPluginEnabledByDefault()));
|
|
|
|
effect.originalStatus = effect.status;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
effect.enabledByDefault = plugin.isPluginEnabledByDefault();
|
|
|
|
effect.enabledByDefaultFunction = false;
|
|
|
|
effect.video = plugin.property(QStringLiteral("X-KWin-Video-Url")).toUrl();
|
2019-02-12 07:54:41 +00:00
|
|
|
effect.website = QUrl(plugin.website());
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
effect.supported = true;
|
|
|
|
effect.exclusiveGroup = plugin.property(QStringLiteral("X-KWin-Exclusive-Category")).toString();
|
|
|
|
effect.internal = plugin.property(QStringLiteral("X-KWin-Internal")).toBool();
|
|
|
|
effect.kind = Kind::Scripted;
|
|
|
|
|
|
|
|
const QString pluginKeyword = plugin.property(QStringLiteral("X-KDE-PluginKeyword")).toString();
|
|
|
|
if (!pluginKeyword.isEmpty()) {
|
|
|
|
// scripted effects have their pluginName() as the keyword
|
|
|
|
effect.configurable = plugin.property(QStringLiteral("X-KDE-ParentComponents")).toString() == pluginKeyword;
|
|
|
|
} else {
|
|
|
|
effect.configurable = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shouldStore(effect)) {
|
2019-02-04 14:20:33 +00:00
|
|
|
m_pendingEffects << effect;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 11:53:44 +00:00
|
|
|
void EffectsModel::loadPluginEffects(const KConfigGroup &kwinConfig)
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
const auto pluginEffects = KPluginLoader::findPlugins(
|
|
|
|
QStringLiteral("kwin/effects/plugins/"),
|
|
|
|
[](const KPluginMetaData &data) {
|
|
|
|
return data.serviceTypes().contains(QStringLiteral("KWin/Effect"));
|
|
|
|
}
|
|
|
|
);
|
|
|
|
for (const KPluginMetaData &pluginEffect : pluginEffects) {
|
|
|
|
if (!pluginEffect.isValid()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
EffectData effect;
|
|
|
|
effect.name = pluginEffect.name();
|
|
|
|
effect.description = pluginEffect.description();
|
|
|
|
effect.license = pluginEffect.license();
|
|
|
|
effect.version = pluginEffect.version();
|
|
|
|
effect.untranslatedCategory = pluginEffect.category();
|
|
|
|
effect.category = translatedCategory(pluginEffect.category());
|
|
|
|
effect.serviceName = pluginEffect.pluginId();
|
|
|
|
effect.iconName = pluginEffect.iconName();
|
|
|
|
effect.enabledByDefault = pluginEffect.isEnabledByDefault();
|
|
|
|
effect.supported = true;
|
|
|
|
effect.enabledByDefaultFunction = false;
|
|
|
|
effect.internal = false;
|
|
|
|
effect.kind = Kind::Binary;
|
2020-09-30 11:53:44 +00:00
|
|
|
effect.configModule = pluginEffect.value(QStringLiteral("X-KDE-ConfigModule"));
|
|
|
|
|
|
|
|
// Compatibility with plugins that don't have ConfigModule in their metadata
|
|
|
|
// TODO KF6 remove
|
|
|
|
if (effect.configModule.isEmpty()) {
|
|
|
|
|
|
|
|
const QList<KPluginInfo> infos = KPluginTrader::self()->query(
|
|
|
|
QStringLiteral("kwin/effects/configs/"),
|
|
|
|
QString(),
|
|
|
|
QStringLiteral("'%1' in [X-KDE-ParentComponents]").arg(pluginEffect.pluginId())
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!infos.isEmpty()) {
|
|
|
|
effect.configModule = infos.first().pluginName();
|
|
|
|
}
|
|
|
|
}
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < pluginEffect.authors().count(); ++i) {
|
|
|
|
effect.authorName.append(pluginEffect.authors().at(i).name());
|
|
|
|
effect.authorEmail.append(pluginEffect.authors().at(i).emailAddress());
|
|
|
|
if (i+1 < pluginEffect.authors().count()) {
|
|
|
|
effect.authorName.append(", ");
|
|
|
|
effect.authorEmail.append(", ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pluginEffect.rawData().contains("org.kde.kwin.effect")) {
|
|
|
|
const QJsonObject d(pluginEffect.rawData().value("org.kde.kwin.effect").toObject());
|
|
|
|
effect.exclusiveGroup = d.value("exclusiveGroup").toString();
|
|
|
|
effect.video = QUrl::fromUserInput(d.value("video").toString());
|
|
|
|
effect.enabledByDefaultFunction = d.value("enabledByDefaultMethod").toBool();
|
|
|
|
}
|
|
|
|
|
2019-02-12 07:54:41 +00:00
|
|
|
effect.website = QUrl(pluginEffect.website());
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
|
|
|
const QString enabledKey = QStringLiteral("%1Enabled").arg(effect.serviceName);
|
|
|
|
if (kwinConfig.hasKey(enabledKey)) {
|
2019-02-03 17:19:16 +00:00
|
|
|
effect.status = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", effect.enabledByDefault));
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
} else if (effect.enabledByDefaultFunction) {
|
2019-02-03 17:19:16 +00:00
|
|
|
effect.status = Status::EnabledUndeterminded;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
} else {
|
2019-02-03 17:19:16 +00:00
|
|
|
effect.status = effectStatus(effect.enabledByDefault);
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
|
2019-02-03 17:19:16 +00:00
|
|
|
effect.originalStatus = effect.status;
|
2019-02-02 20:49:38 +00:00
|
|
|
|
2020-09-30 11:53:44 +00:00
|
|
|
effect.configurable = !effect.configModule.isEmpty();
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
|
|
|
if (shouldStore(effect)) {
|
2019-02-04 14:20:33 +00:00
|
|
|
m_pendingEffects << effect;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
void EffectsModel::load(LoadOptions options)
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins");
|
|
|
|
|
2019-02-04 14:20:33 +00:00
|
|
|
m_pendingEffects.clear();
|
2020-09-30 11:53:44 +00:00
|
|
|
loadBuiltInEffects(kwinConfig);
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
loadJavascriptEffects(kwinConfig);
|
2020-09-30 11:53:44 +00:00
|
|
|
loadPluginEffects(kwinConfig);
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
2019-07-09 21:00:07 +00:00
|
|
|
std::sort(m_pendingEffects.begin(), m_pendingEffects.end(),
|
2019-02-04 14:20:33 +00:00
|
|
|
[](const EffectData &a, const EffectData &b) {
|
|
|
|
if (a.category == b.category) {
|
|
|
|
if (a.exclusiveGroup == b.exclusiveGroup) {
|
|
|
|
return a.name < b.name;
|
2019-02-03 16:06:05 +00:00
|
|
|
}
|
2019-02-04 14:20:33 +00:00
|
|
|
return a.exclusiveGroup < b.exclusiveGroup;
|
2019-02-03 16:06:05 +00:00
|
|
|
}
|
2019-02-04 14:20:33 +00:00
|
|
|
return a.category < b.category;
|
2019-02-03 16:06:05 +00:00
|
|
|
}
|
2019-02-04 14:20:33 +00:00
|
|
|
);
|
2019-02-03 16:06:05 +00:00
|
|
|
|
2019-02-04 14:20:33 +00:00
|
|
|
auto commit = [this, options] {
|
|
|
|
if (options == LoadOptions::KeepDirty) {
|
|
|
|
for (const EffectData &oldEffect : m_effects) {
|
|
|
|
if (!oldEffect.changed) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
auto effectIt = std::find_if(m_pendingEffects.begin(), m_pendingEffects.end(),
|
|
|
|
[oldEffect](const EffectData &data) {
|
|
|
|
return data.serviceName == oldEffect.serviceName;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
if (effectIt == m_pendingEffects.end()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
effectIt->status = oldEffect.status;
|
|
|
|
effectIt->changed = effectIt->status != effectIt->originalStatus;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-02-04 14:20:33 +00:00
|
|
|
|
|
|
|
beginResetModel();
|
|
|
|
m_effects = m_pendingEffects;
|
|
|
|
m_pendingEffects.clear();
|
|
|
|
endResetModel();
|
|
|
|
|
|
|
|
emit loaded();
|
|
|
|
};
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
|
|
|
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
|
|
|
QStringLiteral("/Effects"),
|
|
|
|
QDBusConnection::sessionBus());
|
|
|
|
|
|
|
|
if (interface.isValid()) {
|
|
|
|
QStringList effectNames;
|
2019-02-04 14:20:33 +00:00
|
|
|
effectNames.reserve(m_pendingEffects.count());
|
|
|
|
for (const EffectData &data : m_pendingEffects) {
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
effectNames.append(data.serviceName);
|
|
|
|
}
|
|
|
|
|
2019-02-04 14:20:33 +00:00
|
|
|
const int serial = ++m_lastSerial;
|
|
|
|
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(interface.areEffectsSupported(effectNames), this);
|
2019-02-04 14:20:33 +00:00
|
|
|
connect(watcher, &QDBusPendingCallWatcher::finished, this,
|
|
|
|
[=](QDBusPendingCallWatcher *self) {
|
|
|
|
self->deleteLater();
|
|
|
|
|
|
|
|
if (m_lastSerial != serial) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QDBusPendingReply<QList<bool > > reply = *self;
|
|
|
|
if (reply.isError()) {
|
|
|
|
commit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QList<bool> supportedValues = reply.value();
|
|
|
|
if (supportedValues.count() != effectNames.count()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
for (int i = 0; i < effectNames.size(); ++i) {
|
2019-02-04 14:20:33 +00:00
|
|
|
const bool supported = supportedValues.at(i);
|
|
|
|
const QString effectName = effectNames.at(i);
|
|
|
|
|
|
|
|
auto it = std::find_if(m_pendingEffects.begin(), m_pendingEffects.end(),
|
|
|
|
[effectName](const EffectData &data) {
|
|
|
|
return data.serviceName == effectName;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
2019-02-04 14:20:33 +00:00
|
|
|
);
|
|
|
|
if (it == m_pendingEffects.end()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*it).supported != supported) {
|
|
|
|
(*it).supported = supported;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-02-04 14:20:33 +00:00
|
|
|
|
|
|
|
commit();
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
2019-02-04 14:20:33 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
commit();
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
void EffectsModel::updateEffectStatus(const QModelIndex &rowIndex, Status effectState)
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
2019-02-03 17:19:16 +00:00
|
|
|
setData(rowIndex, static_cast<int>(effectState), StatusRole);
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
void EffectsModel::save()
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins");
|
|
|
|
|
2019-02-03 16:44:06 +00:00
|
|
|
QVector<EffectData> dirtyEffects;
|
|
|
|
|
2019-02-03 20:27:47 +00:00
|
|
|
for (EffectData &effect : m_effects) {
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
if (!effect.changed) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-02-03 16:44:06 +00:00
|
|
|
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
effect.changed = false;
|
2019-02-03 17:19:16 +00:00
|
|
|
effect.originalStatus = effect.status;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
|
|
|
|
const QString key = effect.serviceName + QStringLiteral("Enabled");
|
2019-02-03 17:19:16 +00:00
|
|
|
const bool shouldEnable = (effect.status != Status::Disabled);
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
const bool restoreToDefault = effect.enabledByDefaultFunction
|
2019-02-03 17:19:16 +00:00
|
|
|
? effect.status == Status::EnabledUndeterminded
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
: shouldEnable == effect.enabledByDefault;
|
|
|
|
if (restoreToDefault) {
|
|
|
|
kwinConfig.deleteEntry(key);
|
|
|
|
} else {
|
|
|
|
kwinConfig.writeEntry(key, shouldEnable);
|
|
|
|
}
|
2019-02-03 16:44:06 +00:00
|
|
|
|
|
|
|
dirtyEffects.append(effect);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dirtyEffects.isEmpty()) {
|
|
|
|
return;
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
kwinConfig.sync();
|
2019-02-03 16:44:06 +00:00
|
|
|
|
|
|
|
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
|
|
|
QStringLiteral("/Effects"),
|
|
|
|
QDBusConnection::sessionBus());
|
|
|
|
|
|
|
|
if (!interface.isValid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const EffectData &effect : dirtyEffects) {
|
2019-02-03 17:19:16 +00:00
|
|
|
if (effect.status != Status::Disabled) {
|
2019-02-03 16:44:06 +00:00
|
|
|
interface.loadEffect(effect.serviceName);
|
|
|
|
} else {
|
|
|
|
interface.unloadEffect(effect.serviceName);
|
|
|
|
}
|
|
|
|
}
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
void EffectsModel::defaults()
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
2019-02-03 20:27:47 +00:00
|
|
|
for (int i = 0; i < m_effects.count(); ++i) {
|
|
|
|
const auto &effect = m_effects.at(i);
|
2019-02-03 17:19:16 +00:00
|
|
|
if (effect.enabledByDefaultFunction && effect.status != Status::EnabledUndeterminded) {
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
updateEffectStatus(index(i, 0), Status::EnabledUndeterminded);
|
2019-12-30 08:39:25 +00:00
|
|
|
} else if (static_cast<bool>(effect.status) != effect.enabledByDefault) {
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
updateEffectStatus(index(i, 0), effect.enabledByDefault ? Status::Enabled : Status::Disabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-16 09:23:18 +00:00
|
|
|
bool EffectsModel::isDefaults() const
|
|
|
|
{
|
|
|
|
return std::all_of(m_effects.constBegin(), m_effects.constEnd(), [](const EffectData &effect) {
|
|
|
|
if (effect.enabledByDefaultFunction && effect.status != Status::EnabledUndeterminded) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-12-30 08:39:25 +00:00
|
|
|
if (static_cast<bool>(effect.status) != effect.enabledByDefault) {
|
2019-12-16 09:23:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
bool EffectsModel::needsSave() const
|
2019-02-02 20:49:38 +00:00
|
|
|
{
|
2019-02-03 20:27:47 +00:00
|
|
|
return std::any_of(m_effects.constBegin(), m_effects.constEnd(),
|
2019-02-02 20:49:38 +00:00
|
|
|
[](const EffectData &data) {
|
|
|
|
return data.changed;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
QModelIndex EffectsModel::findByPluginId(const QString &pluginId) const
|
2019-02-02 20:49:38 +00:00
|
|
|
{
|
2019-02-03 20:27:47 +00:00
|
|
|
auto it = std::find_if(m_effects.constBegin(), m_effects.constEnd(),
|
2019-02-02 20:49:38 +00:00
|
|
|
[pluginId](const EffectData &data) {
|
|
|
|
return data.serviceName == pluginId;
|
|
|
|
}
|
|
|
|
);
|
2019-02-03 20:27:47 +00:00
|
|
|
if (it == m_effects.constEnd()) {
|
2019-02-02 20:49:38 +00:00
|
|
|
return {};
|
|
|
|
}
|
2019-02-03 20:27:47 +00:00
|
|
|
return index(std::distance(m_effects.constBegin(), it), 0);
|
2019-02-02 20:49:38 +00:00
|
|
|
}
|
|
|
|
|
2020-09-30 11:53:44 +00:00
|
|
|
static KCModule *loadBinaryConfig(const QString &configModule, QObject *parent)
|
2019-02-03 15:18:42 +00:00
|
|
|
{
|
2020-09-30 11:53:44 +00:00
|
|
|
const QVector<KPluginMetaData> offers = KPluginLoader::findPluginsById(QStringLiteral("kwin/effects/configs/"), configModule);
|
|
|
|
|
|
|
|
if (offers.isEmpty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
KPluginLoader loader(offers.first().fileName());
|
|
|
|
KPluginFactory *factory = loader.factory();
|
|
|
|
|
|
|
|
return factory->create<KCModule>(parent);
|
2019-02-03 15:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static KCModule *findScriptedConfig(const QString &pluginId, QObject *parent)
|
|
|
|
{
|
2020-09-30 11:17:04 +00:00
|
|
|
const QVector<KPluginMetaData> offers = KPluginLoader::findPluginsById(QStringLiteral("kwin/effects/configs/"), QStringLiteral("kcm_kwin4_genericscripted"));
|
2019-02-03 15:18:42 +00:00
|
|
|
|
|
|
|
if (offers.isEmpty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-09-30 11:17:04 +00:00
|
|
|
const KPluginMetaData &generic = offers.first();
|
|
|
|
KPluginLoader loader(generic.fileName());
|
2019-02-03 15:18:42 +00:00
|
|
|
KPluginFactory *factory = loader.factory();
|
|
|
|
if (!factory) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return factory->create<KCModule>(pluginId, parent);
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
void EffectsModel::requestConfigure(const QModelIndex &index, QWindow *transientParent)
|
2019-02-03 15:18:42 +00:00
|
|
|
{
|
|
|
|
if (!index.isValid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-03-30 16:27:11 +00:00
|
|
|
auto dialog = new QDialog();
|
2019-02-03 15:18:42 +00:00
|
|
|
|
2020-09-30 11:53:44 +00:00
|
|
|
const bool scripted = index.data(ScriptedRole).toBool();
|
|
|
|
|
|
|
|
KCModule *module = nullptr;
|
|
|
|
|
|
|
|
if (scripted) {
|
|
|
|
module = findScriptedConfig(index.data(ServiceNameRole).toString(), dialog);
|
|
|
|
} else {
|
|
|
|
const QString configModule = index.data(ConfigModuleRole).toString();
|
|
|
|
module = loadBinaryConfig(configModule, dialog);
|
|
|
|
}
|
|
|
|
|
2019-02-03 15:18:42 +00:00
|
|
|
if (!module) {
|
|
|
|
delete dialog;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog->setWindowTitle(index.data(NameRole).toString());
|
|
|
|
dialog->winId();
|
|
|
|
dialog->windowHandle()->setTransientParent(transientParent);
|
|
|
|
|
|
|
|
auto buttons = new QDialogButtonBox(
|
|
|
|
QDialogButtonBox::Ok |
|
|
|
|
QDialogButtonBox::Cancel |
|
|
|
|
QDialogButtonBox::RestoreDefaults,
|
|
|
|
dialog
|
|
|
|
);
|
|
|
|
connect(buttons, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
|
|
|
|
connect(buttons, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
|
|
|
|
connect(buttons->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked,
|
|
|
|
module, &KCModule::defaults);
|
2019-12-16 09:23:18 +00:00
|
|
|
connect(module, &KCModule::defaulted, this, [=](bool defaulted) {
|
|
|
|
buttons->button(QDialogButtonBox::RestoreDefaults)->setEnabled(!defaulted);
|
|
|
|
});
|
2019-02-03 15:18:42 +00:00
|
|
|
|
|
|
|
auto layout = new QVBoxLayout(dialog);
|
|
|
|
layout->addWidget(module);
|
|
|
|
layout->addWidget(buttons);
|
|
|
|
|
2020-03-30 16:35:47 +00:00
|
|
|
connect(dialog, &QDialog::accepted, module, &KCModule::save);
|
2019-02-03 15:18:42 +00:00
|
|
|
|
2020-03-30 16:27:11 +00:00
|
|
|
dialog->setModal(true);
|
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
dialog->show();
|
2019-02-03 15:18:42 +00:00
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
bool EffectsModel::shouldStore(const EffectData &data) const
|
[kcmkwin] Move effects model into a shared library
Summary:
The main motivation for moving it into a shared library is to share the
model between Desktop Effects and Virtual Desktops KCM.
The extracted model is quite the same as the one in Desktop Effects KCM,
except some minor changes, e.g. rename loadEffect and syncConfig to more
convenient names, add comments, some whitespace changes, fix coding
style in some parts, etc.
Test Plan: effectModelTest passes, Desktop Effects KCM works.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: hein, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17765
2018-12-22 10:50:28 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(data)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|