diff --git a/kcmkwin/kwincompositing/CMakeLists.txt b/kcmkwin/kwincompositing/CMakeLists.txt index 46217bd444..eb48b30289 100644 --- a/kcmkwin/kwincompositing/CMakeLists.txt +++ b/kcmkwin/kwincompositing/CMakeLists.txt @@ -1,7 +1,7 @@ ########### next target ############### -set(kcm_kwincompositing_PART_SRCS main.cpp ) -kde4_add_ui_files(kcm_kwincompositing_PART_SRCS main.ui) +set(kcm_kwincompositing_PART_SRCS advanced.cpp main.cpp ) +kde4_add_ui_files(kcm_kwincompositing_PART_SRCS advanced.ui main.ui) kde4_add_plugin(kcm_kwincompositing ${kcm_kwincompositing_PART_SRCS}) target_link_libraries(kcm_kwincompositing ${KDE4_KUTILS_LIBS}) install(TARGETS kcm_kwincompositing DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kcmkwin/kwincompositing/advanced.cpp b/kcmkwin/kwincompositing/advanced.cpp new file mode 100644 index 0000000000..35338c6c96 --- /dev/null +++ b/kcmkwin/kwincompositing/advanced.cpp @@ -0,0 +1,75 @@ +/***************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2007 Rivo Laks + +You can Freely distribute this program under the GNU General Public +License. See the file "COPYING" for the exact licensing terms. +******************************************************************/ + +#include "advanced.h" + +#include + +namespace KWin +{ + +KWinAdvancedCompositingOptions::KWinAdvancedCompositingOptions(QWidget* parent, KSharedConfigPtr config) : + KDialog(parent) +{ + mKWinConfig = config; + + setCaption(i18n("Advanced compositing options")); + setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply); + setModal(true); + + QWidget* mainWidget = new QWidget(this); + ui.setupUi(mainWidget); + setMainWidget(mainWidget); + + ui.compositingType->insertItem(0, i18n("OpenGL")); + ui.compositingType->insertItem(1, i18n("XRender")); + + connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); + + connect(this, SIGNAL(okClicked()), this, SLOT(save())); + connect(this, SIGNAL(applyClicked()), this, SLOT(save())); + + load(); + + enableButtonApply(false); +} + +KWinAdvancedCompositingOptions::~KWinAdvancedCompositingOptions() +{ +} + +void KWinAdvancedCompositingOptions::changed() +{ + enableButtonApply(true); +} + +void KWinAdvancedCompositingOptions::load() +{ + KConfigGroup config(mKWinConfig, "Compositing"); + QString backend = config.readEntry("Backend", "OpenGL"); + ui.compositingType->setCurrentIndex((backend == "XRender") ? 1 : 0); +} + +void KWinAdvancedCompositingOptions::save() +{ + // Is this ok? + if (!isButtonEnabled(KDialog::Apply)) { + return; + } + + KConfigGroup config(mKWinConfig, "Compositing"); + config.writeEntry("Backend", (ui.compositingType->currentIndex() == 0) ? "OpenGL" : "XRender"); + + enableButtonApply(false); + emit configSaved(); +} + +} // namespace + diff --git a/kcmkwin/kwincompositing/advanced.h b/kcmkwin/kwincompositing/advanced.h new file mode 100644 index 0000000000..c2996ea54e --- /dev/null +++ b/kcmkwin/kwincompositing/advanced.h @@ -0,0 +1,46 @@ +/***************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2007 Rivo Laks + +You can Freely distribute this program under the GNU General Public +License. See the file "COPYING" for the exact licensing terms. +******************************************************************/ + + +#ifndef ADVANCED_H +#define ADVANCED_H + +#include + +#include "ui_advanced.h" + + +namespace KWin +{ + +class KWinAdvancedCompositingOptions : public KDialog +{ + Q_OBJECT + public: + KWinAdvancedCompositingOptions(QWidget* parent, KSharedConfigPtr config); + virtual ~KWinAdvancedCompositingOptions(); + + void load(); + + public slots: + void changed(); + void save(); + + signals: + void configSaved(); + + private: + KSharedConfigPtr mKWinConfig; + Ui::KWinAdvancedCompositingOptions ui; +}; + +} // namespace + +#endif diff --git a/kcmkwin/kwincompositing/advanced.ui b/kcmkwin/kwincompositing/advanced.ui new file mode 100644 index 0000000000..8b37718b37 --- /dev/null +++ b/kcmkwin/kwincompositing/advanced.ui @@ -0,0 +1,47 @@ + + KWinAdvancedCompositingOptions + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + Compositing type: + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/kcmkwin/kwincompositing/kwincompositing.desktop b/kcmkwin/kwincompositing/kwincompositing.desktop index 48573415e2..713460defc 100644 --- a/kcmkwin/kwincompositing/kwincompositing.desktop +++ b/kcmkwin/kwincompositing/kwincompositing.desktop @@ -10,8 +10,8 @@ X-KDE-Library=kcm_kwincompositing X-KDE-FactoryName=kcm_kwincompositing X-KDE-ParentApp=kcontrol -Name=Compositing +Name=Desktop effects -Comment=Configure window compositing +Comment=Configure desktop effects Keywords=kwin,window,manager,compositing,effect diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp index 4dccadb8ea..206e87058e 100644 --- a/kcmkwin/kwincompositing/main.cpp +++ b/kcmkwin/kwincompositing/main.cpp @@ -10,6 +10,8 @@ License. See the file "COPYING" for the exact licensing terms. #include "main.h" +#include "advanced.h" + #include #include #include @@ -36,19 +38,16 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QStringList { ui.setupUi(this); - ui.compositingType->insertItem(0, i18n("OpenGL")); - ui.compositingType->insertItem(1, i18n("XRender")); - + connect(ui.advancedOptions, SIGNAL(clicked()), this, SLOT(showAdvancedOptions())); connect(ui.useCompositing, SIGNAL(toggled(bool)), ui.compositingOptionsContainer, SLOT(setEnabled(bool))); connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(changed())); - connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); // Load config load(); KAboutData *about = new KAboutData(I18N_NOOP("kcmkwincompositing"), 0, - ki18n("KWin Compositing Configuration Module"), + ki18n("KWin Desktop Effects Configuration Module"), 0, KLocalizedString(), KAboutData::License_GPL, ki18n("(c) 2007 Rivo Laks")); about->addAuthor(ki18n("Rivo Laks"), KLocalizedString(), "rivolaks@hot.ee"); setAboutData(about); @@ -63,6 +62,14 @@ void KWinCompositingConfig::reparseConfiguration(const QByteArray&conf) KSettings::Dispatcher::reparseConfiguration(conf); } +void KWinCompositingConfig::showAdvancedOptions() +{ + KWinAdvancedCompositingOptions* dialog = new KWinAdvancedCompositingOptions(this, mKWinConfig); + + dialog->show(); + connect(dialog, SIGNAL(configSaved()), this, SLOT(configChanged())); +} + void KWinCompositingConfig::load() { kDebug() << k_funcinfo << endl; @@ -70,8 +77,6 @@ void KWinCompositingConfig::load() KConfigGroup config(mKWinConfig, "Compositing"); ui.useCompositing->setChecked(config.readEntry("Enabled", false)); - QString backend = config.readEntry("Backend", "OpenGL"); - ui.compositingType->setCurrentIndex((backend == "XRender") ? 1 : 0); emit changed( false ); } @@ -83,12 +88,16 @@ void KWinCompositingConfig::save() KConfigGroup config(mKWinConfig, "Compositing"); config.writeEntry("Enabled", ui.useCompositing->isChecked()); - config.writeEntry("Backend", (ui.compositingType->currentIndex() == 0) ? "OpenGL" : "XRender"); // TODO: save effects emit changed( false ); + configChanged(); +} + +void KWinCompositingConfig::configChanged() +{ // Send signal to kwin mKWinConfig->sync(); // Send signal to all kwin instances @@ -101,7 +110,6 @@ void KWinCompositingConfig::defaults() { kDebug() << k_funcinfo << endl; ui.useCompositing->setChecked(false); - ui.compositingType->setCurrentIndex(0); } QString KWinCompositingConfig::quickHelp() const diff --git a/kcmkwin/kwincompositing/main.h b/kcmkwin/kwincompositing/main.h index e95acf71c6..d3e59fa2d1 100644 --- a/kcmkwin/kwincompositing/main.h +++ b/kcmkwin/kwincompositing/main.h @@ -33,11 +33,15 @@ class KWinCompositingConfig : public KCModule virtual QString quickHelp() const; public slots: + virtual void showAdvancedOptions(); + virtual void load(); virtual void save(); virtual void defaults(); void reparseConfiguration(const QByteArray&conf); + void configChanged(); + private: KSharedConfigPtr mKWinConfig; Ui::KWinCompositingConfig ui; diff --git a/kcmkwin/kwincompositing/main.ui b/kcmkwin/kwincompositing/main.ui index 736ebed9fc..c7a84d5580 100644 --- a/kcmkwin/kwincompositing/main.ui +++ b/kcmkwin/kwincompositing/main.ui @@ -16,7 +16,7 @@ - Use compositing + Enable desktop effects true @@ -26,20 +26,6 @@ - - - - - - Compositing type: - - - - - - - - @@ -96,6 +82,30 @@ + + + + + + Qt::Horizontal + + + + 101 + 20 + + + + + + + + Advanced options... + + + + + @@ -116,22 +126,6 @@ - - useCompositing - toggled(bool) - compositingType - setEnabled(bool) - - - 110 - 21 - - - 324 - 50 - - - useCompositing toggled(bool)