add more spacing
[personal-kdebase.git] / workspace / kcontrol / style / kcmstyle.cpp
blobc120fd7ba24d6b73241d91a1699f54284e529f43
1 /*
2 * KCMStyle
3 * Copyright (C) 2002 Karol Szwed <gallium@kde.org>
4 * Copyright (C) 2002 Daniel Molkentin <molkentin@kde.org>
5 * Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org>
7 * Portions Copyright (C) 2000 TrollTech AS.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License version 2 as published by the Free Software Foundation.
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 GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #include "kcmstyle.h"
26 #ifdef Q_WS_X11
27 #include <config-X11.h>
28 #endif
30 #include "styleconfdialog.h"
31 #include "ui_stylepreview.h"
33 #include <kaboutdata.h>
34 #include <kapplication.h>
35 #include <kcombobox.h>
36 #include <kmessagebox.h>
37 #include <kstyle.h>
38 #include <kstandarddirs.h>
39 #include <KDebug>
41 #include <QtCore/QFile>
42 #include <QtCore/QSettings>
43 #include <QtGui/QLabel>
44 #include <QtGui/QPixmapCache>
45 #include <QtGui/QStyleFactory>
46 #include <QtGui/QFormLayout>
47 #include <QtDBus/QtDBus>
49 #ifdef Q_WS_X11
50 #include <QX11Info>
51 #endif
53 #include "../krdb/krdb.h"
55 #ifdef Q_WS_X11
56 #include <X11/Xlib.h>
57 #endif
59 // X11 namespace cleanup
60 #undef Below
61 #undef KeyPress
62 #undef KeyRelease
65 /**** DLL Interface for kcontrol ****/
67 #include <kpluginfactory.h>
68 #include <kpluginloader.h>
69 #include <KLibLoader>
71 K_PLUGIN_FACTORY(KCMStyleFactory, registerPlugin<KCMStyle>();)
72 K_EXPORT_PLUGIN(KCMStyleFactory("kcmstyle"))
75 extern "C"
77 KDE_EXPORT void kcminit_style()
79 uint flags = KRdbExportQtSettings | KRdbExportQtColors | KRdbExportXftSettings;
80 KConfig _config( "kcmdisplayrc", KConfig::NoGlobals );
81 KConfigGroup config(&_config, "X11");
83 // This key is written by the "colors" module.
84 bool exportKDEColors = config.readEntry("exportKDEColors", true);
85 if (exportKDEColors)
86 flags |= KRdbExportColors;
87 runRdb( flags );
89 // Write some Qt root property.
90 #ifdef Q_WS_X11
91 #ifndef __osf__ // this crashes under Tru64 randomly -- will fix later
92 QByteArray properties;
93 QDataStream d(&properties, QIODevice::WriteOnly);
94 d.setVersion( 3 ); // Qt2 apps need this.
95 d << kapp->palette() << KGlobalSettings::generalFont();
96 Atom a = XInternAtom(QX11Info::display(), "_QT_DESKTOP_PROPERTIES", false);
98 // do it for all root windows - multihead support
99 int screen_count = ScreenCount(QX11Info::display());
100 for (int i = 0; i < screen_count; i++)
101 XChangeProperty(QX11Info::display(), RootWindow(QX11Info::display(), i),
102 a, a, 8, PropModeReplace,
103 (unsigned char*) properties.data(), properties.size());
104 #endif
105 #endif
109 class StylePreview : public QWidget, public Ui::StylePreview
111 public:
112 StylePreview(QWidget *parent = 0)
113 : QWidget(parent)
115 setupUi(this);
117 // Ensure that the user can't toy with the child widgets.
118 // Method borrowed from Qt's qtconfig.
119 QList<QWidget*> widgets = findChildren<QWidget*>();
120 foreach (QWidget* widget, widgets)
122 widget->installEventFilter(this);
123 widget->setFocusPolicy(Qt::NoFocus);
127 bool eventFilter( QObject* /* obj */, QEvent* ev )
129 switch( ev->type() )
131 case QEvent::MouseButtonPress:
132 case QEvent::MouseButtonRelease:
133 case QEvent::MouseButtonDblClick:
134 case QEvent::MouseMove:
135 case QEvent::KeyPress:
136 case QEvent::KeyRelease:
137 case QEvent::Enter:
138 case QEvent::Leave:
139 case QEvent::Wheel:
140 case QEvent::ContextMenu:
141 return true; // ignore
142 default:
143 break;
145 return false;
150 KCMStyle::KCMStyle( QWidget* parent, const QVariantList& )
151 : KCModule( KCMStyleFactory::componentData(), parent ), appliedStyle(NULL)
153 setQuickHelp( i18n("<h1>Style</h1>"
154 "This module allows you to modify the visual appearance "
155 "of user interface elements, such as the widget style "
156 "and effects."));
158 m_bStyleDirty= false;
159 m_bEffectsDirty = false;
161 KGlobal::dirs()->addResourceType("themes", "data", "kstyle/themes");
163 KAboutData *about =
164 new KAboutData( I18N_NOOP("kcmstyle"), 0,
165 ki18n("KDE Style Module"),
166 0, KLocalizedString(), KAboutData::License_GPL,
167 ki18n("(c) 2002 Karol Szwed, Daniel Molkentin"));
169 about->addAuthor(ki18n("Karol Szwed"), KLocalizedString(), "gallium@kde.org");
170 about->addAuthor(ki18n("Daniel Molkentin"), KLocalizedString(), "molkentin@kde.org");
171 about->addAuthor(ki18n("Ralf Nolden"), KLocalizedString(), "nolden@kde.org");
172 setAboutData( about );
174 // Setup pages and mainLayout
175 mainLayout = new QVBoxLayout( this );
176 mainLayout->setMargin(0);
178 tabWidget = new QTabWidget( this );
179 mainLayout->addWidget( tabWidget );
181 page1 = new QWidget;
182 page1Layout = new QVBoxLayout( page1 );
184 // Add Page1 (Style)
185 // -----------------
186 //gbWidgetStyle = new QGroupBox( i18n("Widget Style"), page1 );
187 QWidget* gbWidgetStyle = new QWidget( page1 );
188 QVBoxLayout *widgetLayout = new QVBoxLayout(gbWidgetStyle);
190 gbWidgetStyleLayout = new QVBoxLayout;
191 widgetLayout->addLayout( gbWidgetStyleLayout );
192 gbWidgetStyleLayout->setAlignment( Qt::AlignTop );
193 hbLayout = new QHBoxLayout( );
194 hbLayout->setObjectName( "hbLayout" );
196 QLabel* label=new QLabel(i18n("Widget style:"),this);
197 label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
198 hbLayout->addWidget( label );
200 cbStyle = new KComboBox( gbWidgetStyle );
201 cbStyle->setObjectName( "cbStyle" );
202 cbStyle->setEditable( false );
203 cbStyle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
204 hbLayout->addWidget( cbStyle );
205 label->setBuddy(cbStyle);
207 pbConfigStyle = new QPushButton( i18n("Con&figure..."), gbWidgetStyle );
208 pbConfigStyle->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Minimum );
209 pbConfigStyle->setEnabled( false );
210 hbLayout->addWidget( pbConfigStyle );
212 gbWidgetStyleLayout->addLayout( hbLayout );
214 lblStyleDesc = new QLabel( gbWidgetStyle );
215 gbWidgetStyleLayout->addWidget( lblStyleDesc );
217 QGroupBox *gbPreview = new QGroupBox( i18n( "Preview" ), page1 );
218 QVBoxLayout *previewLayout = new QVBoxLayout(gbPreview);
219 previewLayout->setMargin( 0 );
220 stylePreview = new StylePreview( gbPreview );
221 gbPreview->layout()->addWidget( stylePreview );
223 page1Layout->addWidget( gbWidgetStyle );
224 page1Layout->addWidget( gbPreview );
225 page1Layout->addStretch();
227 connect( cbStyle, SIGNAL(activated(int)), this, SLOT(styleChanged()) );
228 connect( cbStyle, SIGNAL(activated(int)), this, SLOT(updateConfigButton()));
229 connect( pbConfigStyle, SIGNAL(clicked()), this, SLOT(styleSpecificConfig()));
231 // Add Page2 (Effects)
232 // -------------------
233 page2 = new QWidget;
234 QFormLayout* page2Layout = new QFormLayout( page2 );
236 comboGraphicEffectsLevel = new KComboBox( page2 );
237 comboGraphicEffectsLevel->setObjectName( "cbGraphicEffectsLevel" );
238 comboGraphicEffectsLevel->setEditable( false );
239 comboGraphicEffectsLevel->addItem(i18n("Low display resolution and Low CPU"), KGlobalSettings::NoEffects);
240 comboGraphicEffectsLevel->addItem(i18n("High display resolution and Low CPU"), KGlobalSettings::GradientEffects);
241 comboGraphicEffectsLevel->addItem(i18n("Low display resolution and High CPU"), KGlobalSettings::SimpleAnimationEffects);
242 comboGraphicEffectsLevel->addItem(i18n("High display resolution and High CPU"), (int) (KGlobalSettings::SimpleAnimationEffects | KGlobalSettings::GradientEffects));
243 comboGraphicEffectsLevel->addItem(i18n("Low display resolution and Very High CPU"), KGlobalSettings::ComplexAnimationEffects);
244 comboGraphicEffectsLevel->addItem(i18n("High display resolution and Very High CPU"), (int) (KGlobalSettings::ComplexAnimationEffects | KGlobalSettings::GradientEffects));
245 page2Layout->addRow(i18nc("@label:listbox","Graphical User Interface:"), comboGraphicEffectsLevel);
247 comboToolbarIcons = new QComboBox( page2 );
248 comboToolbarIcons->setEditable( false );
249 comboToolbarIcons->addItem( i18n("Icons Only") );
250 comboToolbarIcons->addItem( i18n("Text Only") );
251 comboToolbarIcons->addItem( i18n("Text Alongside Icons") );
252 comboToolbarIcons->addItem( i18n("Text Under Icons") );
253 comboToolbarIcons->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
254 page2Layout->addRow(i18nc("@label:listbox","Text pos&ition:"), comboToolbarIcons);
256 cbIconsOnButtons = new QCheckBox( i18nc("@option:check","Sho&w icons on buttons"), page2 );
257 page2Layout->addRow(cbIconsOnButtons);
259 connect(cbStyle, SIGNAL(activated(int)), this, SLOT(setStyleDirty()));
260 connect( cbIconsOnButtons, SIGNAL(toggled(bool)), this, SLOT(setEffectsDirty()));
261 connect( comboGraphicEffectsLevel, SIGNAL(activated(int)), this, SLOT(setEffectsDirty()));
262 connect( comboToolbarIcons, SIGNAL(activated(int)), this, SLOT(setEffectsDirty()));
264 addWhatsThis();
266 // Insert the pages into the tabWidget
267 tabWidget->addTab( page1, i18nc("@title:tab","&Style"));
268 tabWidget->addTab( page2, i18nc("@title:tab","&Fine Tuning"));
273 KCMStyle::~KCMStyle()
275 qDeleteAll(styleEntries);
276 delete appliedStyle;
279 void KCMStyle::updateConfigButton()
281 if (!styleEntries[currentStyle()] || styleEntries[currentStyle()]->configPage.isEmpty()) {
282 pbConfigStyle->setEnabled(false);
283 return;
286 // We don't check whether it's loadable here -
287 // lets us report an error and not waste time
288 // loading things if the user doesn't click the button
289 pbConfigStyle->setEnabled( true );
292 void KCMStyle::styleSpecificConfig()
294 QString libname = styleEntries[currentStyle()]->configPage;
296 KLibrary library(libname, KCMStyleFactory::componentData());
297 if (!library.load()) {
298 KMessageBox::detailedError(this,
299 i18n("There was an error loading the configuration dialog for this style."),
300 library.errorString(),
301 i18n("Unable to Load Dialog"));
302 return;
305 KLibrary::void_function_ptr allocPtr = library.resolveFunction("allocate_kstyle_config");
307 if (!allocPtr)
309 KMessageBox::detailedError(this,
310 i18n("There was an error loading the configuration dialog for this style."),
311 library.errorString(),
312 i18n("Unable to Load Dialog"));
313 return;
316 //Create the container dialog
317 StyleConfigDialog* dial = new StyleConfigDialog(this, styleEntries[currentStyle()]->name);
318 dial->showButtonSeparator(true);
320 typedef QWidget*(* factoryRoutine)( QWidget* parent );
322 //Get the factory, and make the widget.
323 factoryRoutine factory = (factoryRoutine)(allocPtr); //Grmbl. So here I am on my
324 //"never use C casts" moralizing streak, and I find that one can't go void* -> function ptr
325 //even with a reinterpret_cast.
327 QWidget* pluginConfig = factory( dial );
329 //Insert it in...
330 dial->setMainWidget( pluginConfig );
332 //..and connect it to the wrapper
333 connect(pluginConfig, SIGNAL(changed(bool)), dial, SLOT(setDirty(bool)));
334 connect(dial, SIGNAL(defaults()), pluginConfig, SLOT(defaults()));
335 connect(dial, SIGNAL(save()), pluginConfig, SLOT(save()));
337 if (dial->exec() == QDialog::Accepted && dial->isDirty() ) {
338 // Force re-rendering of the preview, to apply settings
339 switchStyle(currentStyle(), true);
341 //For now, ask all KDE apps to recreate their styles to apply the setitngs
342 KGlobalSettings::self()->emitChange(KGlobalSettings::StyleChanged);
344 // We call setStyleDirty here to make sure we force style re-creation
345 setStyleDirty();
348 delete dial;
351 void KCMStyle::changeEvent( QEvent *event )
353 KCModule::changeEvent( event );
354 if ( event->type() == QEvent::PaletteChange ) {
355 // Force re-rendering of the preview, to apply new palette
356 switchStyle(currentStyle(), true);
360 void KCMStyle::load()
362 KConfig config( "kdeglobals", KConfig::FullConfig );
364 loadStyle( config );
365 loadEffects( config );
367 m_bStyleDirty= false;
368 m_bEffectsDirty = false;
369 //Enable/disable the button for the initial style
370 updateConfigButton();
372 emit changed( false );
376 void KCMStyle::save()
378 // Don't do anything if we don't need to.
379 if ( !( m_bStyleDirty | m_bEffectsDirty ) )
380 return;
382 // Save effects.
383 KConfig _config( "kdeglobals" );
384 KConfigGroup config(&_config, "KDE");
386 // Effects page
387 config.writeEntry( "ShowIconsOnPushButtons", cbIconsOnButtons->isChecked(), KConfig::Normal|KConfig::Global);
388 KConfigGroup g( &_config, "KDE-Global GUI Settings" );
389 g.writeEntry( "GraphicEffectsLevel", comboGraphicEffectsLevel->itemData(comboGraphicEffectsLevel->currentIndex()), KConfig::Normal|KConfig::Global);
391 KConfigGroup generalGroup(&_config, "General");
392 generalGroup.writeEntry("widgetStyle", currentStyle());
394 KConfigGroup toolbarStyleGroup(&_config, "Toolbar style");
395 QString tbIcon;
396 switch( comboToolbarIcons->currentIndex() )
398 case 0: tbIcon = "IconOnly"; break;
399 case 1: tbIcon = "TextOnly"; break;
400 case 2: tbIcon = "TextBesideIcon"; break;
401 default:
402 case 3: tbIcon = "TextUnderIcon"; break;
404 toolbarStyleGroup.writeEntry("ToolButtonStyle", tbIcon, KConfig::Normal|KConfig::Global);
405 _config.sync();
407 // Export the changes we made to qtrc, and update all qt-only
408 // applications on the fly, ensuring that we still follow the user's
409 // export fonts/colors settings.
410 if (m_bStyleDirty | m_bEffectsDirty) // Export only if necessary
412 uint flags = KRdbExportQtSettings;
413 KConfig _kconfig( "kcmdisplayrc", KConfig::NoGlobals );
414 KConfigGroup kconfig(&_kconfig, "X11");
415 bool exportKDEColors = kconfig.readEntry("exportKDEColors", true);
416 if (exportKDEColors)
417 flags |= KRdbExportColors;
418 runRdb( flags );
421 // Now allow KDE apps to reconfigure themselves.
422 if ( m_bStyleDirty )
423 KGlobalSettings::self()->emitChange(KGlobalSettings::StyleChanged);
425 if ( m_bEffectsDirty ) {
426 KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged);
427 // ##### FIXME - Doesn't apply all settings correctly due to bugs in
428 // KApplication/KToolbar
429 KGlobalSettings::self()->emitChange(KGlobalSettings::ToolbarStyleChanged);
431 #ifdef Q_WS_X11
432 // Send signal to all kwin instances
433 QDBusMessage message =
434 QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
435 QDBusConnection::sessionBus().send(message);
436 #endif
439 // Clean up
440 m_bStyleDirty = false;
441 m_bEffectsDirty = false;
442 emit changed( false );
446 bool KCMStyle::findStyle( const QString& str, int& combobox_item )
448 StyleEntry* se = styleEntries[str.toLower()];
450 QString name = se ? se->name : str;
452 combobox_item = 0;
454 //look up name
455 for( int i = 0; i < cbStyle->count(); i++ )
457 if ( cbStyle->itemText(i) == name )
459 combobox_item = i;
460 return true;
464 return false;
468 void KCMStyle::defaults()
470 // Select default style
471 int item = 0;
472 bool found;
474 found = findStyle( KStyle::defaultStyle(), item );
475 if (!found)
476 found = findStyle( "plastique", item );
477 if (!found)
478 found = findStyle( "windows", item );
479 if (!found)
480 found = findStyle( "platinum", item );
481 if (!found)
482 found = findStyle( "motif", item );
484 cbStyle->setCurrentIndex( item );
486 m_bStyleDirty = true;
487 switchStyle( currentStyle() ); // make resets visible
489 // Effects
490 comboToolbarIcons->setCurrentIndex(0);
491 cbIconsOnButtons->setChecked(true);
492 comboGraphicEffectsLevel->setCurrentIndex(comboGraphicEffectsLevel->findData(((int) KGlobalSettings::graphicEffectsLevelDefault())));
493 emit changed(true);
496 void KCMStyle::setEffectsDirty()
498 m_bEffectsDirty = true;
499 emit changed(true);
502 void KCMStyle::setStyleDirty()
504 m_bStyleDirty = true;
505 emit changed(true);
508 // ----------------------------------------------------------------
509 // All the Style Switching / Preview stuff
510 // ----------------------------------------------------------------
512 void KCMStyle::loadStyle( KConfig& config )
514 cbStyle->clear();
515 // Create a dictionary of WidgetStyle to Name and Desc. mappings,
516 // as well as the config page info
517 qDeleteAll(styleEntries);
518 styleEntries.clear();
520 QString strWidgetStyle;
521 QStringList list = KGlobal::dirs()->findAllResources("themes", "*.themerc",
522 KStandardDirs::Recursive |
523 KStandardDirs::NoDuplicates);
524 for (QStringList::iterator it = list.begin(); it != list.end(); ++it)
526 KConfig config( *it, KConfig::SimpleConfig);
527 if ( !(config.hasGroup("KDE") && config.hasGroup("Misc")) )
528 continue;
530 KConfigGroup configGroup = config.group("KDE");
532 strWidgetStyle = configGroup.readEntry("WidgetStyle");
533 if (strWidgetStyle.isNull())
534 continue;
536 // We have a widgetstyle, so lets read the i18n entries for it...
537 StyleEntry* entry = new StyleEntry;
538 configGroup = config.group("Misc");
539 entry->name = configGroup.readEntry("Name");
540 entry->desc = configGroup.readEntry("Comment", i18n("No description available."));
541 entry->configPage = configGroup.readEntry("ConfigPage", QString());
543 // Check if this style should be shown
544 configGroup = config.group("Desktop Entry");
545 entry->hidden = configGroup.readEntry("Hidden", false);
547 // Insert the entry into our dictionary.
548 styleEntries.insert(strWidgetStyle.toLower(), entry);
551 // Obtain all style names
552 QStringList allStyles = QStyleFactory::keys();
554 // Get translated names, remove all hidden style entries.
555 QStringList styles;
556 StyleEntry* entry;
557 for (QStringList::iterator it = allStyles.begin(); it != allStyles.end(); ++it)
559 QString id = (*it).toLower();
560 // Find the entry.
561 if ( (entry = styleEntries[id]) != 0 )
563 // Do not add hidden entries
564 if (entry->hidden)
565 continue;
567 styles += entry->name;
569 nameToStyleKey[entry->name] = id;
571 else
573 styles += (*it); //Fall back to the key (but in original case)
574 nameToStyleKey[*it] = id;
578 // Sort the style list, and add it to the combobox
579 styles.sort();
580 cbStyle->addItems( styles );
582 // Find out which style is currently being used
583 KConfigGroup configGroup = config.group( "General" );
584 QString defaultStyle = KStyle::defaultStyle();
585 QString cfgStyle = configGroup.readEntry( "widgetStyle", defaultStyle );
587 // Select the current style
588 // Do not use cbStyle->listBox() as this may be NULL for some styles when
589 // they use QPopupMenus for the drop-down list!
591 // ##### Since Trolltech likes to seemingly copy & paste code,
592 // QStringList::findItem() doesn't have a Qt::StringComparisonMode field.
593 // We roll our own (yuck)
594 cfgStyle = cfgStyle.toLower();
595 int item = 0;
596 for( int i = 0; i < cbStyle->count(); i++ )
598 QString id = nameToStyleKey[cbStyle->itemText(i)];
599 item = i;
600 if ( id == cfgStyle ) // ExactMatch
601 break;
602 else if ( id.contains( cfgStyle ) )
603 break;
604 else if ( id.contains( QApplication::style()->metaObject()->className() ) )
605 break;
606 item = 0;
608 cbStyle->setCurrentIndex( item );
609 m_bStyleDirty = false;
611 switchStyle( currentStyle() ); // make resets visible
614 QString KCMStyle::currentStyle()
616 return nameToStyleKey[cbStyle->currentText()];
620 void KCMStyle::styleChanged()
622 switchStyle( currentStyle() );
626 void KCMStyle::switchStyle(const QString& styleName, bool force)
628 // Don't flicker the preview if the same style is chosen in the cb
629 if (!force && appliedStyle && appliedStyle->objectName() == styleName)
630 return;
632 // Create an instance of the new style...
633 QStyle* style = QStyleFactory::create(styleName);
634 if (!style)
635 return;
637 // Prevent Qt from wrongly caching radio button images
638 QPixmapCache::clear();
640 setStyleRecursive( stylePreview, style );
642 // this flickers, but reliably draws the widgets correctly.
643 stylePreview->resize( stylePreview->sizeHint() );
645 delete appliedStyle;
646 appliedStyle = style;
648 // Set the correct style description
649 StyleEntry* entry = styleEntries[ styleName ];
650 QString desc;
651 desc = i18n("Description: %1", entry ? entry->desc : i18n("No description available.") );
652 lblStyleDesc->setText( desc );
655 void KCMStyle::setStyleRecursive(QWidget* w, QStyle* s)
657 // Don't let broken styles kill the palette
658 // for other styles being previewed. (e.g SGI style)
659 w->setPalette(QPalette());
661 QPalette newPalette(KGlobalSettings::createApplicationPalette());
662 s->polish( newPalette );
663 w->setPalette(newPalette);
665 // Apply the new style.
666 w->setStyle(s);
668 // Recursively update all children.
669 const QObjectList children = w->children();
671 // Apply the style to each child widget.
672 foreach (QObject* child, children)
674 if (child->isWidgetType())
675 setStyleRecursive((QWidget *) child, s);
679 // ----------------------------------------------------------------
680 // All the Effects stuff
681 // ----------------------------------------------------------------
683 void KCMStyle::loadEffects( KConfig& config )
685 // KDE's Part via KConfig
686 KConfigGroup configGroup = config.group("Toolbar style");
688 QString tbIcon = configGroup.readEntry("ToolButtonStyle", "TextUnderIcon");
689 if (tbIcon == "TextOnly")
690 comboToolbarIcons->setCurrentIndex(1);
691 else if (tbIcon == "TextBesideIcon")
692 comboToolbarIcons->setCurrentIndex(2);
693 else if (tbIcon == "TextUnderIcon")
694 comboToolbarIcons->setCurrentIndex(3);
695 else
696 comboToolbarIcons->setCurrentIndex(0);
698 configGroup = config.group("KDE");
699 cbIconsOnButtons->setChecked(configGroup.readEntry("ShowIconsOnPushButtons", true));
701 KConfigGroup graphicConfigGroup = config.group("KDE-Global GUI Settings");
702 comboGraphicEffectsLevel->setCurrentIndex(comboGraphicEffectsLevel->findData(graphicConfigGroup.readEntry("GraphicEffectsLevel", ((int) KGlobalSettings::graphicEffectsLevel()))));
704 m_bEffectsDirty = false;
707 void KCMStyle::addWhatsThis()
709 // Page1
710 cbStyle->setWhatsThis( i18n("Here you can choose from a list of"
711 " predefined widget styles (e.g. the way buttons are drawn) which"
712 " may or may not be combined with a theme (additional information"
713 " like a marble texture or a gradient).") );
714 stylePreview->setWhatsThis( i18n("This area shows a preview of the currently selected style "
715 "without having to apply it to the whole desktop.") );
716 // Page2
717 page2->setWhatsThis( i18n("This page allows you to enable various widget style effects. "
718 "For best performance, it is advisable to disable all effects.") );
719 comboToolbarIcons->setWhatsThis( i18n( "<p><b>Icons only:</b> Shows only icons on toolbar buttons. "
720 "Best option for low resolutions.</p>"
721 "<p><b>Text only: </b>Shows only text on toolbar buttons.</p>"
722 "<p><b>Text alongside icons: </b> Shows icons and text on toolbar buttons. "
723 "Text is aligned alongside the icon.</p>"
724 "<b>Text under icons: </b> Shows icons and text on toolbar buttons. "
725 "Text is aligned below the icon.") );
726 cbIconsOnButtons->setWhatsThis( i18n( "If you enable this option, KDE Applications will "
727 "show small icons alongside some important buttons.") );
728 comboGraphicEffectsLevel->setWhatsThis( i18n( "If you enable this option, KDE Applications will "
729 "run internal animations.") );
732 #include "kcmstyle.moc"
734 // vim: set noet ts=4: