Load the configuration UI for the Effects

This commit is contained in:
Antonis Tsiapaliokas 2013-08-01 19:20:37 +03:00 committed by Martin Gräßlin
parent 51549d3ec9
commit 837c44434d
5 changed files with 132 additions and 3 deletions

View file

@ -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)

View file

@ -0,0 +1,63 @@
/**************************************************************************
* 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 "effectconfig.h"
#include <QStandardPaths>
#include <QString>
#include <KCModuleProxy>
#include <KPluginInfo>
#include <KServiceTypeTrader>
#include <QDebug>
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();
}
}
}

View file

@ -0,0 +1,43 @@
/**************************************************************************
* 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/>. *
**************************************************************************/
#ifndef EFFECTCONFIG_H
#define EFFECTCONFIG_H
#include <QAbstractListModel>
#include <QHash>
#include <QList>
#include <QQuickView>
#include <QString>
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

View file

@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include "effectconfig.h"
#include "model.h"
#include <QAbstractItemModel>
@ -35,6 +36,7 @@
#include <KService>
#include <KServiceTypeTrader>
#include <KSharedConfig>
#include <KCModuleProxy>
EffectModel::EffectModel(QObject *parent)
: QAbstractListModel(parent) {
@ -108,6 +110,8 @@ EffectView::EffectView(QWindow *parent)
: QQuickView(parent)
{
qmlRegisterType<EffectModel>("org.kde.kwin.kwincompositing", 1, 0, "EffectModel");
qmlRegisterType<EffectConfig>("org.kde.kwin.kwincompositing", 1, 0, "EffectConfig");
init();
}

View file

@ -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