add more spacing
[personal-kdebase.git] / workspace / kwin / effects / presentwindows_config.cpp
blobd173bd7bc36f841833322cb3d66644109f3391f5
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
6 Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *********************************************************************/
22 #include "presentwindows_config.h"
23 #include <kwineffects.h>
25 #include <kconfiggroup.h>
26 #include <KActionCollection>
27 #include <kaction.h>
29 #include <QVBoxLayout>
30 #include <QColor>
31 #ifndef KDE_USE_FINAL
32 KWIN_EFFECT_CONFIG_FACTORY
33 #endif
35 namespace KWin
38 PresentWindowsEffectConfigForm::PresentWindowsEffectConfigForm(QWidget* parent) : QWidget(parent)
40 setupUi(this);
43 PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QVariantList& args)
44 : KCModule( EffectFactory::componentData(), parent, args )
46 m_ui = new PresentWindowsEffectConfigForm( this );
48 QVBoxLayout* layout = new QVBoxLayout( this );
50 layout->addWidget( m_ui );
52 m_actionCollection = new KActionCollection( this, componentData() );
53 m_actionCollection->setConfigGroup( "PresentWindows" );
54 m_actionCollection->setConfigGlobal( true );
56 KAction* a = (KAction*) m_actionCollection->addAction( "ExposeAll" );
57 a->setText( i18n( "Toggle Present Windows (All desktops)" ));
58 a->setProperty( "isConfigurationAction", true );
59 a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F10 ));
61 KAction* b = (KAction*) m_actionCollection->addAction( "Expose" );
62 b->setText( i18n( "Toggle Present Windows (Current desktop)" ));
63 b->setProperty( "isConfigurationAction", true );
64 b->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F9 ));
66 m_ui->shortcutEditor->addCollection( m_actionCollection );
68 connect( m_ui->layoutCombo, SIGNAL( currentIndexChanged( int )), this, SLOT( changed() ));
69 connect( m_ui->rearrangeDurationSpin, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
70 connect( m_ui->displayTitleBox, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
71 connect( m_ui->displayIconBox, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
72 connect( m_ui->switchingBox, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
73 connect( m_ui->ignoreMinimizedBox, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
74 connect( m_ui->showPanelBox, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
75 connect( m_ui->accuracySlider, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
76 connect( m_ui->fillGapsBox, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
77 connect( m_ui->shortcutEditor, SIGNAL( keyChange() ), this, SLOT( changed() ));
79 load();
82 PresentWindowsEffectConfig::~PresentWindowsEffectConfig()
84 // If save() is called undoChanges() has no effect
85 m_ui->shortcutEditor->undoChanges();
88 void PresentWindowsEffectConfig::load()
90 KCModule::load();
92 KConfigGroup conf = EffectsHandler::effectConfig( "PresentWindows" );
94 int layoutMode = conf.readEntry( "LayoutMode", int( PresentWindowsEffect::LayoutNatural ));
95 m_ui->layoutCombo->setCurrentIndex( layoutMode );
97 m_ui->rearrangeDurationSpin->setValue( conf.readEntry( "RearrangeDuration", 0 ));
99 bool displayTitle = conf.readEntry( "DrawWindowCaptions", true );
100 m_ui->displayTitleBox->setChecked( displayTitle );
102 bool displayIcon = conf.readEntry( "DrawWindowIcons", true );
103 m_ui->displayIconBox->setChecked( displayIcon );
105 bool switching = conf.readEntry( "TabBox", false );
106 m_ui->switchingBox->setChecked( switching );
108 bool ignoreMinimized = conf.readEntry( "IgnoreMinimized", false );
109 m_ui->ignoreMinimizedBox->setChecked( ignoreMinimized );
111 bool showPanel = conf.readEntry( "ShowPanel", false );
112 m_ui->showPanelBox->setChecked( showPanel );
114 int accuracy = conf.readEntry( "Accuracy", 1 );
115 m_ui->accuracySlider->setSliderPosition( accuracy );
117 bool fillGaps = conf.readEntry( "FillGaps", true );
118 m_ui->fillGapsBox->setChecked( fillGaps );
120 emit changed(false);
123 void PresentWindowsEffectConfig::save()
125 KCModule::save();
127 KConfigGroup conf = EffectsHandler::effectConfig( "PresentWindows" );
129 int layoutMode = m_ui->layoutCombo->currentIndex();
130 conf.writeEntry( "LayoutMode", layoutMode );
132 conf.writeEntry( "RearrangeDuration", m_ui->rearrangeDurationSpin->value() );
134 conf.writeEntry( "DrawWindowCaptions", m_ui->displayTitleBox->isChecked() );
135 conf.writeEntry( "DrawWindowIcons", m_ui->displayIconBox->isChecked() );
136 conf.writeEntry( "TabBox", m_ui->switchingBox->isChecked() );
137 conf.writeEntry( "IgnoreMinimized", m_ui->ignoreMinimizedBox->isChecked() );
138 conf.writeEntry( "ShowPanel", m_ui->showPanelBox->isChecked() );
140 int accuracy = m_ui->accuracySlider->value();
141 conf.writeEntry( "Accuracy", accuracy );
143 conf.writeEntry( "FillGaps", m_ui->fillGapsBox->isChecked() );
145 m_ui->shortcutEditor->save();
147 conf.sync();
149 emit changed(false);
150 EffectsHandler::sendReloadMessage( "presentwindows" );
153 void PresentWindowsEffectConfig::defaults()
155 m_ui->layoutCombo->setCurrentIndex( int( PresentWindowsEffect::LayoutNatural ));
156 m_ui->rearrangeDurationSpin->setValue( 0 );
157 m_ui->displayTitleBox->setChecked( true );
158 m_ui->displayIconBox->setChecked( true );
159 m_ui->switchingBox->setChecked( false );
160 m_ui->ignoreMinimizedBox->setChecked( false );
161 m_ui->showPanelBox->setChecked( false );
162 m_ui->accuracySlider->setSliderPosition( 1 );
163 m_ui->fillGapsBox->setChecked( true );
164 m_ui->shortcutEditor->allDefault();
165 emit changed(true);
168 } // namespace
170 #include "presentwindows_config.moc"