From 837c44434de1bf1f1eb3b89441def9513f6dc9f1 Mon Sep 17 00:00:00 2001 From: Antonis Tsiapaliokas Date: Thu, 1 Aug 2013 19:20:37 +0300 Subject: [PATCH] Load the configuration UI for the Effects --- kcmkwin/kwincompositing/CMakeLists.txt | 5 +- kcmkwin/kwincompositing/effectconfig.cpp | 63 ++++++++++++++++++++++++ kcmkwin/kwincompositing/effectconfig.h | 43 ++++++++++++++++ kcmkwin/kwincompositing/model.cpp | 4 ++ kcmkwin/kwincompositing/qml/Effect.qml | 20 +++++++- 5 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 kcmkwin/kwincompositing/effectconfig.cpp create mode 100644 kcmkwin/kwincompositing/effectconfig.h diff --git a/kcmkwin/kwincompositing/CMakeLists.txt b/kcmkwin/kwincompositing/CMakeLists.txt index d1a0e3aabe..5a7c4f9dce 100644 --- a/kcmkwin/kwincompositing/CMakeLists.txt +++ b/kcmkwin/kwincompositing/CMakeLists.txt @@ -46,6 +46,7 @@ find_package(KDELibs4 REQUIRED NO_MODULE) find_package(KDE4Support REQUIRED NO_MODULE) find_package(kdeclarative REQUIRED NO_MODULE) +find_package(LibAttica REQUIRED NO_MODULE) ######################################################################### @@ -73,7 +74,8 @@ set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") set(kwincomposing_SRC model.cpp - main.cpp) + main.cpp + effectconfig.cpp) add_executable(kwincompositing ${kwincomposing_SRC}) @@ -84,6 +86,7 @@ target_link_libraries(kwincompositing ${kservice_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${KDE4_KDECORE_LIBS} + ${KDE4_KCMUTILS_LIBS} ) INSTALL(DIRECTORY qml DESTINATION ${DATA_INSTALL_DIR}/kwincompositing) diff --git a/kcmkwin/kwincompositing/effectconfig.cpp b/kcmkwin/kwincompositing/effectconfig.cpp new file mode 100644 index 0000000000..e071d7f70f --- /dev/null +++ b/kcmkwin/kwincompositing/effectconfig.cpp @@ -0,0 +1,63 @@ +/************************************************************************** +* KWin - the KDE window manager * +* This file is part of the KDE project. * +* * +* Copyright (C) 2013 Antonis Tsiapaliokas * +* * +* 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 . * +**************************************************************************/ + +#include "effectconfig.h" + +#include +#include + +#include +#include +#include + + +#include +EffectConfig::EffectConfig(QObject *parent) + : QObject(parent) +{ +} + +QString EffectConfig::serviceName(const QString &effectName) { + //The effect name is something like "Show Fps" and + //we want something like "showfps" + return effectName.toLower().replace(" ", ""); +} + +bool EffectConfig::effectUiConfigExists(const QString &effectName) { + + const QString effectConfig = serviceName(effectName) + "_config"; + QString effectConfigFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kde5/services/kwin/" + effectConfig +".desktop", QStandardPaths::LocateFile); + + return !effectConfigFile.isEmpty(); +} + +void EffectConfig::openConfig(const QString &effectName) { + + KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect"); + for(KService::Ptr service : offers) { + KPluginInfo plugin(service); + if (plugin.name() == effectName) { + QString effectConfig = serviceName(plugin.name() + "_config"); + KCModuleProxy *proxy = new KCModuleProxy(effectConfig); + proxy->show(); + } + } +} + diff --git a/kcmkwin/kwincompositing/effectconfig.h b/kcmkwin/kwincompositing/effectconfig.h new file mode 100644 index 0000000000..d047cbda35 --- /dev/null +++ b/kcmkwin/kwincompositing/effectconfig.h @@ -0,0 +1,43 @@ +/************************************************************************** + * KWin - the KDE window manager * + * This file is part of the KDE project. * + * * + * Copyright (C) 2013 Antonis Tsiapaliokas * + * * + * 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 . * + **************************************************************************/ + + +#ifndef EFFECTCONFIG_H +#define EFFECTCONFIG_H +#include +#include +#include +#include +#include + + +class EffectConfig : public QObject { + + Q_OBJECT + +public: + EffectConfig(QObject *parent = 0); + QString serviceName(const QString &effectName); + + Q_INVOKABLE bool effectUiConfigExists(const QString &effectName); + Q_INVOKABLE void openConfig(const QString &effectName); + +}; +#endif diff --git a/kcmkwin/kwincompositing/model.cpp b/kcmkwin/kwincompositing/model.cpp index d206d614c2..4a48123e44 100644 --- a/kcmkwin/kwincompositing/model.cpp +++ b/kcmkwin/kwincompositing/model.cpp @@ -18,6 +18,7 @@ * along with this program. If not, see . * **************************************************************************/ +#include "effectconfig.h" #include "model.h" #include @@ -35,6 +36,7 @@ #include #include #include +#include EffectModel::EffectModel(QObject *parent) : QAbstractListModel(parent) { @@ -108,6 +110,8 @@ EffectView::EffectView(QWindow *parent) : QQuickView(parent) { qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "EffectModel"); + qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "EffectConfig"); + init(); } diff --git a/kcmkwin/kwincompositing/qml/Effect.qml b/kcmkwin/kwincompositing/qml/Effect.qml index 1fd5e1e738..0cefee31f0 100644 --- a/kcmkwin/kwincompositing/qml/Effect.qml +++ b/kcmkwin/kwincompositing/qml/Effect.qml @@ -22,6 +22,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 +import org.kde.kwin.kwincompositing 1.0 Component { id: effectDelegate @@ -45,7 +46,7 @@ Component { Item { id: effectItem - width: effectView.width - myCheckBox.width - aboutButton.width + width: effectView.width - myCheckBox.width - aboutButton.width - configureButton.width anchors.left: myCheckBox.right Column { id: col @@ -81,14 +82,29 @@ Component { } Button { - id: aboutButton + id: configureButton anchors.left: effectItem.right + visible: effectConfig.effectUiConfigExists(model.Name) + text: "CONFIGURE EFFECT" + onClicked: { + effectConfig.openConfig(model.Name); + } + } + + Button { + id: aboutButton + anchors.left: configureButton.right text: "ABOUT UI BUTTON" onClicked: { animationAbout.running = true; animationAboutSpacing.running = true; } } + + EffectConfig { + id: effectConfig + } + } //end Row } //end Rectangle } //end item