? .kcmstyle.cpp.rej.swp Index: Makefile.am =================================================================== RCS file: /home/kde/kdebase/kcontrol/style/Makefile.am,v retrieving revision 1.11 diff -u -3 -p -r1.11 Makefile.am --- Makefile.am 12 Jul 2002 17:26:57 -0000 1.11 +++ Makefile.am 21 Jun 2003 21:07:35 -0000 @@ -6,7 +6,7 @@ SUBDIRS = . kde_module_LTLIBRARIES = kcm_style.la -kcm_style_la_SOURCES = kcmstyle.cpp stylepreview.ui menupreview.cpp +kcm_style_la_SOURCES = kcmstyle.cpp stylepreview.ui menupreview.cpp styleconfdialog.cpp kcm_style_la_LDFLAGS = $(KDE_RPATH) -module -avoid-version $(all_libraries) -no-undefined kcm_style_la_LIBADD = $(LIB_KIO) $(top_builddir)/kcontrol/krdb/libkrdb.la kcm_style_la_METASOURCES = AUTO Index: kcmstyle.cpp =================================================================== RCS file: /home/kde/kdebase/kcontrol/style/kcmstyle.cpp,v retrieving revision 1.55 diff -u -3 -p -r1.55 kcmstyle.cpp --- kcmstyle.cpp 21 Jun 2003 09:39:41 -0000 1.55 +++ kcmstyle.cpp 21 Jun 2003 21:07:36 -0000 @@ -5,6 +5,9 @@ * Copyright (C) 2002 Karol Szwed * Copyright (C) 2002 Daniel Molkentin * + * The plugin config page code based heavily on kcmwindecoration, + * Copyright (c) 2001 Karol Szwed + * * Portions Copyright (C) 2000 TrollTech AS. * * This program is free software; you can redistribute it and/or @@ -28,6 +31,9 @@ #include #include +#include +#include +#include #include #include #include @@ -39,8 +45,8 @@ #include #include #include -#include #include +#include #include #include @@ -49,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +65,7 @@ #include "../krdb/krdb.h" #include "kcmstyle.h" +#include "styleconfdialog.h" #include // X11 namespace cleanup @@ -196,6 +204,8 @@ KCMStyle::KCMStyle( QWidget* parent, con // Connect all required stuff connect( cbStyle, SIGNAL(activated(int)), this, SLOT(styleChanged()) ); + connect( cbStyle, SIGNAL(activated(int)), this, SLOT(updateConfigButton())); + connect( pbConfigStyle, SIGNAL(clicked()), this, SLOT(styleSpecificConfig())); // Add Page2 (Effects) // ------------------- @@ -369,14 +379,77 @@ KCMStyle::KCMStyle( QWidget* parent, con tabWidget->insertTab( page1, i18n("&Style")); tabWidget->insertTab( page2, i18n("&Effects")); tabWidget->insertTab( page3, i18n("&Miscellaneous")); -} + updateConfigButton(); +} KCMStyle::~KCMStyle() { delete appliedStyle; } +void KCMStyle::updateConfigButton() +{ + if (!styleEntries[currentStyle] || styleEntries[currentStyle]->configPage.isEmpty()) { + pbConfigStyle->setEnabled(false); + return; + } + + // We don't check whether it's loadable here - + // lets us report an error and not waste time + // loading things if the user doesn't click the button + pbConfigStyle->setEnabled( true ); +} + +void KCMStyle::styleSpecificConfig() +{ + QString libname = styleEntries[currentStyle]->configPage; + + // Use KLibLoader for library manipulation + KLibLoader* loader = KLibLoader::self(); + + KLibrary* library = loader->library( QFile::encodeName(libname) ); + if (!library) + { + KMessageBox::detailedError(this, + i18n("There was an error loading the configuration dialog for this style."), + loader->lastErrorMessage(), + i18n("Unable to load the dialog.")); + return; + } + + void* allocPtr = library->symbol("allocate_kstyle_config"); + + if (!allocPtr) + { + KMessageBox::detailedError(this, + i18n("There was an error loading the configuration dialog for this style."), + loader->lastErrorMessage(), + i18n("Unable to load the dialog.")); + return; + } + + typedef QWidget*(* factoryRoutine)( QWidget* parent ); + + factoryRoutine factory = reinterpret_cast(allocPtr); + StyleConfigDialog *dial = new StyleConfigDialog(this, styleEntries[currentStyle]->name); + dial->enableButtonSeparator(true); + QWidget* pluginConfig = factory( dial ); + dial->setMainWidget( pluginConfig ); + + connect(pluginConfig, SIGNAL(changed(bool)), dial, SLOT(setDirty(bool))); + connect(dial, SIGNAL(defaults()), pluginConfig, SLOT(defaults())); + connect(dial, SIGNAL(save()), pluginConfig, SLOT(save())); + + if (dial->exec() == QDialog::Accepted /* && dial->isDirty() */) { + if ( dial->isDirty() ) { + // Force re-rendering of the preview, to apply settings + setStyleRecursive(stylePreview, appliedStyle); + // We call setStyleDirty here to make sure we force style re-creation + setStyleDirty(); + } + } +} void KCMStyle::load() { @@ -394,6 +467,8 @@ void KCMStyle::load() m_bEffectsDirty = false; m_bStyleDirty= false; m_bToolbarsDirty = false; + + emit pluginLoad(); } @@ -507,6 +582,9 @@ void KCMStyle::save() config.writeEntry( "IconText", tbIcon, true, true ); config.sync(); + // Let any config page save. + emit pluginSave(); + // Export the changes we made to qtrc, and update all qt-only // applications on the fly, ensuring that we still follow the user's // export fonts/colors settings. @@ -592,6 +670,8 @@ void KCMStyle::defaults() cbIconsOnButtons->setChecked(false); cbTearOffHandles->setChecked(false); cbMacMenubar->setChecked(false); + + emit pluginDefaults(); } @@ -651,7 +731,9 @@ void KCMStyle::loadStyle( KSimpleConfig& { cbStyle->clear(); - // Create a dictionary of WidgetStyle to Name and Desc. mappings. + // Create a dictionary of WidgetStyle to Name and Desc. mappings, + // as well as the hidden and config page info + styleEntries.clear(); styleEntries.setAutoDelete(true); QString strWidgetStyle; @@ -671,8 +753,9 @@ void KCMStyle::loadStyle( KSimpleConfig& // We have a widgetstyle, so lets read the i18n entries for it... StyleEntry* entry = new StyleEntry; config.setGroup("Misc"); - entry->name = config.readEntry("Name"); + entry->name = config.readEntry("Name", strWidgetStyle); entry->desc = config.readEntry("Comment", i18n("No description available.")); + entry->configPage = config.readEntry("ConfigPage", QString::null); // Check if this style should be shown config.setGroup("Desktop Entry"); Index: kcmstyle.h =================================================================== RCS file: /home/kde/kdebase/kcontrol/style/kcmstyle.h,v retrieving revision 1.13 diff -u -3 -p -r1.13 kcmstyle.h --- kcmstyle.h 21 Jun 2003 09:39:41 -0000 1.13 +++ kcmstyle.h 21 Jun 2003 21:07:36 -0000 @@ -51,15 +51,17 @@ class QSpacerItem; class QLabel; class QSlider; class KComboBox; +class StyleConfigDialog; struct StyleEntry { QString name; QString desc; + QString configPage; bool hidden; }; class KCMStyle : public KCModule -{ +{ Q_OBJECT public: @@ -82,6 +84,8 @@ protected: void addWhatsThis(); protected slots: + void styleSpecificConfig(); + void updateConfigButton(); // void setDirty(); void setMacDirty(); void setEffectsDirty(); @@ -92,6 +96,11 @@ protected slots: void menuEffectChanged( bool enabled ); void menuEffectChanged(); void menuEffectTypeChanged(); + +signals: + void pluginLoad(); + void pluginSave(); + void pluginDefaults(); private: bool m_bMacDirty, m_bEffectsDirty, m_bStyleDirty, m_bToolbarsDirty; Index: styleconfdialog.cpp =================================================================== RCS file: styleconfdialog.cpp diff -N styleconfdialog.cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ styleconfdialog.cpp 21 Jun 2003 21:07:36 -0000 @@ -0,0 +1,46 @@ +/* + * KCMStyle's container dialog for custom style setup dialogs + * + * (c) 2003 Maksim Orlovich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License version 2 as published by the Free Software Foundation. + * + * 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; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "styleconfdialog.h" +#include + +StyleConfigDialog::StyleConfigDialog(QWidget* parent, QString styleName): + KDialogBase(parent, "StyleConfigDialog", + true, /*modal*/ + i18n("Configure %1").arg(styleName), + KDialogBase::Default | KDialogBase::Ok | KDialogBase::Cancel, + KDialogBase::Cancel) +{ + m_dirty = false; + connect( this, SIGNAL( defaultClicked() ), this, SIGNAL( defaults() )); + connect( this, SIGNAL( okClicked() ), this, SIGNAL( save() )); +} + +bool StyleConfigDialog::isDirty() const +{ + return m_dirty; +} + +void StyleConfigDialog::setDirty(bool dirty) +{ + m_dirty = dirty; +} + +#include Index: styleconfdialog.h =================================================================== RCS file: styleconfdialog.h diff -N styleconfdialog.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ styleconfdialog.h 21 Jun 2003 21:07:36 -0000 @@ -0,0 +1,46 @@ +/* + * KCMStyle's container dialog for custom style setup dialogs + * + * (c) 2003 Maksim Orlovich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License version 2 as published by the Free Software Foundation. + * + * 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; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef STYLE_CONF_DIALOG +#define STYLE_CONF_DIALOG + +#include + + +class StyleConfigDialog: public KDialogBase +{ + Q_OBJECT +public: + StyleConfigDialog(QWidget* parent, QString styleName); + + bool isDirty() const; + +public slots: + void setDirty(bool dirty); + +signals: + void defaults(); + void save(); + +private: + bool m_dirty; +}; + +#endif