2007-05-25 17:11:00 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
#include <kgenericfactory.h>
|
|
|
|
#include <kaboutdata.h>
|
|
|
|
#include <kconfig.h>
|
|
|
|
#include <kdebug.h>
|
|
|
|
#include <kpluginselector.h>
|
|
|
|
#include <kservicetypetrader.h>
|
|
|
|
#include <kplugininfo.h>
|
2007-05-28 11:12:20 +00:00
|
|
|
#include <kservice.h>
|
2007-06-04 20:34:00 +00:00
|
|
|
#include <ksettings/dispatcher.h>
|
2007-05-25 17:11:00 +00:00
|
|
|
|
|
|
|
#include <QtDBus/QtDBus>
|
|
|
|
#include <QBoxLayout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef KGenericFactory<KWin::KWinEffectsConfig> KWinEffectsConfigFactory;
|
|
|
|
K_EXPORT_COMPONENT_FACTORY( kcm_kwineffects, KWinEffectsConfigFactory("kcmkwineffects"))
|
|
|
|
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
KWinEffectsConfig::KWinEffectsConfig(QWidget *parent, const QStringList &)
|
|
|
|
: KCModule( KWinEffectsConfigFactory::componentData(), parent),
|
|
|
|
mKWinConfig(KSharedConfig::openConfig("kwinrc"))
|
|
|
|
{
|
|
|
|
mPluginSelector = new KPluginSelector(this);
|
|
|
|
QHBoxLayout* layout = new QHBoxLayout;
|
2007-05-28 22:21:39 +00:00
|
|
|
layout->setMargin(0);
|
2007-05-25 17:11:00 +00:00
|
|
|
layout->addWidget(mPluginSelector);
|
|
|
|
setLayout(layout);
|
|
|
|
|
|
|
|
connect(mPluginSelector, SIGNAL(changed(bool)), this, SLOT(changed()));
|
2007-06-04 20:34:00 +00:00
|
|
|
connect(mPluginSelector, SIGNAL(configCommitted(const QByteArray&)),
|
2007-06-19 06:41:55 +00:00
|
|
|
this, SLOT(reparseConfiguration(const QByteArray&)));
|
2007-05-25 17:11:00 +00:00
|
|
|
|
|
|
|
// Find all .desktop files of the effects
|
2007-05-28 11:12:20 +00:00
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
|
2007-07-22 23:10:53 +00:00
|
|
|
QList<KPluginInfo> effectinfos = KPluginInfo::fromServices(offers);
|
2007-05-25 17:11:00 +00:00
|
|
|
|
|
|
|
// Add them to the plugin selector
|
2007-06-03 21:13:31 +00:00
|
|
|
mPluginSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Appearance"), "Appearance", mKWinConfig);
|
2007-07-04 12:34:58 +00:00
|
|
|
mPluginSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Accessibility"), "Accessibility", mKWinConfig);
|
2007-06-03 21:13:31 +00:00
|
|
|
mPluginSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Window Management"), "Window Management", mKWinConfig);
|
|
|
|
mPluginSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Demos"), "Demos", mKWinConfig);
|
|
|
|
mPluginSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Tests"), "Tests", mKWinConfig);
|
|
|
|
mPluginSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Misc"), "Misc", mKWinConfig);
|
2007-05-25 17:11:00 +00:00
|
|
|
|
|
|
|
// Load config
|
|
|
|
load();
|
|
|
|
|
2007-07-02 08:49:20 +00:00
|
|
|
KAboutData *about = new KAboutData(I18N_NOOP("kcmkwineffects"), 0,
|
|
|
|
ki18n("Window Effects Configuration Module"),
|
|
|
|
0, KLocalizedString(), KAboutData::License_GPL, ki18n("(c) 2007 Rivo Laks"));
|
|
|
|
about->addAuthor(ki18n("Rivo Laks"), KLocalizedString(), "rivolaks@hot.ee");
|
2007-05-25 17:11:00 +00:00
|
|
|
setAboutData(about);
|
|
|
|
}
|
|
|
|
|
|
|
|
KWinEffectsConfig::~KWinEffectsConfig()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-06-19 06:41:55 +00:00
|
|
|
void KWinEffectsConfig::reparseConfiguration(const QByteArray&conf)
|
|
|
|
{
|
|
|
|
KSettings::Dispatcher::reparseConfiguration(conf);
|
|
|
|
}
|
|
|
|
|
2007-05-25 17:11:00 +00:00
|
|
|
void KWinEffectsConfig::load()
|
|
|
|
{
|
2007-08-20 21:33:48 +00:00
|
|
|
kDebug() ;
|
2007-05-25 17:11:00 +00:00
|
|
|
mKWinConfig->reparseConfiguration();
|
|
|
|
|
|
|
|
mPluginSelector->load();
|
|
|
|
|
|
|
|
emit changed( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KWinEffectsConfig::save()
|
|
|
|
{
|
2007-08-20 21:33:48 +00:00
|
|
|
kDebug() ;
|
2007-05-25 17:11:00 +00:00
|
|
|
|
|
|
|
mPluginSelector->save();
|
|
|
|
|
|
|
|
emit changed( false );
|
|
|
|
|
|
|
|
// Send signal to kwin
|
|
|
|
mKWinConfig->sync();
|
|
|
|
// Send signal to all kwin instances
|
|
|
|
QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KWinEffectsConfig::defaults()
|
|
|
|
{
|
2007-08-20 21:33:48 +00:00
|
|
|
kDebug() ;
|
2007-05-25 17:11:00 +00:00
|
|
|
mPluginSelector->defaults();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString KWinEffectsConfig::quickHelp() const
|
|
|
|
{
|
2007-08-20 21:33:48 +00:00
|
|
|
kDebug() ;
|
2007-05-25 17:11:00 +00:00
|
|
|
return i18n("<h1>Window Effects</h1> Here you can configure which effects will be used.");
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "main.moc"
|