diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index bf584ad1b8..9cde66f187 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -174,6 +174,8 @@ if(KWIN_HAVE_OPENGL_COMPOSITING) coverswitch_config.ui cube_config.cpp cube_config.ui + cylinder_config.cpp + cylinder_config.ui flipswitch_config.cpp flipswitch_config.ui invert_config.cpp @@ -186,6 +188,8 @@ if(KWIN_HAVE_OPENGL_COMPOSITING) sharpen_config.cpp snow_config.cpp snow_config.ui + sphere_config.cpp + sphere_config.ui trackmouse_config.cpp wobblywindows_config.cpp wobblywindows_config.ui @@ -193,6 +197,7 @@ if(KWIN_HAVE_OPENGL_COMPOSITING) install( FILES coverswitch_config.desktop cube_config.desktop + cylinder_config.desktop flipswitch_config.desktop invert_config.desktop lookingglass_config.desktop @@ -200,6 +205,7 @@ if(KWIN_HAVE_OPENGL_COMPOSITING) mousemark_config.desktop sharpen_config.desktop snow_config.desktop + sphere_config.desktop trackmouse_config.desktop wobblywindows_config.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) diff --git a/effects/configs_builtins.cpp b/effects/configs_builtins.cpp index ff5de05cc5..2c373c2313 100644 --- a/effects/configs_builtins.cpp +++ b/effects/configs_builtins.cpp @@ -34,6 +34,7 @@ along with this program. If not, see . #ifdef KWIN_HAVE_OPENGL_COMPOSITING #include "coverswitch_config.h" #include "cube_config.h" +#include "cylinder_config.h" #include "flipswitch_config.h" #include "invert_config.h" #include "lookingglass_config.h" @@ -41,6 +42,7 @@ along with this program. If not, see . #include "magnifier_config.h" #include "sharpen_config.h" #include "snow_config.h" +#include "sphere_config.h" #include "trackmouse_config.h" #include "wobblywindows_config.h" #endif @@ -71,6 +73,7 @@ KWIN_EFFECT_CONFIG_FACTORY #define OPENGL_PLUGINS \ registerPlugin("coverswitch"); \ registerPlugin("cube"); \ + registerPlugin("cylinder"); \ registerPlugin("flipswitch"); \ registerPlugin("invert"); \ registerPlugin("lookingglass"); \ @@ -78,6 +81,7 @@ KWIN_EFFECT_CONFIG_FACTORY registerPlugin("magnifier"); \ registerPlugin("sharpen"); \ registerPlugin("snow"); \ + registerPlugin("sphere"); \ registerPlugin("trackmouse"); \ registerPlugin ("wobblywindows"); diff --git a/effects/cube.cpp b/effects/cube.cpp index a3e6e647dc..2a3029fa9b 100644 --- a/effects/cube.cpp +++ b/effects/cube.cpp @@ -76,7 +76,18 @@ CubeEffect::CubeEffect() , capListCreated( false ) , capList( 0 ) { - KConfigGroup conf = effects->effectConfig( "Cube" ); + loadConfig( "Cube" ); + + KActionCollection* actionCollection = new KActionCollection( this ); + KAction* a = static_cast< KAction* >( actionCollection->addAction( "Cube" )); + a->setText( i18n("Desktop Cube" )); + a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F11 )); + connect( a, SIGNAL( triggered( bool )), this, SLOT( toggle())); + } + +void CubeEffect::loadConfig( QString config ) + { + KConfigGroup conf = effects->effectConfig( config ); borderActivate = (ElectricBorder)conf.readEntry( "BorderActivate", (int)ElectricNone ); effects->reserveElectricBorder( borderActivate ); @@ -141,12 +152,6 @@ CubeEffect::CubeEffect() verticalTimeLine.setCurveShape( TimeLine::EaseInOutCurve ); verticalTimeLine.setDuration( rotationDuration ); - - KActionCollection* actionCollection = new KActionCollection( this ); - KAction* a = static_cast< KAction* >( actionCollection->addAction( "Cube" )); - a->setText( i18n("Desktop Cube" )); - a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F11 )); - connect( a, SIGNAL( triggered( bool )), this, SLOT( toggle())); } CubeEffect::~CubeEffect() diff --git a/effects/cube.h b/effects/cube.h index 513e64e4d3..76d5e6289b 100644 --- a/effects/cube.h +++ b/effects/cube.h @@ -65,6 +65,7 @@ class CubeEffect virtual void paintScene( int mask, QRegion region, ScreenPaintData& data ); virtual void paintCap( float z, float zTexture ); virtual void paintCapStep( float z, float zTexture, bool texture ); + void loadConfig( QString config ); void rotateToDesktop( int desktop ); void setActive( bool active ); bool activated; diff --git a/effects/cylinder.cpp b/effects/cylinder.cpp index 934f9f5c5e..231dd5167b 100644 --- a/effects/cylinder.cpp +++ b/effects/cylinder.cpp @@ -38,6 +38,10 @@ CylinderEffect::CylinderEffect() , mValid( true ) , mShader( 0 ) { + if( wallpaper ) + wallpaper->discard(); + loadConfig( "Cylinder" ); + animateDesktopChange = false; } CylinderEffect::~CylinderEffect() diff --git a/effects/cylinder_config.cpp b/effects/cylinder_config.cpp new file mode 100644 index 0000000000..0bfc172bd6 --- /dev/null +++ b/effects/cylinder_config.cpp @@ -0,0 +1,261 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + + Copyright (C) 2008 Martin Gräßlin + +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 . +*********************************************************************/ +#include "cylinder_config.h" +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#ifndef KDE_USE_FINAL +KWIN_EFFECT_CONFIG_FACTORY +#endif + +namespace KWin +{ + +CylinderEffectConfigForm::CylinderEffectConfigForm(QWidget* parent) : QWidget(parent) +{ + setupUi(this); +} + +CylinderEffectConfig::CylinderEffectConfig(QWidget* parent, const QVariantList& args) : + KCModule(EffectFactory::componentData(), parent, args) + { + m_ui = new CylinderEffectConfigForm(this); + + QGridLayout* layout = new QGridLayout(this); + + layout->addWidget(m_ui, 0, 0); + + m_ui->screenEdgeCombo->addItem(i18n("Top")); + m_ui->screenEdgeCombo->addItem(i18n("Top-right")); + m_ui->screenEdgeCombo->addItem(i18n("Right")); + m_ui->screenEdgeCombo->addItem(i18n("Bottom-right")); + m_ui->screenEdgeCombo->addItem(i18n("Bottom")); + m_ui->screenEdgeCombo->addItem(i18n("Bottom-left")); + m_ui->screenEdgeCombo->addItem(i18n("Left")); + m_ui->screenEdgeCombo->addItem(i18n("Top-left")); + m_ui->screenEdgeCombo->addItem(i18n("None")); + + m_actionCollection = new KActionCollection( this, componentData() ); + m_actionCollection->setConfigGroup( "Cube" ); + m_actionCollection->setConfigGlobal(true); + + KAction* a = (KAction*) m_actionCollection->addAction( "Cube" ); + a->setText( i18n("Desktop Cube" )); + a->setProperty("isConfigurationAction", true); + a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F11 )); + + m_ui->editor->addCollection(m_actionCollection); + + m_ui->wallpaperButton->setIcon(KIcon("document-open")); + connect(m_ui->wallpaperButton, SIGNAL(clicked()), this, SLOT(showFileDialog())); + + connect(m_ui->screenEdgeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); + connect(m_ui->rotationDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); + connect(m_ui->cubeOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(changed())); + connect(m_ui->cubeOpacitySpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); + connect(m_ui->displayDesktopNameBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect(m_ui->reflectionBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect(m_ui->backgroundColorButton, SIGNAL(changed(QColor)), this, SLOT(changed())); + connect(m_ui->bigCubeBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect(m_ui->cubeCapsBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect(m_ui->cubeCapsBox, SIGNAL(stateChanged(int)), this, SLOT(capsSelectionChanged())); + connect(m_ui->capsImageBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect(m_ui->capColorButton, SIGNAL(changed(QColor)), this, SLOT(changed())); + connect(m_ui->wallpaperLineEdit, SIGNAL(textChanged(QString)), this, SLOT(changed())); + + load(); + } + +void CylinderEffectConfig::load() + { + KCModule::load(); + + KConfigGroup conf = EffectsHandler::effectConfig( "Cylinder" ); + + int duration = conf.readEntry( "RotationDuration", 500 ); + float opacity = conf.readEntry( "Opacity", 80 ); + bool desktopName = conf.readEntry( "DisplayDesktopName", true ); + bool reflection = conf.readEntry( "Reflection", true ); + int activateBorder = conf.readEntry( "BorderActivate", (int)ElectricNone ); + QColor background = conf.readEntry( "BackgroundColor", QColor( Qt::black ) ); + QColor capColor = conf.readEntry( "CapColor", KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() ); + bool texturedCaps = conf.readEntry( "TexturedCaps", true ); + bool caps = conf.readEntry( "Caps", true ); + bool bigCube = conf.readEntry( "BigCube", false ); + m_ui->wallpaperLineEdit->setText( conf.readEntry( "Wallpaper", "" ) ); + if( activateBorder == (int)ElectricNone ) + activateBorder--; + m_ui->screenEdgeCombo->setCurrentIndex( activateBorder ); + + m_ui->rotationDurationSpin->setValue( duration ); + m_ui->cubeOpacitySlider->setValue( opacity ); + m_ui->cubeOpacitySpin->setValue( opacity ); + if( desktopName ) + { + m_ui->displayDesktopNameBox->setCheckState( Qt::Checked ); + } + else + { + m_ui->displayDesktopNameBox->setCheckState( Qt::Unchecked ); + } + if( reflection ) + { + m_ui->reflectionBox->setCheckState( Qt::Checked ); + } + else + { + m_ui->reflectionBox->setCheckState( Qt::Unchecked ); + } + if( caps ) + { + m_ui->cubeCapsBox->setCheckState( Qt::Checked ); + } + else + { + m_ui->cubeCapsBox->setCheckState( Qt::Unchecked ); + } + if( texturedCaps ) + { + m_ui->capsImageBox->setCheckState( Qt::Checked ); + } + else + { + m_ui->capsImageBox->setCheckState( Qt::Unchecked ); + } + if( bigCube ) + { + m_ui->bigCubeBox->setCheckState( Qt::Checked ); + } + else + { + m_ui->bigCubeBox->setCheckState( Qt::Unchecked ); + } + m_ui->backgroundColorButton->setColor( background ); + m_ui->capColorButton->setColor( capColor ); + capsSelectionChanged(); + + emit changed(false); + } + +void CylinderEffectConfig::save() + { + KConfigGroup conf = EffectsHandler::effectConfig( "Cylinder" ); + + conf.writeEntry( "RotationDuration", m_ui->rotationDurationSpin->value() ); + conf.writeEntry( "DisplayDesktopName", m_ui->displayDesktopNameBox->checkState() == Qt::Checked ? true : false ); + conf.writeEntry( "Reflection", m_ui->reflectionBox->checkState() == Qt::Checked ? true : false ); + conf.writeEntry( "Opacity", m_ui->cubeOpacitySpin->value() ); + conf.writeEntry( "BackgroundColor", m_ui->backgroundColorButton->color() ); + conf.writeEntry( "Caps", m_ui->cubeCapsBox->checkState() == Qt::Checked ? true : false ); + conf.writeEntry( "CapColor", m_ui->capColorButton->color() ); + conf.writeEntry( "TexturedCaps", m_ui->capsImageBox->checkState() == Qt::Checked ? true : false ); + conf.writeEntry( "BigCube", m_ui->bigCubeBox->checkState() == Qt::Checked ? true : false ); + conf.writeEntry( "Wallpaper", m_ui->wallpaperLineEdit->text() ); + + int activateBorder = m_ui->screenEdgeCombo->currentIndex(); + if( activateBorder == (int)ELECTRIC_COUNT ) + activateBorder = (int)ElectricNone; + conf.writeEntry( "BorderActivate", activateBorder ); + + m_ui->editor->save(); + + conf.sync(); + + emit changed(false); + EffectsHandler::sendReloadMessage( "cube" ); + } + +void CylinderEffectConfig::defaults() + { + m_ui->rotationDurationSpin->setValue( 500 ); + m_ui->displayDesktopNameBox->setCheckState( Qt::Checked ); + m_ui->reflectionBox->setCheckState( Qt::Checked ); + m_ui->cubeOpacitySpin->setValue( 80 ); + m_ui->cubeOpacitySlider->setValue( 80 ); + m_ui->screenEdgeCombo->setCurrentIndex( (int)ElectricNone -1 ); + m_ui->backgroundColorButton->setColor( QColor( Qt::black ) ); + m_ui->cubeCapsBox->setCheckState( Qt::Checked ); + m_ui->capColorButton->setColor( KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() ); + m_ui->capsImageBox->setCheckState( Qt::Checked ); + m_ui->bigCubeBox->setCheckState( Qt::Unchecked ); + m_ui->wallpaperLineEdit->setText( "" ); + m_ui->editor->allDefault(); + emit changed(true); + } + +void CylinderEffectConfig::capsSelectionChanged() + { + if( m_ui->cubeCapsBox->checkState() == Qt::Checked ) + { + // activate cap color + m_ui->capColorButton->setEnabled( true ); + m_ui->capColorLabel->setEnabled( true ); + m_ui->capsImageBox->setEnabled( true ); + } + else + { + // deactivate cap color + m_ui->capColorButton->setEnabled( false ); + m_ui->capColorLabel->setEnabled( false ); + m_ui->capsImageBox->setEnabled( false ); + } + } + +void CylinderEffectConfig::showFileDialog() + { + m_dialog = new KFileDialog( KUrl(), "*.png *.jpeg *.jpg ", m_ui ); + KImageFilePreview *previewWidget = new KImageFilePreview( m_dialog ); + m_dialog->setPreviewWidget( previewWidget ); + m_dialog->setOperationMode( KFileDialog::Opening ); + m_dialog->setCaption( i18n("Select Wallpaper Image File") ); + m_dialog->setModal( false ); + m_dialog->show(); + m_dialog->raise(); + m_dialog->activateWindow(); + + connect(m_dialog, SIGNAL(okClicked()), this, SLOT(wallpaperSelected())); + } + +void CylinderEffectConfig::wallpaperSelected() + { + QString wallpaper = m_dialog->selectedFile(); + disconnect(m_dialog, SIGNAL(okClicked()), this, SLOT(wallpaperSelected())); + + m_dialog->deleteLater(); + + if (wallpaper.isEmpty()) { + return; + } + + m_ui->wallpaperLineEdit->setText( wallpaper ); + } + + +} // namespace + +#include "cylinder_config.moc" diff --git a/effects/cylinder_config.desktop b/effects/cylinder_config.desktop new file mode 100644 index 0000000000..911834f43d --- /dev/null +++ b/effects/cylinder_config.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Service +X-KDE-ServiceTypes=KCModule + +X-KDE-Library=kcm_kwin4_effect_builtins +X-KDE-ParentComponents=kwin4_effect_cylinder +X-KDE-PluginKeyword=cylinder + +Name=Desktop Cylinder diff --git a/effects/cylinder_config.h b/effects/cylinder_config.h new file mode 100644 index 0000000000..1f00c40842 --- /dev/null +++ b/effects/cylinder_config.h @@ -0,0 +1,63 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + + Copyright (C) 2008 Martin Gräßlin + +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 . +*********************************************************************/ + +#ifndef KWIN_CYLINDER_CONFIG_H +#define KWIN_CYLINDER_CONFIG_H + +#include + +#include "ui_cylinder_config.h" + +class KFileDialog; + +namespace KWin +{ + +class CylinderEffectConfigForm : public QWidget, public Ui::CylinderEffectConfigForm +{ + Q_OBJECT + public: + explicit CylinderEffectConfigForm(QWidget* parent); +}; + +class CylinderEffectConfig : public KCModule + { + Q_OBJECT + public: + explicit CylinderEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); + + public slots: + virtual void save(); + virtual void load(); + virtual void defaults(); + + private slots: + void capsSelectionChanged(); + void showFileDialog(); + void wallpaperSelected(); + private: + CylinderEffectConfigForm* m_ui; + KActionCollection* m_actionCollection; + KFileDialog* m_dialog; + }; + +} // namespace + +#endif diff --git a/effects/cylinder_config.ui b/effects/cylinder_config.ui new file mode 100644 index 0000000000..28fadf55e7 --- /dev/null +++ b/effects/cylinder_config.ui @@ -0,0 +1,291 @@ + + KWin::CylinderEffectConfigForm + + + + 0 + 0 + 400 + 490 + + + + + + + Appearance + + + + + + Rotation &duration: + + + rotationDurationSpin + + + + + + + msec + + + 5000 + + + 500 + + + + + + + Cube &opacity: + + + cubeOpacitySpin + + + + + + + + + + + + 100 + + + 1 + + + 100 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 10 + + + + + + + + + Fully transparent + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Fully opaque + + + + + + + + + + + % + + + 100 + + + 100 + + + + + + + Display desktop &name + + + + + + + &Reflection + + + + + + + &Background Color: + + + backgroundColorButton + + + + + + + + + + Cube &Caps + + + + + + + C&ap Color: + + + capColorButton + + + + + + + + + + Display &image on cube caps + + + + + + + S&pan cube on all screens + + + + + + + Screen &edge: + + + screenEdgeCombo + + + + + + + &Wallpaper: + + + wallpaperLineEdit + + + + + + + + + + + + + + + + + + + + + + + + + + + + KColorButton + QPushButton +
kcolorbutton.h
+
+ + KWin::GlobalShortcutsEditor + QWidget +
kwineffects.h
+ 1 +
+
+ + screenEdgeCombo + rotationDurationSpin + cubeOpacitySpin + cubeOpacitySlider + displayDesktopNameBox + reflectionBox + backgroundColorButton + wallpaperLineEdit + wallpaperButton + cubeCapsBox + capColorButton + capsImageBox + bigCubeBox + + + + + cubeOpacitySpin + valueChanged(int) + cubeOpacitySlider + setValue(int) + + + 386 + 175 + + + 235 + 162 + + + + + cubeOpacitySlider + valueChanged(int) + cubeOpacitySpin + setValue(int) + + + 133 + 162 + + + 386 + 175 + + + + +
diff --git a/effects/sphere.cpp b/effects/sphere.cpp index 8f74c2b185..81d112ea49 100644 --- a/effects/sphere.cpp +++ b/effects/sphere.cpp @@ -38,6 +38,9 @@ SphereEffect::SphereEffect() , mValid( true ) , mShader( 0 ) { + if( wallpaper ) + wallpaper->discard(); + loadConfig( "Sphere" ); reflection = false; animateDesktopChange = false; } diff --git a/effects/sphere_config.cpp b/effects/sphere_config.cpp new file mode 100644 index 0000000000..c6067ef8c4 --- /dev/null +++ b/effects/sphere_config.cpp @@ -0,0 +1,249 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + + Copyright (C) 2008 Martin Gräßlin + +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 . +*********************************************************************/ +#include "sphere_config.h" +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#ifndef KDE_USE_FINAL +KWIN_EFFECT_CONFIG_FACTORY +#endif + +namespace KWin +{ + +SphereEffectConfigForm::SphereEffectConfigForm(QWidget* parent) : QWidget(parent) +{ + setupUi(this); +} + +SphereEffectConfig::SphereEffectConfig(QWidget* parent, const QVariantList& args) : + KCModule(EffectFactory::componentData(), parent, args) + { + m_ui = new SphereEffectConfigForm(this); + + QGridLayout* layout = new QGridLayout(this); + + layout->addWidget(m_ui, 0, 0); + + m_ui->screenEdgeCombo->addItem(i18n("Top")); + m_ui->screenEdgeCombo->addItem(i18n("Top-right")); + m_ui->screenEdgeCombo->addItem(i18n("Right")); + m_ui->screenEdgeCombo->addItem(i18n("Bottom-right")); + m_ui->screenEdgeCombo->addItem(i18n("Bottom")); + m_ui->screenEdgeCombo->addItem(i18n("Bottom-left")); + m_ui->screenEdgeCombo->addItem(i18n("Left")); + m_ui->screenEdgeCombo->addItem(i18n("Top-left")); + m_ui->screenEdgeCombo->addItem(i18n("None")); + + m_actionCollection = new KActionCollection( this, componentData() ); + m_actionCollection->setConfigGroup( "Cube" ); + m_actionCollection->setConfigGlobal(true); + + KAction* a = (KAction*) m_actionCollection->addAction( "Cube" ); + a->setText( i18n("Desktop Cube" )); + a->setProperty("isConfigurationAction", true); + a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F11 )); + + m_ui->editor->addCollection(m_actionCollection); + + m_ui->wallpaperButton->setIcon(KIcon("document-open")); + connect(m_ui->wallpaperButton, SIGNAL(clicked()), this, SLOT(showFileDialog())); + + connect(m_ui->screenEdgeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); + connect(m_ui->rotationDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); + connect(m_ui->cubeOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(changed())); + connect(m_ui->cubeOpacitySpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); + connect(m_ui->displayDesktopNameBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect(m_ui->backgroundColorButton, SIGNAL(changed(QColor)), this, SLOT(changed())); + connect(m_ui->bigCubeBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect(m_ui->cubeCapsBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect(m_ui->cubeCapsBox, SIGNAL(stateChanged(int)), this, SLOT(capsSelectionChanged())); + connect(m_ui->capsImageBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect(m_ui->capColorButton, SIGNAL(changed(QColor)), this, SLOT(changed())); + connect(m_ui->wallpaperLineEdit, SIGNAL(textChanged(QString)), this, SLOT(changed())); + + load(); + } + +void SphereEffectConfig::load() + { + KCModule::load(); + + KConfigGroup conf = EffectsHandler::effectConfig( "Sphere" ); + + int duration = conf.readEntry( "RotationDuration", 500 ); + float opacity = conf.readEntry( "Opacity", 80 ); + bool desktopName = conf.readEntry( "DisplayDesktopName", true ); + int activateBorder = conf.readEntry( "BorderActivate", (int)ElectricNone ); + QColor background = conf.readEntry( "BackgroundColor", QColor( Qt::black ) ); + QColor capColor = conf.readEntry( "CapColor", KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() ); + bool texturedCaps = conf.readEntry( "TexturedCaps", true ); + bool caps = conf.readEntry( "Caps", true ); + bool bigCube = conf.readEntry( "BigCube", false ); + m_ui->wallpaperLineEdit->setText( conf.readEntry( "Wallpaper", "" ) ); + if( activateBorder == (int)ElectricNone ) + activateBorder--; + m_ui->screenEdgeCombo->setCurrentIndex( activateBorder ); + + m_ui->rotationDurationSpin->setValue( duration ); + m_ui->cubeOpacitySlider->setValue( opacity ); + m_ui->cubeOpacitySpin->setValue( opacity ); + if( desktopName ) + { + m_ui->displayDesktopNameBox->setCheckState( Qt::Checked ); + } + else + { + m_ui->displayDesktopNameBox->setCheckState( Qt::Unchecked ); + } + if( caps ) + { + m_ui->cubeCapsBox->setCheckState( Qt::Checked ); + } + else + { + m_ui->cubeCapsBox->setCheckState( Qt::Unchecked ); + } + if( texturedCaps ) + { + m_ui->capsImageBox->setCheckState( Qt::Checked ); + } + else + { + m_ui->capsImageBox->setCheckState( Qt::Unchecked ); + } + if( bigCube ) + { + m_ui->bigCubeBox->setCheckState( Qt::Checked ); + } + else + { + m_ui->bigCubeBox->setCheckState( Qt::Unchecked ); + } + m_ui->backgroundColorButton->setColor( background ); + m_ui->capColorButton->setColor( capColor ); + capsSelectionChanged(); + + emit changed(false); + } + +void SphereEffectConfig::save() + { + KConfigGroup conf = EffectsHandler::effectConfig( "Sphere" ); + + conf.writeEntry( "RotationDuration", m_ui->rotationDurationSpin->value() ); + conf.writeEntry( "DisplayDesktopName", m_ui->displayDesktopNameBox->checkState() == Qt::Checked ? true : false ); + conf.writeEntry( "Opacity", m_ui->cubeOpacitySpin->value() ); + conf.writeEntry( "BackgroundColor", m_ui->backgroundColorButton->color() ); + conf.writeEntry( "Caps", m_ui->cubeCapsBox->checkState() == Qt::Checked ? true : false ); + conf.writeEntry( "CapColor", m_ui->capColorButton->color() ); + conf.writeEntry( "TexturedCaps", m_ui->capsImageBox->checkState() == Qt::Checked ? true : false ); + conf.writeEntry( "BigCube", m_ui->bigCubeBox->checkState() == Qt::Checked ? true : false ); + conf.writeEntry( "Wallpaper", m_ui->wallpaperLineEdit->text() ); + + int activateBorder = m_ui->screenEdgeCombo->currentIndex(); + if( activateBorder == (int)ELECTRIC_COUNT ) + activateBorder = (int)ElectricNone; + conf.writeEntry( "BorderActivate", activateBorder ); + + m_ui->editor->save(); + + conf.sync(); + + emit changed(false); + EffectsHandler::sendReloadMessage( "cube" ); + } + +void SphereEffectConfig::defaults() + { + m_ui->rotationDurationSpin->setValue( 500 ); + m_ui->displayDesktopNameBox->setCheckState( Qt::Checked ); + m_ui->cubeOpacitySpin->setValue( 80 ); + m_ui->cubeOpacitySlider->setValue( 80 ); + m_ui->screenEdgeCombo->setCurrentIndex( (int)ElectricNone -1 ); + m_ui->backgroundColorButton->setColor( QColor( Qt::black ) ); + m_ui->cubeCapsBox->setCheckState( Qt::Checked ); + m_ui->capColorButton->setColor( KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() ); + m_ui->capsImageBox->setCheckState( Qt::Checked ); + m_ui->bigCubeBox->setCheckState( Qt::Unchecked ); + m_ui->wallpaperLineEdit->setText( "" ); + m_ui->editor->allDefault(); + emit changed(true); + } + +void SphereEffectConfig::capsSelectionChanged() + { + if( m_ui->cubeCapsBox->checkState() == Qt::Checked ) + { + // activate cap color + m_ui->capColorButton->setEnabled( true ); + m_ui->capColorLabel->setEnabled( true ); + m_ui->capsImageBox->setEnabled( true ); + } + else + { + // deactivate cap color + m_ui->capColorButton->setEnabled( false ); + m_ui->capColorLabel->setEnabled( false ); + m_ui->capsImageBox->setEnabled( false ); + } + } + +void SphereEffectConfig::showFileDialog() + { + m_dialog = new KFileDialog( KUrl(), "*.png *.jpeg *.jpg ", m_ui ); + KImageFilePreview *previewWidget = new KImageFilePreview( m_dialog ); + m_dialog->setPreviewWidget( previewWidget ); + m_dialog->setOperationMode( KFileDialog::Opening ); + m_dialog->setCaption( i18n("Select Wallpaper Image File") ); + m_dialog->setModal( false ); + m_dialog->show(); + m_dialog->raise(); + m_dialog->activateWindow(); + + connect(m_dialog, SIGNAL(okClicked()), this, SLOT(wallpaperSelected())); + } + +void SphereEffectConfig::wallpaperSelected() + { + QString wallpaper = m_dialog->selectedFile(); + disconnect(m_dialog, SIGNAL(okClicked()), this, SLOT(wallpaperSelected())); + + m_dialog->deleteLater(); + + if (wallpaper.isEmpty()) { + return; + } + + m_ui->wallpaperLineEdit->setText( wallpaper ); + } + + +} // namespace + +#include "sphere_config.moc" diff --git a/effects/sphere_config.desktop b/effects/sphere_config.desktop new file mode 100644 index 0000000000..11b8f29bb1 --- /dev/null +++ b/effects/sphere_config.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Service +X-KDE-ServiceTypes=KCModule + +X-KDE-Library=kcm_kwin4_effect_builtins +X-KDE-ParentComponents=kwin4_effect_sphere +X-KDE-PluginKeyword=sphere + +Name=Desktop Sphere diff --git a/effects/sphere_config.h b/effects/sphere_config.h new file mode 100644 index 0000000000..14f8b5492a --- /dev/null +++ b/effects/sphere_config.h @@ -0,0 +1,63 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + + Copyright (C) 2008 Martin Gräßlin + +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 . +*********************************************************************/ + +#ifndef KWIN_SPHERE_CONFIG_H +#define KWIN_SPHERE_CONFIG_H + +#include + +#include "ui_sphere_config.h" + +class KFileDialog; + +namespace KWin +{ + +class SphereEffectConfigForm : public QWidget, public Ui::SphereEffectConfigForm +{ + Q_OBJECT + public: + explicit SphereEffectConfigForm(QWidget* parent); +}; + +class SphereEffectConfig : public KCModule + { + Q_OBJECT + public: + explicit SphereEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); + + public slots: + virtual void save(); + virtual void load(); + virtual void defaults(); + + private slots: + void capsSelectionChanged(); + void showFileDialog(); + void wallpaperSelected(); + private: + SphereEffectConfigForm* m_ui; + KActionCollection* m_actionCollection; + KFileDialog* m_dialog; + }; + +} // namespace + +#endif diff --git a/effects/sphere_config.ui b/effects/sphere_config.ui new file mode 100644 index 0000000000..ef36d205bd --- /dev/null +++ b/effects/sphere_config.ui @@ -0,0 +1,283 @@ + + KWin::SphereEffectConfigForm + + + + 0 + 0 + 400 + 490 + + + + + + + Appearance + + + + + + Rotation &duration: + + + rotationDurationSpin + + + + + + + msec + + + 5000 + + + 500 + + + + + + + Cube &opacity: + + + cubeOpacitySpin + + + + + + + + + + + + 100 + + + 1 + + + 100 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 10 + + + + + + + + + Fully transparent + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Fully opaque + + + + + + + + + + + % + + + 100 + + + 100 + + + + + + + Display desktop &name + + + + + + + &Background Color: + + + backgroundColorButton + + + + + + + + + + Cube &Caps + + + + + + + C&ap Color: + + + capColorButton + + + + + + + + + + Display &image on cube caps + + + + + + + S&pan cube on all screens + + + + + + + Screen &edge: + + + screenEdgeCombo + + + + + + + &Wallpaper: + + + wallpaperLineEdit + + + + + + + + + + + + + + + + + + + + + + + + + + + + KColorButton + QPushButton +
kcolorbutton.h
+
+ + KWin::GlobalShortcutsEditor + QWidget +
kwineffects.h
+ 1 +
+
+ + screenEdgeCombo + rotationDurationSpin + cubeOpacitySpin + cubeOpacitySlider + displayDesktopNameBox + backgroundColorButton + wallpaperLineEdit + wallpaperButton + cubeCapsBox + capColorButton + capsImageBox + bigCubeBox + + + + + cubeOpacitySpin + valueChanged(int) + cubeOpacitySlider + setValue(int) + + + 386 + 175 + + + 235 + 162 + + + + + cubeOpacitySlider + valueChanged(int) + cubeOpacitySpin + setValue(int) + + + 133 + 162 + + + 386 + 175 + + + + +