/******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Martin Gräßlin . *********************************************************************/ #include "snow_config.h" #include #include #include #include #include #include #include #ifndef KDE_USE_FINAL KWIN_EFFECT_CONFIG_FACTORY #endif namespace KWin { SnowEffectConfigForm::SnowEffectConfigForm(QWidget* parent) : QWidget(parent) { setupUi(this); } SnowEffectConfig::SnowEffectConfig(QWidget* parent, const QVariantList& args) : KCModule(EffectFactory::componentData(), parent, args) { kDebug() ; m_ui = new SnowEffectConfigForm(this); QVBoxLayout* layout = new QVBoxLayout(this); layout->addWidget(m_ui); connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed())); connect(m_ui->numberFlakes, SIGNAL(valueChanged(int)), this, SLOT(changed())); connect(m_ui->minSizeFlake, SIGNAL(valueChanged(int)), this, SLOT(changed())); connect(m_ui->maxSizeFlake, SIGNAL(valueChanged(int)), this, SLOT(changed())); m_actionCollection = new KActionCollection( this, componentData() ); m_actionCollection->setConfigGroup("Snow"); m_actionCollection->setConfigGlobal(true); KAction* a = (KAction*)m_actionCollection->addAction( "Snow" ); a->setText( i18n("Toggle Snow on Desktop" )); a->setProperty("isConfigurationAction", true); a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::META + Qt::Key_F12 )); m_ui->editor->addCollection(m_actionCollection); } SnowEffectConfig::~SnowEffectConfig() { // Undo (only) unsaved changes to global key shortcuts m_ui->editor->undoChanges(); kDebug() ; } void SnowEffectConfig::load() { kDebug() ; KCModule::load(); KConfigGroup conf = EffectsHandler::effectConfig("Snow"); int number = conf.readEntry("Number", 50); int minFlake = conf.readEntry("MinFlakes", 10); int maxFlake = conf.readEntry("MaxFlakes", 50); m_ui->numberFlakes->setValue( number ); m_ui->minSizeFlake->setValue( minFlake ); m_ui->maxSizeFlake->setValue( maxFlake ); emit changed(false); } void SnowEffectConfig::save() { kDebug() ; KConfigGroup conf = EffectsHandler::effectConfig("Snow"); conf.writeEntry("Number", m_ui->numberFlakes->value()); conf.writeEntry("MinFlakes", m_ui->minSizeFlake->value()); conf.writeEntry("MaxFlakes", m_ui->maxSizeFlake->value()); m_ui->editor->save(); // undo() will restore to this state from now on conf.sync(); emit changed(false); EffectsHandler::sendReloadMessage( "snow" ); } void SnowEffectConfig::defaults() { kDebug() ; m_ui->numberFlakes->setValue( 50 ); m_ui->minSizeFlake->setValue( 10 ); m_ui->maxSizeFlake->setValue( 50 ); m_ui->editor->allDefault(); emit changed(true); } } // namespace #include "snow_config.moc"