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"
|
|
|
|
|
2013-08-07 16:52:45 +00:00
|
|
|
#include <KDE/KPluginInfo>
|
|
|
|
#include <KDE/KService>
|
|
|
|
#include <KDE/KServiceTypeTrader>
|
|
|
|
#include <KDE/KSharedConfig>
|
|
|
|
#include <KDE/KCModuleProxy>
|
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
|
|
|
|
|
|
|
EffectModel::EffectModel(QObject *parent)
|
2013-08-09 12:29:05 +00:00
|
|
|
: QAbstractItemModel(parent) {
|
2013-06-25 14:07:48 +00:00
|
|
|
|
2013-08-27 09:57:21 +00:00
|
|
|
loadEffects();
|
|
|
|
}
|
|
|
|
|
|
|
|
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-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:
|
|
|
|
return m_effectsList.at(index.row()).effectStatus;
|
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) {
|
|
|
|
m_effectsList[index.row()].effectStatus = value.toBool();
|
2013-08-19 16:50:01 +00:00
|
|
|
|
|
|
|
const QString effectServiceName = m_effectsList[index.row()].serviceName;
|
|
|
|
if (effectServiceName == "kwin4_effect_slide") {
|
|
|
|
handleDesktopSwitching(index.row());
|
|
|
|
} else if (effectServiceName == "kwin4_effect_fadedesktop") {
|
|
|
|
handleDesktopSwitching(index.row());
|
|
|
|
} else if (effectServiceName == "kwin4_effect_cubeslide") {
|
|
|
|
handleDesktopSwitching(index.row());
|
|
|
|
}
|
2013-08-09 12:29:05 +00:00
|
|
|
emit dataChanged(index, index);
|
|
|
|
return true;
|
2013-08-22 10:31:01 +00:00
|
|
|
} else if (role == EffectModel::WindowManagementRole) {
|
|
|
|
bool enabled = value.toBool();
|
|
|
|
handleWindowManagement(index.row(), enabled);
|
|
|
|
emit dataChanged(index, index);
|
|
|
|
return true;
|
2013-08-09 12:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return QAbstractItemModel::setData(index, value, role);
|
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
void EffectModel::loadEffects()
|
|
|
|
{
|
2013-08-07 16:52:45 +00:00
|
|
|
EffectData effect;
|
|
|
|
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins");
|
2013-06-25 14:07:48 +00:00
|
|
|
|
2013-08-07 16:52:45 +00:00
|
|
|
beginResetModel();
|
2013-12-02 14:40:16 +00:00
|
|
|
m_effectsChanged.clear();
|
|
|
|
m_effectsList.clear();
|
2013-07-31 07:39:06 +00:00
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
|
|
|
|
for(KService::Ptr service : offers) {
|
2013-08-21 10:15:24 +00:00
|
|
|
const QString effectPluginPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kde5/services/"+ service->entryPath(), QStandardPaths::LocateFile);
|
|
|
|
KPluginInfo plugin(effectPluginPath);
|
|
|
|
|
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();
|
|
|
|
effect.category = plugin.category();
|
2013-08-21 10:15:24 +00:00
|
|
|
effect.serviceName = plugin.pluginName();
|
2013-09-13 16:01:26 +00:00
|
|
|
effect.effectStatus = kwinConfig.readEntry(effect.serviceName + "Enabled", plugin.isPluginEnabledByDefault());
|
2013-12-02 14:59:31 +00:00
|
|
|
effect.enabledByDefault = plugin.isPluginEnabledByDefault();
|
2013-08-07 16:52:45 +00:00
|
|
|
|
2013-06-25 14:07:48 +00:00
|
|
|
m_effectsList << effect;
|
|
|
|
}
|
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) {
|
|
|
|
return a.category < b.category;
|
|
|
|
});
|
2013-07-31 07:39:06 +00:00
|
|
|
|
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
|
|
|
void EffectModel::handleDesktopSwitching(int row)
|
|
|
|
{
|
2013-08-19 16:50:01 +00:00
|
|
|
//Q: Why do we need the handleDesktopSwitching?
|
|
|
|
//A: Because of the setData, when we enable the effect
|
|
|
|
//and then we scroll, our model is being updated,
|
|
|
|
//so the setData is being called again, and as a result
|
|
|
|
//of that we have multiple effects enabled for the desktop switching.
|
|
|
|
const QString currentEffect = m_effectsList[row].serviceName;
|
|
|
|
for (int it = 0; it < m_effectsList.size(); it++) {
|
|
|
|
EffectData effect = m_effectsList.at(it);
|
|
|
|
|
|
|
|
if (effect.serviceName == "kwin4_effect_slide" && currentEffect != effect.serviceName && effect.effectStatus) {
|
|
|
|
m_effectsList[it].effectStatus = !m_effectsList[it].effectStatus;
|
|
|
|
} else if (effect.serviceName == "kwin4_effect_cubeslide" && currentEffect != effect.serviceName && effect.effectStatus) {
|
|
|
|
m_effectsList[it].effectStatus = !m_effectsList[it].effectStatus;
|
2013-08-28 09:01:08 +00:00
|
|
|
} else if (effect.serviceName == "kwin4_effect_fadedesktop" && currentEffect != effect.serviceName && effect.effectStatus) {
|
2013-08-19 16:50:01 +00:00
|
|
|
m_effectsList[it].effectStatus = !m_effectsList[it].effectStatus;
|
|
|
|
}
|
|
|
|
}
|
2013-06-25 14:07:48 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
void EffectModel::handleWindowManagement(int row, bool enabled)
|
|
|
|
{
|
2013-09-10 10:38:05 +00:00
|
|
|
//Make sure that our row is valid
|
2013-09-10 11:35:51 +00:00
|
|
|
if (m_effectsList.size() > 0 && row <= m_effectsList.size())
|
2013-09-10 10:34:55 +00:00
|
|
|
m_effectsList[row].effectStatus = enabled;
|
2013-08-22 10:31:01 +00:00
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2013-12-02 15:19:49 +00:00
|
|
|
QDBusInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"));
|
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) {
|
|
|
|
if (m_effectsList.at(it).effectStatus) {
|
|
|
|
interface.asyncCall("loadEffect", m_effectsList.at(it).serviceName);
|
|
|
|
} else {
|
|
|
|
interface.asyncCall("unloadEffect", m_effectsList.at(it).serviceName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_effectsChanged = m_effectsList;
|
|
|
|
}
|
|
|
|
|
2013-09-10 11:35:51 +00:00
|
|
|
void EffectModel::updateEffectStatus(const QModelIndex &rowIndex, bool effectState)
|
2013-08-28 07:36:53 +00:00
|
|
|
{
|
2013-08-28 07:31:57 +00:00
|
|
|
setData(rowIndex, 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");
|
|
|
|
|
|
|
|
for (auto it = m_effectsList.begin(); it != m_effectsList.end(); it++) {
|
|
|
|
EffectData effect = *(it);
|
2013-08-28 09:01:08 +00:00
|
|
|
|
2013-08-08 16:00:28 +00:00
|
|
|
bool effectConfigStatus = kwinConfig.readEntry(effect.serviceName + "Enabled", false);
|
|
|
|
|
|
|
|
if (effect.effectStatus) {
|
|
|
|
kwinConfig.writeEntry(effect.serviceName + "Enabled", effect.effectStatus);
|
|
|
|
} else if (effect.effectStatus != effectConfigStatus) {
|
|
|
|
kwinConfig.writeEntry(effect.serviceName + "Enabled", effect.effectStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kwinConfig.sync();
|
2013-08-28 09:01:08 +00:00
|
|
|
syncEffectsToKWin();
|
2013-08-08 16:00:28 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
void EffectModel::enableWidnowManagement(bool enabled)
|
|
|
|
{
|
2013-09-10 10:38:05 +00:00
|
|
|
//Make sure that our effects are being installed properly
|
|
|
|
if (m_effectsList.size() <= 0)
|
|
|
|
return;
|
|
|
|
|
2013-08-22 10:31:01 +00:00
|
|
|
int desktopGridRow = findRowByServiceName("kwin4_effect_desktopgrid");
|
|
|
|
const QModelIndex desktopGridIndex = createIndex(desktopGridRow, 0);
|
|
|
|
setData(desktopGridIndex, enabled, EffectModel::WindowManagementRole);
|
|
|
|
|
|
|
|
int dialogParentRow = findRowByServiceName("kwin4_effect_dialogparent");
|
|
|
|
const QModelIndex dialogParentIndex = createIndex(dialogParentRow, 0);
|
|
|
|
setData(dialogParentIndex, enabled, EffectModel::WindowManagementRole);
|
|
|
|
|
|
|
|
int presentWindowsRow = findRowByServiceName("kwin4_effect_presentwindows");
|
|
|
|
const QModelIndex presentWindowsIndex = createIndex(presentWindowsRow, 0);
|
|
|
|
setData(presentWindowsIndex, enabled, EffectModel::WindowManagementRole);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
if (effect.effectStatus != effect.enabledByDefault) {
|
|
|
|
updateEffectStatus(index(i, 0), effect.enabledByDefault);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-09 12:29:05 +00:00
|
|
|
EffectFilterModel::EffectFilterModel(QObject *parent)
|
|
|
|
:QSortFilterProxyModel(parent),
|
2013-08-28 07:31:57 +00:00
|
|
|
m_effectModel( new EffectModel(this))
|
2013-08-09 12:29:05 +00:00
|
|
|
{
|
2013-08-27 18:21:07 +00:00
|
|
|
setSourceModel(m_effectModel);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_filter.isEmpty()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QModelIndex index = m_effectModel->index(source_row, 0, source_parent);
|
|
|
|
if (!index.isValid()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-10 11:35:51 +00:00
|
|
|
void EffectFilterModel::updateEffectStatus(int rowIndex, bool effectState)
|
2013-08-28 07:36:53 +00:00
|
|
|
{
|
2013-08-28 07:31:57 +00:00
|
|
|
const QModelIndex sourceIndex = mapToSource(index(rowIndex, 0));
|
|
|
|
|
2013-09-10 11:35:51 +00:00
|
|
|
m_effectModel->updateEffectStatus(sourceIndex, 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-08-28 07:36:53 +00:00
|
|
|
void EffectFilterModel::enableWidnowManagement(bool enabled)
|
|
|
|
{
|
2013-08-27 18:21:07 +00:00
|
|
|
m_effectModel->enableWidnowManagement(enabled);
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-06-25 14:07:48 +00:00
|
|
|
EffectView::EffectView(QWindow *parent)
|
|
|
|
: QQuickView(parent)
|
|
|
|
{
|
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");
|
2013-06-25 14:07:48 +00:00
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
2013-08-28 07:36:53 +00:00
|
|
|
void EffectView::init()
|
|
|
|
{
|
2013-12-02 08:55:21 +00:00
|
|
|
QString mainFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwincompositing/qml/main.qml", QStandardPaths::LocateFile);
|
2013-06-25 14:07:48 +00:00
|
|
|
setResizeMode(QQuickView::SizeRootObjectToView);
|
2013-09-13 12:29:53 +00:00
|
|
|
rootContext()->setContextProperty("engine", this);
|
2013-06-25 14:07:48 +00:00
|
|
|
setSource(QUrl(mainFile));
|
2013-12-02 10:26:37 +00:00
|
|
|
connect(rootObject(), SIGNAL(changed()), this, SIGNAL(changed()));
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-07 16:52:45 +00:00
|
|
|
}//end namespace Compositing
|
|
|
|
}//end namespace KWin
|