not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kcontrol / style / kcmstyle.cpp
blobde68aa52ddaef68f23a6759eb4d21da0e8052e9e
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->setVisible(false);
238 comboGraphicEffectsLevel->setObjectName( "cbGraphicEffectsLevel" );
239 comboGraphicEffectsLevel->setEditable( false );
240 comboGraphicEffectsLevel->addItem(i18n("Low display resolution and Low CPU"), KGlobalSettings::NoEffects);
241 comboGraphicEffectsLevel->addItem(i18n("High display resolution and Low CPU"), KGlobalSettings::GradientEffects);
242 comboGraphicEffectsLevel->addItem(i18n("Low display resolution and High CPU"), KGlobalSettings::SimpleAnimationEffects);
243 comboGraphicEffectsLevel->addItem(i18n("High display resolution and High CPU"), (int) (KGlobalSettings::SimpleAnimationEffects | KGlobalSettings::GradientEffects));
244 comboGraphicEffectsLevel->addItem(i18n("Low display resolution and Very High CPU"), KGlobalSettings::ComplexAnimationEffects);
245 comboGraphicEffectsLevel->addItem(i18n("High display resolution and Very High CPU"), (int) (KGlobalSettings::ComplexAnimationEffects | KGlobalSettings::GradientEffects));
246 //page2Layout->addRow(i18nc("@label:listbox","Graphical User Interface:"), comboGraphicEffectsLevel);
248 comboToolbarIcons = new QComboBox( page2 );
249 comboToolbarIcons->setEditable( false );
250 comboToolbarIcons->addItem( i18n("Icons Only") );
251 comboToolbarIcons->addItem( i18n("Text Only") );
252 comboToolbarIcons->addItem( i18n("Text Alongside Icons") );
253 comboToolbarIcons->addItem( i18n("Text Under Icons") );
254 comboToolbarIcons->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
255 page2Layout->addRow(i18nc("@label:listbox","Text pos&ition:"), comboToolbarIcons);
257 cbIconsOnButtons = new QCheckBox( i18nc("@option:check","Sho&w icons on buttons"), page2 );
258 page2Layout->addRow(cbIconsOnButtons);
260 connect(cbStyle, SIGNAL(activated(int)), this, SLOT(setStyleDirty()));
261 connect( cbIconsOnButtons, SIGNAL(toggled(bool)), this, SLOT(setEffectsDirty()));
262 connect( comboGraphicEffectsLevel, SIGNAL(activated(int)), this, SLOT(setEffectsDirty()));
263 connect( comboToolbarIcons, SIGNAL(activated(int)), this, SLOT(setEffectsDirty()));
265 addWhatsThis();
267 // Insert the pages into the tabWidget
268 tabWidget->addTab( page1, i18nc("@title:tab","&Style"));
269 tabWidget->addTab( page2, i18nc("@title:tab","&Fine Tuning"));
274 KCMStyle::~KCMStyle()
276 qDeleteAll(styleEntries);
277 delete appliedStyle;
280 void KCMStyle::updateConfigButton()
282 if (!styleEntries[currentStyle()] || styleEntries[currentStyle()]->configPage.isEmpty()) {
283 pbConfigStyle->setEnabled(false);
284 return;
287 // We don't check whether it's loadable here -
288 // lets us report an error and not waste time
289 // loading things if the user doesn't click the button
290 pbConfigStyle->setEnabled( true );
293 void KCMStyle::styleSpecificConfig()
295 QString libname = styleEntries[currentStyle()]->configPage;
297 KLibrary library(libname, KCMStyleFactory::componentData());
298 if (!library.load()) {
299 KMessageBox::detailedError(this,
300 i18n("There was an error loading the configuration dialog for this style."),
301 library.errorString(),
302 i18n("Unable to Load Dialog"));
303 return;
306 KLibrary::void_function_ptr allocPtr = library.resolveFunction("allocate_kstyle_config");
308 if (!allocPtr)
310 KMessageBox::detailedError(this,
311 i18n("There was an error loading the configuration dialog for this style."),
312 library.errorString(),
313 i18n("Unable to Load Dialog"));
314 return;
317 //Create the container dialog
318 StyleConfigDialog* dial = new StyleConfigDialog(this, styleEntries[currentStyle()]->name);
319 dial->showButtonSeparator(true);
321 typedef QWidget*(* factoryRoutine)( QWidget* parent );
323 //Get the factory, and make the widget.
324 factoryRoutine factory = (factoryRoutine)(allocPtr); //Grmbl. So here I am on my
325 //"never use C casts" moralizing streak, and I find that one can't go void* -> function ptr
326 //even with a reinterpret_cast.
328 QWidget* pluginConfig = factory( dial );
330 //Insert it in...
331 dial->setMainWidget( pluginConfig );
333 //..and connect it to the wrapper
334 connect(pluginConfig, SIGNAL(changed(bool)), dial, SLOT(setDirty(bool)));
335 connect(dial, SIGNAL(defaults()), pluginConfig, SLOT(defaults()));
336 connect(dial, SIGNAL(save()), pluginConfig, SLOT(save()));
338 if (dial->exec() == QDialog::Accepted && dial->isDirty() ) {
339 // Force re-rendering of the preview, to apply settings
340 switchStyle(currentStyle(), true);
342 //For now, ask all KDE apps to recreate their styles to apply the setitngs
343 KGlobalSettings::self()->emitChange(KGlobalSettings::StyleChanged);
345 // We call setStyleDirty here to make sure we force style re-creation
346 setStyleDirty();
349 delete dial;
352 void KCMStyle::changeEvent( QEvent *event )
354 KCModule::changeEvent( event );
355 if ( event->type() == QEvent::PaletteChange ) {
356 // Force re-rendering of the preview, to apply new palette
357 switchStyle(currentStyle(), true);
361 void KCMStyle::load()
363 KConfig config( "kdeglobals", KConfig::FullConfig );
365 loadStyle( config );
366 loadEffects( config );
368 m_bStyleDirty= false;
369 m_bEffectsDirty = false;
370 //Enable/disable the button for the initial style
371 updateConfigButton();
373 emit changed( false );
377 void KCMStyle::save()
379 // Don't do anything if we don't need to.
380 if ( !( m_bStyleDirty | m_bEffectsDirty ) )
381 return;
383 // Save effects.
384 KConfig _config( "kdeglobals" );
385 KConfigGroup config(&_config, "KDE");
387 // Effects page
388 config.writeEntry( "ShowIconsOnPushButtons", cbIconsOnButtons->isChecked(), KConfig::Normal|KConfig::Global);
389 KConfigGroup g( &_config, "KDE-Global GUI Settings" );
390 g.writeEntry( "GraphicEffectsLevel", comboGraphicEffectsLevel->itemData(comboGraphicEffectsLevel->currentIndex()), KConfig::Normal|KConfig::Global);
392 KConfigGroup generalGroup(&_config, "General");
393 generalGroup.writeEntry("widgetStyle", currentStyle());
395 KConfigGroup toolbarStyleGroup(&_config, "Toolbar style");
396 QString tbIcon;
397 switch( comboToolbarIcons->currentIndex() )
399 case 0: tbIcon = "IconOnly"; break;
400 case 1: tbIcon = "TextOnly"; break;
401 case 2: tbIcon = "TextBesideIcon"; break;
402 default:
403 case 3: tbIcon = "TextUnderIcon"; break;
405 toolbarStyleGroup.writeEntry("ToolButtonStyle", tbIcon, KConfig::Normal|KConfig::Global);
406 _config.sync();
408 // Export the changes we made to qtrc, and update all qt-only
409 // applications on the fly, ensuring that we still follow the user's
410 // export fonts/colors settings.
411 if (m_bStyleDirty | m_bEffectsDirty) // Export only if necessary
413 uint flags = KRdbExportQtSettings;
414 KConfig _kconfig( "kcmdisplayrc", KConfig::NoGlobals );
415 KConfigGroup kconfig(&_kconfig, "X11");
416 bool exportKDEColors = kconfig.readEntry("exportKDEColors", true);
417 if (exportKDEColors)
418 flags |= KRdbExportColors;
419 runRdb( flags );
422 // Now allow KDE apps to reconfigure themselves.
423 if ( m_bStyleDirty )
424 KGlobalSettings::self()->emitChange(KGlobalSettings::StyleChanged);
426 if ( m_bEffectsDirty ) {
427 KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged);
428 // ##### FIXME - Doesn't apply all settings correctly due to bugs in
429 // KApplication/KToolbar
430 KGlobalSettings::self()->emitChange(KGlobalSettings::ToolbarStyleChanged);
432 #ifdef Q_WS_X11
433 // Send signal to all kwin instances
434 QDBusMessage message =
435 QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
436 QDBusConnection::sessionBus().send(message);
437 #endif
440 // Clean up
441 m_bStyleDirty = false;
442 m_bEffectsDirty = false;
443 emit changed( false );
447 bool KCMStyle::findStyle( const QString& str, int& combobox_item )
449 StyleEntry* se = styleEntries[str.toLower()];
451 QString name = se ? se->name : str;
453 combobox_item = 0;
455 //look up name
456 for( int i = 0; i < cbStyle->count(); i++ )
458 if ( cbStyle->itemText(i) == name )
460 combobox_item = i;
461 return true;
465 return false;
469 void KCMStyle::defaults()
471 // Select default style
472 int item = 0;
473 bool found;
475 found = findStyle( KStyle::defaultStyle(), item );
476 if (!found)
477 found = findStyle( "plastique", item );
478 if (!found)
479 found = findStyle( "windows", item );
480 if (!found)
481 found = findStyle( "platinum", item );
482 if (!found)
483 found = findStyle( "motif", item );
485 cbStyle->setCurrentIndex( item );
487 m_bStyleDirty = true;
488 switchStyle( currentStyle() ); // make resets visible
490 // Effects
491 comboToolbarIcons->setCurrentIndex(0);
492 cbIconsOnButtons->setChecked(true);
493 comboGraphicEffectsLevel->setCurrentIndex(comboGraphicEffectsLevel->findData(((int) KGlobalSettings::graphicEffectsLevelDefault())));
494 emit changed(true);
497 void KCMStyle::setEffectsDirty()
499 m_bEffectsDirty = true;
500 emit changed(true);
503 void KCMStyle::setStyleDirty()
505 m_bStyleDirty = true;
506 emit changed(true);
509 // ----------------------------------------------------------------
510 // All the Style Switching / Preview stuff
511 // ----------------------------------------------------------------
513 void KCMStyle::loadStyle( KConfig& config )
515 cbStyle->clear();
516 // Create a dictionary of WidgetStyle to Name and Desc. mappings,
517 // as well as the config page info
518 qDeleteAll(styleEntries);
519 styleEntries.clear();
521 QString strWidgetStyle;
522 QStringList list = KGlobal::dirs()->findAllResources("themes", "*.themerc",
523 KStandardDirs::Recursive |
524 KStandardDirs::NoDuplicates);
525 for (QStringList::iterator it = list.begin(); it != list.end(); ++it)
527 KConfig config( *it, KConfig::SimpleConfig);
528 if ( !(config.hasGroup("KDE") && config.hasGroup("Misc")) )
529 continue;
531 KConfigGroup configGroup = config.group("KDE");
533 strWidgetStyle = configGroup.readEntry("WidgetStyle");
534 if (strWidgetStyle.isNull())
535 continue;
537 // We have a widgetstyle, so lets read the i18n entries for it...
538 StyleEntry* entry = new StyleEntry;
539 configGroup = config.group("Misc");
540 entry->name = configGroup.readEntry("Name");
541 entry->desc = configGroup.readEntry("Comment", i18n("No description available."));
542 entry->configPage = configGroup.readEntry("ConfigPage", QString());
544 // Check if this style should be shown
545 configGroup = config.group("Desktop Entry");
546 entry->hidden = configGroup.readEntry("Hidden", false);
548 // Insert the entry into our dictionary.
549 styleEntries.insert(strWidgetStyle.toLower(), entry);
552 // Obtain all style names
553 QStringList allStyles = QStyleFactory::keys();
555 // Get translated names, remove all hidden style entries.
556 QStringList styles;
557 StyleEntry* entry;
558 for (QStringList::iterator it = allStyles.begin(); it != allStyles.end(); ++it)
560 QString id = (*it).toLower();
561 // Find the entry.
562 if ( (entry = styleEntries[id]) != 0 )
564 // Do not add hidden entries
565 if (entry->hidden)
566 continue;
568 styles += entry->name;
570 nameToStyleKey[entry->name] = id;
572 else
574 styles += (*it); //Fall back to the key (but in original case)
575 nameToStyleKey[*it] = id;
579 // Sort the style list, and add it to the combobox
580 styles.sort();
581 cbStyle->addItems( styles );
583 // Find out which style is currently being used
584 KConfigGroup configGroup = config.group( "General" );
585 QString defaultStyle = KStyle::defaultStyle();
586 QString cfgStyle = configGroup.readEntry( "widgetStyle", defaultStyle );
588 // Select the current style
589 // Do not use cbStyle->listBox() as this may be NULL for some styles when
590 // they use QPopupMenus for the drop-down list!
592 // ##### Since Trolltech likes to seemingly copy & paste code,
593 // QStringList::findItem() doesn't have a Qt::StringComparisonMode field.
594 // We roll our own (yuck)
595 cfgStyle = cfgStyle.toLower();
596 int item = 0;
597 for( int i = 0; i < cbStyle->count(); i++ )
599 QString id = nameToStyleKey[cbStyle->itemText(i)];
600 item = i;
601 if ( id == cfgStyle ) // ExactMatch
602 break;
603 else if ( id.contains( cfgStyle ) )
604 break;
605 else if ( id.contains( QApplication::style()->metaObject()->className() ) )
606 break;
607 item = 0;
609 cbStyle->setCurrentIndex( item );
610 m_bStyleDirty = false;
612 switchStyle( currentStyle() ); // make resets visible
615 QString KCMStyle::currentStyle()
617 return nameToStyleKey[cbStyle->currentText()];
621 void KCMStyle::styleChanged()
623 switchStyle( currentStyle() );
627 void KCMStyle::switchStyle(const QString& styleName, bool force)
629 // Don't flicker the preview if the same style is chosen in the cb
630 if (!force && appliedStyle && appliedStyle->objectName() == styleName)
631 return;
633 // Create an instance of the new style...
634 QStyle* style = QStyleFactory::create(styleName);
635 if (!style)
636 return;
638 // Prevent Qt from wrongly caching radio button images
639 QPixmapCache::clear();
641 setStyleRecursive( stylePreview, style );
643 // this flickers, but reliably draws the widgets correctly.
644 stylePreview->resize( stylePreview->sizeHint() );
646 delete appliedStyle;
647 appliedStyle = style;
649 // Set the correct style description
650 StyleEntry* entry = styleEntries[ styleName ];
651 QString desc;
652 desc = i18n("Description: %1", entry ? entry->desc : i18n("No description available.") );
653 lblStyleDesc->setText( desc );
656 void KCMStyle::setStyleRecursive(QWidget* w, QStyle* s)
658 // Don't let broken styles kill the palette
659 // for other styles being previewed. (e.g SGI style)
660 w->setPalette(QPalette());
662 QPalette newPalette(KGlobalSettings::createApplicationPalette());
663 s->polish( newPalette );
664 w->setPalette(newPalette);
666 // Apply the new style.
667 w->setStyle(s);
669 // Recursively update all children.
670 const QObjectList children = w->children();
672 // Apply the style to each child widget.
673 foreach (QObject* child, children)
675 if (child->isWidgetType())
676 setStyleRecursive((QWidget *) child, s);
680 // ----------------------------------------------------------------
681 // All the Effects stuff
682 // ----------------------------------------------------------------
684 void KCMStyle::loadEffects( KConfig& config )
686 // KDE's Part via KConfig
687 KConfigGroup configGroup = config.group("Toolbar style");
689 QString tbIcon = configGroup.readEntry("ToolButtonStyle", "TextUnderIcon");
690 if (tbIcon == "TextOnly")
691 comboToolbarIcons->setCurrentIndex(1);
692 else if (tbIcon == "TextBesideIcon")
693 comboToolbarIcons->setCurrentIndex(2);
694 else if (tbIcon == "TextUnderIcon")
695 comboToolbarIcons->setCurrentIndex(3);
696 else
697 comboToolbarIcons->setCurrentIndex(0);
699 configGroup = config.group("KDE");
700 cbIconsOnButtons->setChecked(configGroup.readEntry("ShowIconsOnPushButtons", true));
702 KConfigGroup graphicConfigGroup = config.group("KDE-Global GUI Settings");
703 comboGraphicEffectsLevel->setCurrentIndex(comboGraphicEffectsLevel->findData(graphicConfigGroup.readEntry("GraphicEffectsLevel", ((int) KGlobalSettings::graphicEffectsLevel()))));
705 m_bEffectsDirty = false;
708 void KCMStyle::addWhatsThis()
710 // Page1
711 cbStyle->setWhatsThis( i18n("Here you can choose from a list of"
712 " predefined widget styles (e.g. the way buttons are drawn) which"
713 " may or may not be combined with a theme (additional information"
714 " like a marble texture or a gradient).") );
715 stylePreview->setWhatsThis( i18n("This area shows a preview of the currently selected style "
716 "without having to apply it to the whole desktop.") );
717 // Page2
718 page2->setWhatsThis( i18n("This page allows you to enable various widget style effects. "
719 "For best performance, it is advisable to disable all effects.") );
720 comboToolbarIcons->setWhatsThis( i18n( "<p><b>Icons only:</b> Shows only icons on toolbar buttons. "
721 "Best option for low resolutions.</p>"
722 "<p><b>Text only: </b>Shows only text on toolbar buttons.</p>"
723 "<p><b>Text alongside icons: </b> Shows icons and text on toolbar buttons. "
724 "Text is aligned alongside the icon.</p>"
725 "<b>Text under icons: </b> Shows icons and text on toolbar buttons. "
726 "Text is aligned below the icon.") );
727 cbIconsOnButtons->setWhatsThis( i18n( "If you enable this option, KDE Applications will "
728 "show small icons alongside some important buttons.") );
729 comboGraphicEffectsLevel->setWhatsThis( i18n( "If you enable this option, KDE Applications will "
730 "run internal animations.") );
733 #include "kcmstyle.moc"
735 // vim: set noet ts=4: