add more spacing
[personal-kdebase.git] / workspace / kcontrol / launch / kcmlaunch.cpp
blob522f85aeb18b70c3e19c8b8bdf3351314dd1c760
1 /*
2 * Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
18 #include <QCheckBox>
19 #include <QComboBox>
20 #include <QLabel>
21 #include <QGroupBox>
23 //Added by qt3to4:
24 #include <QVBoxLayout>
25 #include <QGridLayout>
27 #include <kapplication.h>
28 #include <klocale.h>
29 #include <kconfig.h>
30 #include <kdialog.h>
31 #include <knuminput.h>
33 #include "kcmlaunch.h"
34 #include "krunner_interface.h"
35 #include <KPluginFactory>
36 #include <KPluginLoader>
38 K_PLUGIN_FACTORY(LaunchFactory,
39 registerPlugin<LaunchConfig>();
41 K_EXPORT_PLUGIN(LaunchFactory("kcmlaunch"))
44 LaunchConfig::LaunchConfig(QWidget * parent, const QVariantList &)
45 : KCModule(LaunchFactory::componentData(), parent)
47 QVBoxLayout* Form1Layout = new QVBoxLayout( this );
48 Form1Layout->setMargin( 0 );
49 Form1Layout->setSpacing( KDialog::spacingHint() );
51 setQuickHelp( i18n ( "<h1>Launch Feedback</h1>"
52 " You can configure the application-launch feedback here." ) );
54 QGroupBox* GroupBox1 = new QGroupBox(i18n( "Bus&y Cursor" ));
55 GroupBox1->setWhatsThis( i18n(
56 "<h1>Busy Cursor</h1>\n"
57 "KDE offers a busy cursor for application startup notification.\n"
58 "To enable the busy cursor, select one kind of visual feedback\n"
59 "from the combobox.\n"
60 "It may occur, that some applications are not aware of this startup\n"
61 "notification. In this case, the cursor stops blinking after the time\n"
62 "given in the section 'Startup indication timeout'"));
64 QVBoxLayout *lay = new QVBoxLayout;
65 lay->setSpacing( 0 );
66 lay->setMargin( 0 );
67 GroupBox1->setLayout(lay);
68 Form1Layout->addWidget(GroupBox1);
70 QGridLayout* GroupBox1Layout = new QGridLayout();
71 GroupBox1->layout()->addItem( GroupBox1Layout );
72 GroupBox1Layout->setSpacing( 6 );
73 GroupBox1Layout->setMargin( 11 );
74 GroupBox1Layout->setColumnStretch( 1, 1 );
76 cb_busyCursor = new QComboBox( GroupBox1);
77 cb_busyCursor->setObjectName( "cb_busyCursor" );
78 cb_busyCursor->insertItem( 0, i18n( "No Busy Cursor" ) );
79 cb_busyCursor->insertItem( 1, i18n( "Passive Busy Cursor" ) );
80 cb_busyCursor->insertItem( 2, i18n( "Blinking Cursor" ) );
81 cb_busyCursor->insertItem( 3, i18n( "Bouncing Cursor" ) );
82 GroupBox1Layout->addWidget( cb_busyCursor, 0, 0 );
83 connect( cb_busyCursor, SIGNAL( activated(int) ),
84 SLOT ( slotBusyCursor(int)));
85 connect( cb_busyCursor, SIGNAL( activated(int) ), SLOT( checkChanged() ) );
87 lbl_cursorTimeout = new QLabel( GroupBox1 );
88 lbl_cursorTimeout->setObjectName( "TextLabel1" );
89 lbl_cursorTimeout->setText( i18n( "&Startup indication timeout:" ) );
90 GroupBox1Layout->addWidget( lbl_cursorTimeout, 2, 0 );
91 sb_cursorTimeout = new KIntNumInput( GroupBox1);
92 sb_cursorTimeout->setRange( 0, 99 );
93 sb_cursorTimeout->setSuffix( i18n(" sec") );
94 GroupBox1Layout->addWidget( sb_cursorTimeout, 2, 1 );
95 lbl_cursorTimeout->setBuddy( sb_cursorTimeout );
96 connect( sb_cursorTimeout, SIGNAL( valueChanged(int) ),
97 SLOT( checkChanged() ) );
99 QGroupBox* GroupBox2 = new QGroupBox( i18n( "Taskbar &Notification" ) );
100 GroupBox2->setWhatsThis( i18n("<H1>Taskbar Notification</H1>\n"
101 "You can enable a second method of startup notification which is\n"
102 "used by the taskbar where a button with a rotating hourglass appears,\n"
103 "symbolizing that your started application is loading.\n"
104 "It may occur, that some applications are not aware of this startup\n"
105 "notification. In this case, the button disappears after the time\n"
106 "given in the section 'Startup indication timeout'"));
108 lay = new QVBoxLayout;
109 lay->setSpacing( 0 );
110 lay->setMargin( 0 );
111 GroupBox2->setLayout(lay);
112 Form1Layout->addWidget( GroupBox2 );
113 QGridLayout* GroupBox2Layout = new QGridLayout();
114 GroupBox2->layout()->addItem( GroupBox2Layout );
115 GroupBox2Layout->setSpacing( 6 );
116 GroupBox2Layout->setMargin( 11 );
117 GroupBox2Layout->setColumnStretch( 1, 1 );
119 cb_taskbarButton = new QCheckBox( GroupBox2 );
120 cb_taskbarButton->setObjectName( "cb_taskbarButton" );
121 cb_taskbarButton->setText( i18n( "Enable &taskbar notification" ) );
122 GroupBox2Layout->addWidget( cb_taskbarButton, 0, 0, 1, 2 );
123 connect( cb_taskbarButton, SIGNAL( toggled(bool) ),
124 SLOT( slotTaskbarButton(bool)));
125 connect( cb_taskbarButton, SIGNAL( toggled(bool) ), SLOT( checkChanged()));
127 lbl_taskbarTimeout = new QLabel( GroupBox2 );
128 lbl_taskbarTimeout->setObjectName( "TextLabel2" );
129 lbl_taskbarTimeout->setText( i18n( "Start&up indication timeout:" ) );
130 GroupBox2Layout->addWidget( lbl_taskbarTimeout, 1, 0 );
131 sb_taskbarTimeout = new KIntNumInput( GroupBox2);
132 sb_taskbarTimeout->setRange( 0, 99 );
133 sb_taskbarTimeout->setSuffix( i18n(" sec") );
134 GroupBox2Layout->addWidget( sb_taskbarTimeout, 1, 1 );
135 lbl_taskbarTimeout->setBuddy( sb_taskbarTimeout );
136 connect( sb_taskbarTimeout, SIGNAL( valueChanged(int) ),
137 SLOT( checkChanged() ) );
139 Form1Layout->addStretch();
142 LaunchConfig::~LaunchConfig()
146 void
147 LaunchConfig::slotBusyCursor(int i)
149 lbl_cursorTimeout->setEnabled( i != 0 );
150 sb_cursorTimeout->setEnabled( i != 0 );
153 void
154 LaunchConfig::slotTaskbarButton(bool b)
156 lbl_taskbarTimeout->setEnabled( b );
157 sb_taskbarTimeout->setEnabled( b );
160 void
161 LaunchConfig::load()
163 KConfig conf("klaunchrc", KConfig::NoGlobals);
164 KConfigGroup c = conf.group("FeedbackStyle");
166 bool busyCursor =
167 c.readEntry("BusyCursor", (bool)(Default & BusyCursor));
169 bool taskbarButton =
170 c.readEntry("TaskbarButton", (bool)(Default & TaskbarButton));
172 cb_taskbarButton->setChecked(taskbarButton);
174 c= conf.group( "BusyCursorSettings" );
175 sb_cursorTimeout->setValue( c.readEntry( "Timeout", 30 ));
176 bool busyBlinking =c.readEntry("Blinking", false);
177 bool busyBouncing =c.readEntry("Bouncing", true);
178 if ( !busyCursor )
179 cb_busyCursor->setCurrentIndex(0);
180 else if ( busyBlinking )
181 cb_busyCursor->setCurrentIndex(2);
182 else if ( busyBouncing )
183 cb_busyCursor->setCurrentIndex(3);
184 else
185 cb_busyCursor->setCurrentIndex(1);
187 c= conf.group( "TaskbarButtonSettings" );
188 sb_taskbarTimeout->setValue( c.readEntry( "Timeout", 30 ));
190 slotBusyCursor( cb_busyCursor->currentIndex() );
191 slotTaskbarButton( taskbarButton );
193 emit changed( false );
196 void
197 LaunchConfig::save()
199 KConfig conf("klaunchrc", KConfig::NoGlobals);
200 KConfigGroup c = conf.group("FeedbackStyle");
202 c.writeEntry("BusyCursor", cb_busyCursor->currentIndex() != 0);
203 c.writeEntry("TaskbarButton", cb_taskbarButton->isChecked());
205 c = conf.group("BusyCursorSettings");
206 c.writeEntry( "Timeout", sb_cursorTimeout->value());
207 c.writeEntry("Blinking", cb_busyCursor->currentIndex() == 2);
208 c.writeEntry("Bouncing", cb_busyCursor->currentIndex() == 3);
210 c = conf.group("TaskbarButtonSettings");
211 c.writeEntry( "Timeout", sb_taskbarTimeout->value());
213 c.sync();
215 emit changed( false );
217 org::kde::krunner::App desktop("org.kde.krunner", "/App", QDBusConnection::sessionBus());
218 desktop.initializeStartupNotification();
219 //TODO: do we need to replace this with a call to plasma to kick over the taskbar? needs
220 //investigating
221 //QDBusInterface kicker("org.kde.kicker", "/Panel", "org.kde.kicker.Panel");
222 //kicker.call("restart");
225 void
226 LaunchConfig::defaults()
228 cb_busyCursor->setCurrentIndex(2);
229 cb_taskbarButton->setChecked((bool)Default & TaskbarButton);
231 sb_cursorTimeout->setValue( 30 );
232 sb_taskbarTimeout->setValue( 30 );
234 slotBusyCursor( 2 );
235 slotTaskbarButton( (bool)Default & TaskbarButton );
237 checkChanged();
240 void
241 LaunchConfig::checkChanged()
243 KConfig conf("klaunchrc", KConfig::NoGlobals);
244 KConfigGroup c = conf.group("FeedbackStyle");
246 bool savedBusyCursor =
247 c.readEntry("BusyCursor", (bool)(Default & BusyCursor));
249 bool savedTaskbarButton =
250 c.readEntry("TaskbarButton", (bool)(Default & TaskbarButton));
252 c = conf.group("BusyCursorSettings");
253 unsigned int savedCursorTimeout = c.readEntry( "Timeout", 30 );
254 bool savedBusyBlinking =c.readEntry("Blinking", false);
255 bool savedBusyBouncing =c.readEntry("Bouncing", true);
257 c = conf.group("TaskbarButtonSettings");
258 unsigned int savedTaskbarTimeout = c.readEntry( "Timeout", 30 );
260 bool newBusyCursor =cb_busyCursor->currentIndex()!=0;
262 bool newTaskbarButton =cb_taskbarButton->isChecked();
264 bool newBusyBlinking= cb_busyCursor->currentIndex()==2;
265 bool newBusyBouncing= cb_busyCursor->currentIndex()==3;
267 unsigned int newCursorTimeout = sb_cursorTimeout->value();
269 unsigned int newTaskbarTimeout = sb_taskbarTimeout->value();
271 emit changed(
272 savedBusyCursor != newBusyCursor
274 savedTaskbarButton != newTaskbarButton
276 savedCursorTimeout != newCursorTimeout
278 savedTaskbarTimeout != newTaskbarTimeout
280 savedBusyBlinking != newBusyBlinking
282 savedBusyBouncing != newBusyBouncing
286 #include "kcmlaunch.moc"