ca725b437f
The model data contains a new role ConfigurableRole. This is used to decide whether the configure button is available. The value for the role is set by searching for a KPlugin which has the effect's service name as X-KDE-ParentComponents. All available configs are expected to be in kf5/kwin/effects/configs/ and are located through the KPluginTrader thus binary effect configs need to provide json meta data. REVIEW: 116855
83 lines
3.1 KiB
C++
83 lines
3.1 KiB
C++
/**************************************************************************
|
|
* 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 <KCModule>
|
|
#include <KPluginTrader>
|
|
|
|
#include <KNS3/DownloadDialog>
|
|
|
|
#include <QDialog>
|
|
#include <QDialogButtonBox>
|
|
#include <QVBoxLayout>
|
|
#include <QPointer>
|
|
#include <QStandardPaths>
|
|
#include <QString>
|
|
|
|
namespace KWin {
|
|
namespace Compositing {
|
|
|
|
EffectConfig::EffectConfig(QObject *parent)
|
|
: QObject(parent)
|
|
{
|
|
}
|
|
|
|
void EffectConfig::openConfig(const QString &serviceName)
|
|
{
|
|
//setup the UI
|
|
QDialog dialog;
|
|
|
|
// create the KCModule through the plugintrader
|
|
KCModule *kcm = KPluginTrader::createInstanceFromQuery<KCModule>(QStringLiteral("kf5/kwin/effects/configs/"), QString(),
|
|
QStringLiteral("[X-KDE-ParentComponents] == '%1'").arg(serviceName),
|
|
&dialog);
|
|
if (!kcm) {
|
|
return;
|
|
}
|
|
|
|
connect(&dialog, &QDialog::accepted, kcm, &KCModule::save);
|
|
|
|
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, &dialog);
|
|
|
|
buttons->setCenterButtons(true);
|
|
|
|
//Here we connect our buttons with the dialog
|
|
connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
|
connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout(&dialog);
|
|
layout->addWidget(kcm);
|
|
layout->addWidget(buttons);
|
|
dialog.exec();
|
|
}
|
|
|
|
void EffectConfig::openGHNS()
|
|
{
|
|
QPointer<KNS3::DownloadDialog> downloadDialog = new KNS3::DownloadDialog(QStringLiteral("kwineffect.knsrc"));
|
|
if (downloadDialog->exec() == QDialog::Accepted) {
|
|
emit effectListChanged();
|
|
}
|
|
|
|
delete downloadDialog;
|
|
}
|
|
|
|
}//end namespace Compositing
|
|
}//end namespace KWin
|