2013-06-25 14:07:48 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* KWin - the KDE window manager *
|
|
|
|
* This file is part of the KDE project. *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2013 Antonis Tsiapaliokas <kok3rs@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
#include "model.h"
|
2013-08-07 16:52:45 +00:00
|
|
|
#include "effectconfig.h"
|
2013-08-17 08:28:09 +00:00
|
|
|
#include "compositing.h"
|
2014-04-03 14:20:26 +00:00
|
|
|
#include <config-kwin.h>
|
2014-03-07 13:41:05 +00:00
|
|
|
#include <kwin_effects_interface.h>
|
2014-04-03 14:20:26 +00:00
|
|
|
#include <effect_builtins.h>
|
2013-08-17 08:28:09 +00:00
|
|
|
|
2014-03-27 12:01:02 +00:00
|
|
|
#include <KLocalizedString>
|
2014-01-08 17:06:08 +00:00
|
|
|
#include <KSharedConfig>
|
|
|
|
#include <KCModuleProxy>
|
[effects] Make scripted effects GHNS-able
Summary:
Currently, if one wants to install a scripted effect from the KDE Store,
the effect won't show up in the Desktop Effects KCM. The reason for that
is kpackagetool5 doesn't know where to install effects (they have to be
installed under ${DATA_DIR}/kwin/effects).
Another problem is that even if the scripted effect is installed in the
right directory (e.g. ~/.local/share/kwin/effects), it won't be listed in
the Desktop Effects KCM because it doesn't have a desktop file in
kservices5 dir. Please notice that the effect will be "visible" for KWin, i.e.
you can enable it by editing kwinrc.
This diff addresses those 2 problems by:
* Adding a PackageStructure plugin for effects (so they are installed
under kwin/effects/);
* Using KPackage::PackageLoader to get list of scripted effect in the
Desktop Effects KCM.
Test Plan:
* Installed an effect from the KDE Store, it appeared in the Desktop Effects
KCM;
* Removed it.
Reviewers: #kwin, mart, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: ngraham, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15372
2018-09-09 09:28:58 +00:00
|
|
|
#include <KPackage/PackageLoader>
|
2014-03-17 12:13:17 +00:00
|
|
|
#include <KPluginTrader>
|
2014-05-26 09:32:52 +00:00
|
|
|
#include <kdeclarative/kdeclarative.h>
|
2015-09-18 13:23:50 +00:00
|
|
|
#include <KPluginLoader>
|
|
|
|
#include <KPluginMetaData>
|
|
|
|
#include <KAboutData>
|
2013-06-25 14:07:48 +00:00
|
|
|
|
|
|
|
#include <QAbstractItemModel>
|
2013-07-31 13:00:03 +00:00
|
|
|
#include <QDBusConnection>
|
2013-08-08 13:47:01 +00:00
|
|
|
#include <QDBusInterface>
|
|
|
|
#include <QDBusPendingCall>
|
2013-07-31 13:00:03 +00:00
|
|
|
#include <QDBusMessage>
|
2013-06-25 14:07:48 +00:00
|
|
|
#include <QHash>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
|
|
|
#include <QQmlEngine>
|
|
|
|
#include <QtQml>
|
2013-12-02 10:26:37 +00:00
|
|
|
#include <QQuickItem>
|
2013-06-25 14:07:48 +00:00
|
|
|
#include <QDebug>
|
|
|
|
|
2013-08-07 16:52:45 +00:00
|
|
|
namespace KWin {
|
|
|
|
namespace Compositing {
|
2013-06-25 14:07:48 +00:00
|
|
|
|
2014-03-27 12:01:02 +00:00
|
|
|
static QString translatedCategory(const QString &category)
|
|
|
|
{
|
|
|
|
static const QVector<QString> knownCategories = {
|
|
|
|
QStringLiteral("Accessibility"),
|
|
|
|
QStringLiteral("Appearance"),
|
|
|
|
QStringLiteral("Candy"),
|
|
|
|
QStringLiteral("Focus"),
|
[kcmkwin/compositing] Move show desktop effects to their own category
Summary:
We have two exclusive categories in the Appearance category:
minimize-animations and show-desktop. But it's hard to draw a line
between them, i.e. one can't say whether given effect belongs to the
minimize-animations category or to the show-desktop category.
This change moves show desktop effects to their own category so we have only
one exclusive category in the Appearance category.
Before:
{F6160592, layout=center, size=full}
After:
{F6161173, layout=center, size=full}
Reviewers: #kwin, #plasma, #vdg, ngraham
Reviewed By: #vdg, ngraham
Subscribers: davidedmundson, graesslin, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D14458
2018-07-29 14:01:39 +00:00
|
|
|
QStringLiteral("Show Desktop Animation"),
|
2014-03-27 12:01:02 +00:00
|
|
|
QStringLiteral("Tools"),
|
|
|
|
QStringLiteral("Virtual Desktop Switching Animation"),
|
|
|
|
QStringLiteral("Window Management")
|
|
|
|
};
|
|
|
|
|
|
|
|
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", "Candy"),
|
|
|
|
i18nc("Category of Desktop Effects, used as section header", "Focus"),
|
[kcmkwin/compositing] Move show desktop effects to their own category
Summary:
We have two exclusive categories in the Appearance category:
minimize-animations and show-desktop. But it's hard to draw a line
between them, i.e. one can't say whether given effect belongs to the
minimize-animations category or to the show-desktop category.
This change moves show desktop effects to their own category so we have only
one exclusive category in the Appearance category.
Before:
{F6160592, layout=center, size=full}
After:
{F6161173, layout=center, size=full}
Reviewers: #kwin, #plasma, #vdg, ngraham
Reviewed By: #vdg, ngraham
Subscribers: davidedmundson, graesslin, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D14458
2018-07-29 14:01:39 +00:00
|
|
|
i18nc("Category of Desktop Effects, used as section header", "Show Desktop Animation"),
|
2014-03-27 12:01:02 +00:00
|
|
|
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")
|
|
|
|
};
|
|
|
|
const int index = knownCategories.indexOf(category);
|
|
|
|
if (index == -1) {
|
|
|
|
qDebug() << "Unknown category '" << category << "' and thus not translated";
|
|
|
|
return category;
|
|
|
|
}
|
|
|
|
return translatedCategories[index];
|
|
|
|
}
|
|
|
|
|
2014-06-11 06:44:04 +00:00
|
|
|
static EffectStatus effectStatus(bool enabled)
|
|
|
|
{
|
|
|
|
return enabled ? EffectStatus::Enabled : EffectStatus::Disabled;
|
|
|
|
}
|
|
|
|
|
2013-06-25 14:07:48 +00:00
|
|
|
EffectModel::EffectModel(QObject *parent)
|
2013-08-09 12:29:05 +00:00
|
|
|
: QAbstractItemModel(parent) {
|
2013-08-27 09:57:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QHash< int, QByteArray > EffectModel::roleNames() const
|
|
|
|
{
|
2013-06-25 14:07:48 +00:00
|
|
|
QHash<int, QByteArray> roleNames;
|
2013-08-07 16:52:45 +00:00
|
|
|
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[EffectStatusRole] = "EffectStatusRole";
|
2013-12-03 06:56:21 +00:00
|
|
|
roleNames[VideoRole] = "VideoRole";
|
2014-03-09 09:02:12 +00:00
|
|
|
roleNames[SupportedRole] = "SupportedRole";
|
2014-03-11 12:06:18 +00:00
|
|
|
roleNames[ExclusiveRole] = "ExclusiveRole";
|
2014-03-17 12:13:17 +00:00
|
|
|
roleNames[ConfigurableRole] = "ConfigurableRole";
|
2014-03-17 18:23:46 +00:00
|
|
|
roleNames[ScriptedRole] = QByteArrayLiteral("ScriptedRole");
|
2013-08-27 09:57:21 +00:00
|
|
|
return roleNames;
|
2013-06-25 14:07:48 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
QModelIndex EffectModel::index(int row, int column, const QModelIndex &parent) const
|
|
|
|
{
|
2013-08-09 13:34:50 +00:00
|
|
|
if (parent.isValid() || column > 0 || column < 0 || row < 0 || row >= m_effectsList.count()) {
|
2013-08-09 12:29:05 +00:00
|
|
|
return QModelIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
return createIndex(row, column);
|
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
QModelIndex EffectModel::parent(const QModelIndex &child) const
|
|
|
|
{
|
2013-08-09 12:29:05 +00:00
|
|
|
Q_UNUSED(child)
|
2013-08-09 13:34:50 +00:00
|
|
|
|
2013-08-09 12:29:05 +00:00
|
|
|
return QModelIndex();
|
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
int EffectModel::columnCount(const QModelIndex &parent) const
|
|
|
|
{
|
2013-08-27 10:03:37 +00:00
|
|
|
Q_UNUSED(parent)
|
2013-08-09 12:29:05 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
int EffectModel::rowCount(const QModelIndex &parent) const
|
|
|
|
{
|
2013-08-09 13:34:50 +00:00
|
|
|
if (parent.isValid()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-06-25 14:07:48 +00:00
|
|
|
return m_effectsList.count();
|
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
QVariant EffectModel::data(const QModelIndex &index, int role) const
|
|
|
|
{
|
2013-06-25 14:07:48 +00:00
|
|
|
if (!index.isValid()) {
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
2013-08-07 16:52:45 +00:00
|
|
|
EffectData currentEffect = m_effectsList.at(index.row());
|
2013-06-25 14:07:48 +00:00
|
|
|
switch (role) {
|
|
|
|
case Qt::DisplayRole:
|
2013-08-07 16:52:45 +00:00
|
|
|
case NameRole:
|
2013-06-25 14:07:48 +00:00
|
|
|
return m_effectsList.at(index.row()).name;
|
2013-08-07 16:52:45 +00:00
|
|
|
case DescriptionRole:
|
2013-06-25 14:07:48 +00:00
|
|
|
return m_effectsList.at(index.row()).description;
|
2013-08-07 16:52:45 +00:00
|
|
|
case AuthorNameRole:
|
2013-06-25 14:07:48 +00:00
|
|
|
return m_effectsList.at(index.row()).authorName;
|
2013-08-07 16:52:45 +00:00
|
|
|
case AuthorEmailRole:
|
2013-06-25 14:07:48 +00:00
|
|
|
return m_effectsList.at(index.row()).authorEmail;
|
2013-08-07 16:52:45 +00:00
|
|
|
case LicenseRole:
|
2013-06-25 14:07:48 +00:00
|
|
|
return m_effectsList.at(index.row()).license;
|
2013-08-07 16:52:45 +00:00
|
|
|
case VersionRole:
|
2013-06-25 14:07:48 +00:00
|
|
|
return m_effectsList.at(index.row()).version;
|
2013-08-07 16:52:45 +00:00
|
|
|
case CategoryRole:
|
2013-06-25 14:07:48 +00:00
|
|
|
return m_effectsList.at(index.row()).category;
|
2013-08-07 16:52:45 +00:00
|
|
|
case ServiceNameRole:
|
|
|
|
return m_effectsList.at(index.row()).serviceName;
|
|
|
|
case EffectStatusRole:
|
2014-06-11 06:44:04 +00:00
|
|
|
return (int)m_effectsList.at(index.row()).effectStatus;
|
2013-12-03 06:56:21 +00:00
|
|
|
case VideoRole:
|
|
|
|
return m_effectsList.at(index.row()).video;
|
2014-03-09 09:02:12 +00:00
|
|
|
case SupportedRole:
|
|
|
|
return m_effectsList.at(index.row()).supported;
|
2014-03-11 12:06:18 +00:00
|
|
|
case ExclusiveRole:
|
|
|
|
return m_effectsList.at(index.row()).exclusiveGroup;
|
2014-03-13 18:50:17 +00:00
|
|
|
case InternalRole:
|
|
|
|
return m_effectsList.at(index.row()).internal;
|
2014-03-17 12:13:17 +00:00
|
|
|
case ConfigurableRole:
|
|
|
|
return m_effectsList.at(index.row()).configurable;
|
2014-03-17 18:23:46 +00:00
|
|
|
case ScriptedRole:
|
|
|
|
return m_effectsList.at(index.row()).scripted;
|
2013-06-25 14:07:48 +00:00
|
|
|
default:
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
bool EffectModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
|
|
|
{
|
2013-08-09 12:29:05 +00:00
|
|
|
if (!index.isValid())
|
|
|
|
return QAbstractItemModel::setData(index, value, role);
|
|
|
|
|
|
|
|
if (role == EffectModel::EffectStatusRole) {
|
2014-06-11 07:36:39 +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
|
2014-03-11 12:06:18 +00:00
|
|
|
EffectData &data = m_effectsList[index.row()];
|
2014-06-11 06:44:04 +00:00
|
|
|
data.effectStatus = EffectStatus(value.toInt());
|
2014-06-11 07:36:39 +00:00
|
|
|
data.changed = true;
|
2014-03-11 12:06:18 +00:00
|
|
|
emit dataChanged(index, index);
|
2013-08-19 16:50:01 +00:00
|
|
|
|
2014-06-11 06:44:04 +00:00
|
|
|
if (data.effectStatus == EffectStatus::Enabled && !data.exclusiveGroup.isEmpty()) {
|
2014-03-11 12:06:18 +00:00
|
|
|
// need to disable all other exclusive effects in the same category
|
|
|
|
for (int i = 0; i < m_effectsList.size(); ++i) {
|
|
|
|
if (i == index.row()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
EffectData &otherData = m_effectsList[i];
|
|
|
|
if (otherData.exclusiveGroup == data.exclusiveGroup) {
|
2014-06-11 06:44:04 +00:00
|
|
|
otherData.effectStatus = EffectStatus::Disabled;
|
2014-06-11 07:36:39 +00:00
|
|
|
otherData.changed = true;
|
2014-03-11 12:06:18 +00:00
|
|
|
emit dataChanged(this->index(i, 0), this->index(i, 0));
|
|
|
|
}
|
|
|
|
}
|
2013-08-19 16:50:01 +00:00
|
|
|
}
|
2014-03-11 12:06:18 +00:00
|
|
|
|
2013-08-22 10:31:01 +00:00
|
|
|
return true;
|
2013-08-09 12:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return QAbstractItemModel::setData(index, value, role);
|
|
|
|
}
|
|
|
|
|
2015-09-18 13:23:50 +00:00
|
|
|
void EffectModel::loadBuiltInEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs)
|
2013-08-28 07:36:53 +00:00
|
|
|
{
|
2014-04-03 14:20:26 +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.category = translatedCategory(data.category);
|
|
|
|
effect.serviceName = data.name;
|
|
|
|
effect.enabledByDefault = data.enabled;
|
2014-06-11 06:44:04 +00:00
|
|
|
effect.enabledByDefaultFunction = (data.enabledFunction != nullptr);
|
|
|
|
const QString enabledKey = QStringLiteral("%1Enabled").arg(effect.serviceName);
|
|
|
|
if (kwinConfig.hasKey(enabledKey)) {
|
|
|
|
effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", effect.enabledByDefault));
|
|
|
|
} else if (data.enabledFunction != nullptr) {
|
|
|
|
effect.effectStatus = EffectStatus::EnabledUndeterminded;
|
|
|
|
} else {
|
|
|
|
effect.effectStatus = effectStatus(effect.enabledByDefault);
|
|
|
|
}
|
2014-04-03 14:20:26 +00:00
|
|
|
effect.video = data.video;
|
|
|
|
effect.supported = true;
|
|
|
|
effect.exclusiveGroup = data.exclusiveCategory;
|
|
|
|
effect.internal = data.internal;
|
|
|
|
effect.scripted = false;
|
|
|
|
|
|
|
|
auto it = std::find_if(configs.begin(), configs.end(), [data](const KPluginInfo &info) {
|
2014-04-04 09:49:31 +00:00
|
|
|
return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == data.name;
|
2014-04-03 14:20:26 +00:00
|
|
|
});
|
|
|
|
effect.configurable = it != configs.end();
|
|
|
|
|
|
|
|
m_effectsList << effect;
|
|
|
|
}
|
2015-09-18 13:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectModel::loadJavascriptEffects(const KConfigGroup &kwinConfig)
|
|
|
|
{
|
[effects] Make scripted effects GHNS-able
Summary:
Currently, if one wants to install a scripted effect from the KDE Store,
the effect won't show up in the Desktop Effects KCM. The reason for that
is kpackagetool5 doesn't know where to install effects (they have to be
installed under ${DATA_DIR}/kwin/effects).
Another problem is that even if the scripted effect is installed in the
right directory (e.g. ~/.local/share/kwin/effects), it won't be listed in
the Desktop Effects KCM because it doesn't have a desktop file in
kservices5 dir. Please notice that the effect will be "visible" for KWin, i.e.
you can enable it by editing kwinrc.
This diff addresses those 2 problems by:
* Adding a PackageStructure plugin for effects (so they are installed
under kwin/effects/);
* Using KPackage::PackageLoader to get list of scripted effect in the
Desktop Effects KCM.
Test Plan:
* Installed an effect from the KDE Store, it appeared in the Desktop Effects
KCM;
* Removed it.
Reviewers: #kwin, mart, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: ngraham, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15372
2018-09-09 09:28:58 +00:00
|
|
|
const auto plugins = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Effect"), QStringLiteral("kwin/effects"));
|
|
|
|
for (const KPluginMetaData &metaData : plugins) {
|
|
|
|
KPluginInfo plugin(metaData);
|
2014-04-03 14:20:26 +00:00
|
|
|
EffectData effect;
|
2013-08-21 10:15:24 +00:00
|
|
|
|
2013-06-25 14:07:48 +00:00
|
|
|
effect.name = plugin.name();
|
|
|
|
effect.description = plugin.comment();
|
|
|
|
effect.authorName = plugin.author();
|
|
|
|
effect.authorEmail = plugin.email();
|
|
|
|
effect.license = plugin.license();
|
|
|
|
effect.version = plugin.version();
|
2014-03-27 12:01:02 +00:00
|
|
|
effect.category = translatedCategory(plugin.category());
|
2013-08-21 10:15:24 +00:00
|
|
|
effect.serviceName = plugin.pluginName();
|
2014-06-11 06:44:04 +00:00
|
|
|
effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", plugin.isPluginEnabledByDefault()));
|
2013-12-02 14:59:31 +00:00
|
|
|
effect.enabledByDefault = plugin.isPluginEnabledByDefault();
|
2014-06-11 06:44:04 +00:00
|
|
|
effect.enabledByDefaultFunction = false;
|
[effects] Make scripted effects GHNS-able
Summary:
Currently, if one wants to install a scripted effect from the KDE Store,
the effect won't show up in the Desktop Effects KCM. The reason for that
is kpackagetool5 doesn't know where to install effects (they have to be
installed under ${DATA_DIR}/kwin/effects).
Another problem is that even if the scripted effect is installed in the
right directory (e.g. ~/.local/share/kwin/effects), it won't be listed in
the Desktop Effects KCM because it doesn't have a desktop file in
kservices5 dir. Please notice that the effect will be "visible" for KWin, i.e.
you can enable it by editing kwinrc.
This diff addresses those 2 problems by:
* Adding a PackageStructure plugin for effects (so they are installed
under kwin/effects/);
* Using KPackage::PackageLoader to get list of scripted effect in the
Desktop Effects KCM.
Test Plan:
* Installed an effect from the KDE Store, it appeared in the Desktop Effects
KCM;
* Removed it.
Reviewers: #kwin, mart, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: ngraham, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15372
2018-09-09 09:28:58 +00:00
|
|
|
effect.video = plugin.property(QStringLiteral("X-KWin-Video-Url")).toUrl();
|
2014-03-09 09:02:12 +00:00
|
|
|
effect.supported = true;
|
[effects] Make scripted effects GHNS-able
Summary:
Currently, if one wants to install a scripted effect from the KDE Store,
the effect won't show up in the Desktop Effects KCM. The reason for that
is kpackagetool5 doesn't know where to install effects (they have to be
installed under ${DATA_DIR}/kwin/effects).
Another problem is that even if the scripted effect is installed in the
right directory (e.g. ~/.local/share/kwin/effects), it won't be listed in
the Desktop Effects KCM because it doesn't have a desktop file in
kservices5 dir. Please notice that the effect will be "visible" for KWin, i.e.
you can enable it by editing kwinrc.
This diff addresses those 2 problems by:
* Adding a PackageStructure plugin for effects (so they are installed
under kwin/effects/);
* Using KPackage::PackageLoader to get list of scripted effect in the
Desktop Effects KCM.
Test Plan:
* Installed an effect from the KDE Store, it appeared in the Desktop Effects
KCM;
* Removed it.
Reviewers: #kwin, mart, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: ngraham, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15372
2018-09-09 09:28:58 +00:00
|
|
|
effect.exclusiveGroup = plugin.property(QStringLiteral("X-KWin-Exclusive-Category")).toString();
|
|
|
|
effect.internal = plugin.property(QStringLiteral("X-KWin-Internal")).toBool();
|
2014-04-03 14:20:26 +00:00
|
|
|
effect.scripted = true;
|
2013-08-07 16:52:45 +00:00
|
|
|
|
[effects] Make scripted effects GHNS-able
Summary:
Currently, if one wants to install a scripted effect from the KDE Store,
the effect won't show up in the Desktop Effects KCM. The reason for that
is kpackagetool5 doesn't know where to install effects (they have to be
installed under ${DATA_DIR}/kwin/effects).
Another problem is that even if the scripted effect is installed in the
right directory (e.g. ~/.local/share/kwin/effects), it won't be listed in
the Desktop Effects KCM because it doesn't have a desktop file in
kservices5 dir. Please notice that the effect will be "visible" for KWin, i.e.
you can enable it by editing kwinrc.
This diff addresses those 2 problems by:
* Adding a PackageStructure plugin for effects (so they are installed
under kwin/effects/);
* Using KPackage::PackageLoader to get list of scripted effect in the
Desktop Effects KCM.
Test Plan:
* Installed an effect from the KDE Store, it appeared in the Desktop Effects
KCM;
* Removed it.
Reviewers: #kwin, mart, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: ngraham, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15372
2018-09-09 09:28:58 +00:00
|
|
|
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;
|
2014-04-03 14:20:26 +00:00
|
|
|
} else {
|
|
|
|
effect.configurable = false;
|
2014-03-17 18:23:46 +00:00
|
|
|
}
|
2014-03-17 12:13:17 +00:00
|
|
|
|
2013-06-25 14:07:48 +00:00
|
|
|
m_effectsList << effect;
|
|
|
|
}
|
2015-09-18 13:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectModel::loadPluginEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs)
|
|
|
|
{
|
|
|
|
static const QString subDir(QStringLiteral("kwin/effects/plugins/"));
|
|
|
|
static const QString serviceType(QStringLiteral("KWin/Effect"));
|
|
|
|
const QVector<KPluginMetaData> pluginEffects = KPluginLoader::findPlugins(subDir, [] (const KPluginMetaData &data) { return data.serviceTypes().contains(serviceType); });
|
|
|
|
for (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.category = pluginEffect.category();
|
|
|
|
effect.serviceName = pluginEffect.pluginId();
|
|
|
|
effect.enabledByDefault = pluginEffect.isEnabledByDefault();
|
|
|
|
effect.supported = true;
|
|
|
|
effect.enabledByDefaultFunction = false;
|
|
|
|
effect.internal = false;
|
|
|
|
effect.scripted = false;
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString enabledKey = QStringLiteral("%1Enabled").arg(effect.serviceName);
|
|
|
|
if (kwinConfig.hasKey(enabledKey)) {
|
|
|
|
effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", effect.enabledByDefault));
|
|
|
|
} else if (effect.enabledByDefaultFunction) {
|
|
|
|
effect.effectStatus = EffectStatus::EnabledUndeterminded;
|
|
|
|
} else {
|
|
|
|
effect.effectStatus = effectStatus(effect.enabledByDefault);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto it = std::find_if(configs.begin(), configs.end(), [pluginEffect](const KPluginInfo &info) {
|
|
|
|
return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == pluginEffect.pluginId();
|
|
|
|
});
|
|
|
|
effect.configurable = it != configs.end();
|
|
|
|
|
|
|
|
m_effectsList << effect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectModel::loadEffects()
|
|
|
|
{
|
|
|
|
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins");
|
|
|
|
|
|
|
|
beginResetModel();
|
|
|
|
m_effectsChanged.clear();
|
|
|
|
m_effectsList.clear();
|
|
|
|
const KPluginInfo::List configs = KPluginTrader::self()->query(QStringLiteral("kwin/effects/configs/"));
|
|
|
|
loadBuiltInEffects(kwinConfig, configs);
|
|
|
|
loadJavascriptEffects(kwinConfig);
|
|
|
|
loadPluginEffects(kwinConfig, configs);
|
2013-08-08 13:47:01 +00:00
|
|
|
|
2013-08-07 16:52:45 +00:00
|
|
|
qSort(m_effectsList.begin(), m_effectsList.end(), [](const EffectData &a, const EffectData &b) {
|
2014-03-12 08:22:47 +00:00
|
|
|
if (a.category == b.category) {
|
|
|
|
if (a.exclusiveGroup == b.exclusiveGroup) {
|
|
|
|
return a.name < b.name;
|
|
|
|
}
|
|
|
|
return a.exclusiveGroup < b.exclusiveGroup;
|
|
|
|
}
|
2013-08-07 16:52:45 +00:00
|
|
|
return a.category < b.category;
|
|
|
|
});
|
2013-07-31 07:39:06 +00:00
|
|
|
|
2014-03-09 09:02:12 +00:00
|
|
|
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
|
|
|
QStringLiteral("/Effects"),
|
|
|
|
QDBusConnection::sessionBus());
|
|
|
|
if (interface.isValid()) {
|
|
|
|
QStringList effectNames;
|
|
|
|
std::for_each(m_effectsList.constBegin(), m_effectsList.constEnd(), [&effectNames](const EffectData &data) {
|
|
|
|
effectNames << data.serviceName;
|
|
|
|
});
|
|
|
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(interface.areEffectsSupported(effectNames), this);
|
|
|
|
watcher->setProperty("effectNames", effectNames);
|
|
|
|
connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher *self) {
|
|
|
|
const QStringList effectNames = self->property("effectNames").toStringList();
|
|
|
|
const QDBusPendingReply< QList< bool > > reply = *self;
|
|
|
|
QList< bool> supportValues;
|
|
|
|
if (reply.isValid()) {
|
|
|
|
supportValues.append(reply.value());
|
|
|
|
}
|
|
|
|
if (effectNames.size() == supportValues.size()) {
|
|
|
|
for (int i = 0; i < effectNames.size(); ++i) {
|
|
|
|
const bool supportedValue = supportValues.at(i);
|
|
|
|
const QString &effectName = effectNames.at(i);
|
|
|
|
auto it = std::find_if(m_effectsList.begin(), m_effectsList.end(), [effectName](const EffectData &data) {
|
|
|
|
return data.serviceName == effectName;
|
|
|
|
});
|
|
|
|
if (it != m_effectsList.end()) {
|
|
|
|
if ((*it).supported != supportedValue) {
|
|
|
|
(*it).supported = supportedValue;
|
|
|
|
QModelIndex i = index(findRowByServiceName(effectName), 0);
|
|
|
|
if (i.isValid()) {
|
|
|
|
emit dataChanged(i, i, QVector<int>() << SupportedRole);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self->deleteLater();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-08-28 09:01:08 +00:00
|
|
|
m_effectsChanged = m_effectsList;
|
2013-08-07 16:52:45 +00:00
|
|
|
endResetModel();
|
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
int EffectModel::findRowByServiceName(const QString &serviceName)
|
|
|
|
{
|
2013-08-28 09:01:08 +00:00
|
|
|
for (int it = 0; it < m_effectsList.size(); it++) {
|
2013-08-22 10:31:01 +00:00
|
|
|
if (m_effectsList.at(it).serviceName == serviceName) {
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2013-08-19 16:50:01 +00:00
|
|
|
|
2013-08-28 09:01:08 +00:00
|
|
|
void EffectModel::syncEffectsToKWin()
|
|
|
|
{
|
2014-03-07 13:41:05 +00:00
|
|
|
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
|
|
|
QStringLiteral("/Effects"),
|
|
|
|
QDBusConnection::sessionBus());
|
2013-08-28 09:01:08 +00:00
|
|
|
for (int it = 0; it < m_effectsList.size(); it++) {
|
|
|
|
if (m_effectsList.at(it).effectStatus != m_effectsChanged.at(it).effectStatus) {
|
2014-06-11 06:44:04 +00:00
|
|
|
if (m_effectsList.at(it).effectStatus != EffectStatus::Disabled) {
|
2014-03-07 13:41:05 +00:00
|
|
|
interface.loadEffect(m_effectsList.at(it).serviceName);
|
2013-08-28 09:01:08 +00:00
|
|
|
} else {
|
2014-03-07 13:41:05 +00:00
|
|
|
interface.unloadEffect(m_effectsList.at(it).serviceName);
|
2013-08-28 09:01:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_effectsChanged = m_effectsList;
|
|
|
|
}
|
|
|
|
|
2014-06-11 06:44:04 +00:00
|
|
|
void EffectModel::updateEffectStatus(const QModelIndex &rowIndex, EffectStatus effectState)
|
2013-08-28 07:36:53 +00:00
|
|
|
{
|
2014-06-11 06:44:04 +00:00
|
|
|
setData(rowIndex, (int)effectState, EffectModel::EffectStatusRole);
|
2013-08-08 16:00:28 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
void EffectModel::syncConfig()
|
|
|
|
{
|
2013-08-08 16:00:28 +00:00
|
|
|
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins");
|
|
|
|
|
2014-06-12 05:47:27 +00:00
|
|
|
for (auto it = m_effectsList.begin(); it != m_effectsList.end(); it++) {
|
|
|
|
EffectData &effect = *(it);
|
2014-06-11 07:36:39 +00:00
|
|
|
if (!effect.changed) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
effect.changed = false;
|
2014-04-03 14:20:26 +00:00
|
|
|
|
2014-05-15 15:10:40 +00:00
|
|
|
const QString key = effect.serviceName + QStringLiteral("Enabled");
|
2014-06-11 06:44:04 +00:00
|
|
|
const bool shouldEnable = (effect.effectStatus != EffectStatus::Disabled);
|
|
|
|
const bool restoreToDefault = effect.enabledByDefaultFunction
|
|
|
|
? effect.effectStatus == EffectStatus::EnabledUndeterminded
|
|
|
|
: shouldEnable == effect.enabledByDefault;
|
|
|
|
if (restoreToDefault) {
|
2014-04-03 14:20:26 +00:00
|
|
|
kwinConfig.deleteEntry(key);
|
2014-06-11 06:44:04 +00:00
|
|
|
} else {
|
|
|
|
kwinConfig.writeEntry(key, shouldEnable);
|
2013-08-08 16:00:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kwinConfig.sync();
|
2013-08-28 09:01:08 +00:00
|
|
|
syncEffectsToKWin();
|
2013-08-08 16:00:28 +00:00
|
|
|
}
|
|
|
|
|
2013-12-02 14:59:31 +00:00
|
|
|
void EffectModel::defaults()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < m_effectsList.count(); ++i) {
|
|
|
|
const auto &effect = m_effectsList.at(i);
|
2014-06-11 06:44:04 +00:00
|
|
|
if (effect.enabledByDefaultFunction && effect.effectStatus != EffectStatus::EnabledUndeterminded) {
|
|
|
|
updateEffectStatus(index(i, 0), EffectStatus::EnabledUndeterminded);
|
|
|
|
} else if ((bool)effect.effectStatus != effect.enabledByDefault) {
|
|
|
|
updateEffectStatus(index(i, 0), effect.enabledByDefault ? EffectStatus::Enabled : EffectStatus::Disabled);
|
2013-12-02 14:59:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-09 12:29:05 +00:00
|
|
|
EffectFilterModel::EffectFilterModel(QObject *parent)
|
2014-03-09 09:02:12 +00:00
|
|
|
: QSortFilterProxyModel(parent)
|
|
|
|
, m_effectModel(new EffectModel(this))
|
2014-03-13 18:50:17 +00:00
|
|
|
, m_filterOutUnsupported(true)
|
|
|
|
, m_filterOutInternal(true)
|
2013-08-09 12:29:05 +00:00
|
|
|
{
|
2013-08-27 18:21:07 +00:00
|
|
|
setSourceModel(m_effectModel);
|
2014-03-13 18:50:17 +00:00
|
|
|
connect(this, &EffectFilterModel::filterOutUnsupportedChanged, this, &EffectFilterModel::invalidateFilter);
|
|
|
|
connect(this, &EffectFilterModel::filterOutInternalChanged, this, &EffectFilterModel::invalidateFilter);
|
2013-08-09 12:29:05 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
const QString &EffectFilterModel::filter() const
|
|
|
|
{
|
2013-08-09 12:29:05 +00:00
|
|
|
return m_filter;
|
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
void EffectFilterModel::setFilter(const QString &filter)
|
|
|
|
{
|
2013-08-09 12:29:05 +00:00
|
|
|
if (filter == m_filter) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_filter = filter;
|
|
|
|
emit filterChanged();
|
|
|
|
invalidateFilter();
|
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
bool EffectFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
|
|
|
{
|
2013-08-09 12:29:05 +00:00
|
|
|
if (!m_effectModel) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QModelIndex index = m_effectModel->index(source_row, 0, source_parent);
|
|
|
|
if (!index.isValid()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-13 18:50:17 +00:00
|
|
|
if (m_filterOutUnsupported) {
|
|
|
|
if (!index.data(EffectModel::SupportedRole).toBool()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_filterOutInternal) {
|
|
|
|
if (index.data(EffectModel::InternalRole).toBool()) {
|
2014-03-09 09:02:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_filter.isEmpty()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-09 12:29:05 +00:00
|
|
|
QVariant data = index.data();
|
|
|
|
if (!data.isValid()) {
|
|
|
|
//An invalid QVariant is valid data
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-09 14:51:59 +00:00
|
|
|
if (m_effectModel->data(index, EffectModel::NameRole).toString().contains(m_filter, Qt::CaseInsensitive)) {
|
|
|
|
return true;
|
|
|
|
} else if (m_effectModel->data(index, EffectModel::DescriptionRole).toString().contains(m_filter, Qt::CaseInsensitive)) {
|
2013-08-09 12:29:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-12 07:48:19 +00:00
|
|
|
if (index.data(EffectModel::CategoryRole).toString().contains(m_filter, Qt::CaseInsensitive)) {
|
|
|
|
return true;
|
|
|
|
}
|
2013-08-09 12:29:05 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-06-11 06:44:04 +00:00
|
|
|
void EffectFilterModel::updateEffectStatus(int rowIndex, int effectState)
|
2013-08-28 07:36:53 +00:00
|
|
|
{
|
2013-08-28 07:31:57 +00:00
|
|
|
const QModelIndex sourceIndex = mapToSource(index(rowIndex, 0));
|
|
|
|
|
2014-06-11 06:44:04 +00:00
|
|
|
m_effectModel->updateEffectStatus(sourceIndex, EffectStatus(effectState));
|
2013-08-27 18:21:07 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
void EffectFilterModel::syncConfig()
|
|
|
|
{
|
2013-08-27 18:21:07 +00:00
|
|
|
m_effectModel->syncConfig();
|
|
|
|
}
|
|
|
|
|
2013-12-02 14:40:16 +00:00
|
|
|
void EffectFilterModel::load()
|
|
|
|
{
|
|
|
|
m_effectModel->loadEffects();
|
|
|
|
}
|
|
|
|
|
2013-12-02 14:59:31 +00:00
|
|
|
void EffectFilterModel::defaults()
|
|
|
|
{
|
|
|
|
m_effectModel->defaults();
|
|
|
|
}
|
|
|
|
|
2018-03-05 19:01:23 +00:00
|
|
|
EffectView::EffectView(ViewType type, QWidget *parent)
|
|
|
|
: QQuickWidget(parent)
|
2013-06-25 14:07:48 +00:00
|
|
|
{
|
2014-04-23 06:21:35 +00:00
|
|
|
qRegisterMetaType<OpenGLPlatformInterfaceModel*>();
|
2013-08-01 16:20:37 +00:00
|
|
|
qmlRegisterType<EffectConfig>("org.kde.kwin.kwincompositing", 1, 0, "EffectConfig");
|
2013-08-09 12:29:05 +00:00
|
|
|
qmlRegisterType<EffectFilterModel>("org.kde.kwin.kwincompositing", 1, 0, "EffectFilterModel");
|
2013-08-17 08:28:09 +00:00
|
|
|
qmlRegisterType<Compositing>("org.kde.kwin.kwincompositing", 1, 0, "Compositing");
|
2013-08-29 16:58:51 +00:00
|
|
|
qmlRegisterType<CompositingType>("org.kde.kwin.kwincompositing", 1, 0, "CompositingType");
|
2014-03-07 09:09:47 +00:00
|
|
|
init(type);
|
2013-06-25 14:07:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-07 09:09:47 +00:00
|
|
|
void EffectView::init(ViewType type)
|
2013-08-28 07:36:53 +00:00
|
|
|
{
|
2014-05-26 09:32:52 +00:00
|
|
|
KDeclarative::KDeclarative kdeclarative;
|
|
|
|
kdeclarative.setDeclarativeEngine(engine());
|
2014-06-06 05:47:25 +00:00
|
|
|
kdeclarative.setTranslationDomain(QStringLiteral(TRANSLATION_DOMAIN));
|
2018-07-01 20:48:31 +00:00
|
|
|
kdeclarative.setupContext();
|
|
|
|
kdeclarative.setupEngine(engine());
|
2014-03-07 09:09:47 +00:00
|
|
|
QString path;
|
|
|
|
switch (type) {
|
|
|
|
case CompositingSettingsView:
|
|
|
|
path = QStringLiteral("kwincompositing/qml/main-compositing.qml");
|
|
|
|
break;
|
|
|
|
case DesktopEffectsView:
|
|
|
|
path = QStringLiteral("kwincompositing/qml/main.qml");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
QString mainFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, path, QStandardPaths::LocateFile);
|
2018-03-05 19:01:23 +00:00
|
|
|
setResizeMode(QQuickWidget::SizeRootObjectToView);
|
2013-06-25 14:07:48 +00:00
|
|
|
setSource(QUrl(mainFile));
|
2015-10-21 11:23:40 +00:00
|
|
|
rootObject()->setProperty("color",
|
|
|
|
KColorScheme(QPalette::Active, KColorScheme::Window, KSharedConfigPtr(0)).background(KColorScheme::NormalBackground).color());
|
2013-12-02 10:26:37 +00:00
|
|
|
connect(rootObject(), SIGNAL(changed()), this, SIGNAL(changed()));
|
2014-03-26 11:06:01 +00:00
|
|
|
setMinimumSize(initialSize());
|
|
|
|
connect(rootObject(), SIGNAL(implicitWidthChanged()), this, SLOT(slotImplicitSizeChanged()));
|
|
|
|
connect(rootObject(), SIGNAL(implicitHeightChanged()), this, SLOT(slotImplicitSizeChanged()));
|
2013-06-25 14:07:48 +00:00
|
|
|
}
|
|
|
|
|
2013-12-02 14:27:58 +00:00
|
|
|
void EffectView::save()
|
|
|
|
{
|
|
|
|
if (auto *model = rootObject()->findChild<EffectFilterModel*>(QStringLiteral("filterModel"))) {
|
|
|
|
model->syncConfig();
|
|
|
|
}
|
|
|
|
if (auto *compositing = rootObject()->findChild<Compositing*>(QStringLiteral("compositing"))) {
|
|
|
|
compositing->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-02 14:40:16 +00:00
|
|
|
void EffectView::load()
|
|
|
|
{
|
|
|
|
if (auto *model = rootObject()->findChild<EffectFilterModel*>(QStringLiteral("filterModel"))) {
|
|
|
|
model->load();
|
|
|
|
}
|
|
|
|
if (auto *compositing = rootObject()->findChild<Compositing*>(QStringLiteral("compositing"))) {
|
|
|
|
compositing->reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-02 14:59:31 +00:00
|
|
|
void EffectView::defaults()
|
|
|
|
{
|
|
|
|
if (auto *model = rootObject()->findChild<EffectFilterModel*>(QStringLiteral("filterModel"))) {
|
|
|
|
model->defaults();
|
|
|
|
}
|
|
|
|
if (auto *compositing = rootObject()->findChild<Compositing*>(QStringLiteral("compositing"))) {
|
|
|
|
compositing->defaults();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-26 11:06:01 +00:00
|
|
|
void EffectView::slotImplicitSizeChanged()
|
|
|
|
{
|
|
|
|
setMinimumSize(QSize(rootObject()->property("implicitWidth").toInt(),
|
|
|
|
rootObject()->property("implicitHeight").toInt()));
|
|
|
|
}
|
|
|
|
|
2013-08-07 16:52:45 +00:00
|
|
|
}//end namespace Compositing
|
|
|
|
}//end namespace KWin
|