summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kcmodule.cpp16
-rw-r--r--microkde/kdeui/kcmodule.h11
-rw-r--r--microkde/kutils/kcmultidialog.cpp13
-rw-r--r--microkde/kutils/kcmultidialog.h5
4 files changed, 25 insertions, 20 deletions
diff --git a/microkde/kdeui/kcmodule.cpp b/microkde/kdeui/kcmodule.cpp
index 915cd0f..f646db3 100644
--- a/microkde/kdeui/kcmodule.cpp
+++ b/microkde/kdeui/kcmodule.cpp
@@ -24,83 +24,91 @@
24//US#include <kinstance.h> 24//US#include <kinstance.h>
25#include <kglobal.h> 25#include <kglobal.h>
26#include <klocale.h> 26#include <klocale.h>
27#include <kdebug.h> 27#include <kdebug.h>
28 28
29class KCModulePrivate 29class KCModulePrivate
30{ 30{
31public: 31public:
32//US KInstance *_instance; 32//US KInstance *_instance;
33 QString _rootOnlyMsg; 33 QString _rootOnlyMsg;
34 bool _useRootOnlyMsg; 34 bool _useRootOnlyMsg;
35 bool _hasOwnInstance; 35 bool _hasOwnInstance;
36 KPrefs* _prefs;
36}; 37};
37 38
38KCModule::KCModule(QWidget *parent, const char *name, const QStringList &) 39KCModule::KCModule(KPrefs* prefs, QWidget *parent, const char *name, const QStringList &)
39 : QWidget(parent, name), _btn(Help|Default|Apply) 40 : QWidget(parent, name), _btn(Help|Default|Apply)
40{ 41{
41 kdDebug() << "KCModule " << name << endl; 42 kdDebug() << "KCModule " << name << endl;
42 d = new KCModulePrivate; 43 d = new KCModulePrivate;
43 d->_useRootOnlyMsg = true; 44 d->_useRootOnlyMsg = true;
44/*US 45 d->_prefs = prefs;
46/*US
45 d->_instance = new KInstance(name); 47 d->_instance = new KInstance(name);
46 if (name && strlen(name)) { 48 if (name && strlen(name)) {
47 d->_instance = new KInstance(name); 49 d->_instance = new KInstance(name);
48 KGlobal::locale()->insertCatalogue(name); 50 KGlobal::locale()->insertCatalogue(name);
49 } else 51 } else
50 d->_instance = new KInstance("kcmunnamed"); 52 d->_instance = new KInstance("kcmunnamed");
51*/ 53*/
52 d->_hasOwnInstance = true; 54 d->_hasOwnInstance = true;
53//US KGlobal::setActiveInstance(this->instance()); 55//US KGlobal::setActiveInstance(this->instance());
54} 56}
55 57
56/*US 58/*US
57KCModule::KCModule(KInstance *instance, QWidget *parent, const QStringList & ) 59KCModule::KCModule(KInstance *instance, QWidget *parent, const QStringList & )
58 : QWidget(parent, instance ? instance->instanceName().data() : 0), _btn(Help|Default|Apply) 60 : QWidget(parent, instance ? instance->instanceName().data() : 0), _btn(Help|Default|Apply)
59{ 61{
60 kdDebug() << "KCModule instance " << (instance ? instance->instanceName().data() : "none") << endl; 62 kdDebug() << "KCModule instance " << (instance ? instance->instanceName().data() : "none") << endl;
61 d = new KCModulePrivate; 63 d = new KCModulePrivate;
62 d->_useRootOnlyMsg = true; 64 d->_useRootOnlyMsg = true;
63 d->_instance = instance; 65 d->_instance = instance;
64 KGlobal::locale()->insertCatalogue(instance->instanceName()); 66 KGlobal::locale()->insertCatalogue(instance->instanceName());
65 d->_hasOwnInstance = false; 67 d->_hasOwnInstance = false;
66 KGlobal::setActiveInstance(this->instance()); 68 KGlobal::setActiveInstance(this->instance());
67} 69}
68*/ 70*/
69KCModule::~KCModule() 71KCModule::~KCModule()
70{ 72{
71/*US 73/*US
72 if (d->_hasOwnInstance) 74 if (d->_hasOwnInstance)
73 delete d->_instance; 75 delete d->_instance;
74*/ 76*/
75 delete d; 77 delete d;
76} 78}
77 79
78void KCModule::setRootOnlyMsg(const QString& msg) 80void KCModule::setRootOnlyMsg(const QString& msg)
79{ 81{
80 d->_rootOnlyMsg = msg; 82 d->_rootOnlyMsg = msg;
81} 83}
82 84
83QString KCModule::rootOnlyMsg() const 85QString KCModule::rootOnlyMsg() const
84{ 86{
85 return d->_rootOnlyMsg; 87 return d->_rootOnlyMsg;
86} 88}
87 89
88void KCModule::setUseRootOnlyMsg(bool on) 90void KCModule::setUseRootOnlyMsg(bool on)
89{ 91{
90 d->_useRootOnlyMsg = on; 92 d->_useRootOnlyMsg = on;
91} 93}
92 94
93bool KCModule::useRootOnlyMsg() const 95bool KCModule::useRootOnlyMsg() const
94{ 96{
95 return d->_useRootOnlyMsg; 97 return d->_useRootOnlyMsg;
96} 98}
99
100KPrefs* KCModule::getPreferences()
101{
102 return d->_prefs;
103}
104
97/*US 105/*US
98KInstance *KCModule::instance() const 106KInstance *KCModule::instance() const
99{ 107{
100 return d->_instance; 108 return d->_instance;
101} 109}
102*/ 110*/
103void KCModule::virtual_hook( int, void* ) 111void KCModule::virtual_hook( int, void* )
104{ /*BASE::virtual_hook( id, data );*/ } 112{ /*BASE::virtual_hook( id, data );*/ }
105 113
106//US #include "kcmodule.moc" 114//US #include "kcmodule.moc"
diff --git a/microkde/kdeui/kcmodule.h b/microkde/kdeui/kcmodule.h
index bc020bc..874958c 100644
--- a/microkde/kdeui/kcmodule.h
+++ b/microkde/kdeui/kcmodule.h
@@ -74,79 +74,79 @@ public:
74 */ 74 */
75 enum Button {Help=1, Default=2, Apply=16, 75 enum Button {Help=1, Default=2, Apply=16,
76 Reset=4, /* obsolete, do not use! */ 76 Reset=4, /* obsolete, do not use! */
77 Cancel=8, /* obsolete, do not use! */ 77 Cancel=8, /* obsolete, do not use! */
78 Ok=32, /* obsolete, do not use! */ 78 Ok=32, /* obsolete, do not use! */
79 SysDefault=64 /* obsolete, do not use! */ }; 79 SysDefault=64 /* obsolete, do not use! */ };
80 80
81 /* 81 /*
82 * Base class for all KControlModules. 82 * Base class for all KControlModules.
83 * Make sure you have a QStringList argument in your 83 * Make sure you have a QStringList argument in your
84 * implementation. 84 * implementation.
85 */ 85 */
86 KCModule(QWidget *parent=0, const char *name=0, const QStringList &args=QStringList() ); 86 KCModule(KPrefs* prefs, QWidget *parent=0, const char *name=0, const QStringList &args=QStringList() );
87 87
88//US KCModule(KInstance *instance, QWidget *parent=0, const QStringList &args=QStringList() ); 88//US KCModule(KInstance *instance, QWidget *parent=0, const QStringList &args=QStringList() );
89 89
90 /* 90 /*
91 * Destroys the module. 91 * Destroys the module.
92 */ 92 */
93 ~KCModule(); 93 ~KCModule();
94 94
95 /** 95 /**
96 * Load the configuration data into the module. 96 * Load the configuration data into the module.
97 * 97 *
98 * The load method sets the user interface elements of the 98 * The load method sets the user interface elements of the
99 * module to reflect the current settings stored in the 99 * module to reflect the current settings stored in the
100 * configuration files. 100 * configuration files.
101 * 101 *
102 * This method is invoked whenever the module should read its configuration 102 * This method is invoked whenever the module should read its configuration
103 * (most of the times from a config file) and update the user interface. 103 * (most of the times from a config file) and update the user interface.
104 * This happens when the user clicks the "Reset" button in the control 104 * This happens when the user clicks the "Reset" button in the control
105 * center, to undo all of his changes and restore the currently valid 105 * center, to undo all of his changes and restore the currently valid
106 * settings. NOTE that this is not called after the modules is loaded, 106 * settings. NOTE that this is not called after the modules is loaded,
107 * so you probably want to call this method in the constructor. 107 * so you probably want to call this method in the constructor.
108 */ 108 */
109 virtual void load(KPrefs* prefs) {}; 109 virtual void load() {};
110 110
111 /** 111 /**
112 * Save the configuration data. 112 * Save the configuration data.
113 * 113 *
114 * The save method stores the config information as shown 114 * The save method stores the config information as shown
115 * in the user interface in the config files. 115 * in the user interface in the config files.
116 * 116 *
117 * If necessary, this method also updates the running system, 117 * If necessary, this method also updates the running system,
118 * e.g. by restarting applications. 118 * e.g. by restarting applications.
119 * 119 *
120 * save is called when the user clicks "Apply" or "Ok". 120 * save is called when the user clicks "Apply" or "Ok".
121 */ 121 */
122 virtual void save(KPrefs* prefs) {}; 122 virtual void save() {};
123 123
124 /** 124 /**
125 * Sets the configuration to sensible default values. 125 * Sets the configuration to sensible default values.
126 * 126 *
127 * This method is called when the user clicks the "Default" 127 * This method is called when the user clicks the "Default"
128 * button. It should set the display to useful values. 128 * button. It should set the display to useful values.
129 */ 129 */
130 virtual void defaults(KPrefs* prefs) {}; 130 virtual void defaults() {};
131 131
132 /** 132 /**
133 * Set the configuration to system default values. 133 * Set the configuration to system default values.
134 * 134 *
135 * This method is called when the user clicks the "System-Default" 135 * This method is called when the user clicks the "System-Default"
136 * button. It should set the display to the system default values. 136 * button. It should set the display to the system default values.
137 * 137 *
138 * NOTE: The default behaviour is to call defaults(). 138 * NOTE: The default behaviour is to call defaults().
139 */ 139 */
140 virtual void sysdefaults(KPrefs* prefs) { defaults(prefs); }; 140 virtual void sysdefaults() { defaults(); };
141 141
142 /** 142 /**
143 * Return a quick-help text. 143 * Return a quick-help text.
144 * 144 *
145 * This method is called when the module is docked. 145 * This method is called when the module is docked.
146 * The quick-help text should contain a short description of the module and 146 * The quick-help text should contain a short description of the module and
147 * links to the module's help files. You can use QML formating tags in the text. 147 * links to the module's help files. You can use QML formating tags in the text.
148 * 148 *
149 * NOTE: Please make sure the quick help text gets translated (use i18n()). 149 * NOTE: Please make sure the quick help text gets translated (use i18n()).
150 */ 150 */
151 virtual QString quickHelp() const { return QString::null; }; 151 virtual QString quickHelp() const { return QString::null; };
152 152
@@ -184,24 +184,25 @@ public:
184 /** 184 /**
185 * Tell if KControl should show a RootOnly message when run as 185 * Tell if KControl should show a RootOnly message when run as
186 * a normal user. 186 * a normal user.
187 * 187 *
188 * In some cases, the module don't want a RootOnly message to 188 * In some cases, the module don't want a RootOnly message to
189 * appear (for example if it has already one). This function 189 * appear (for example if it has already one). This function
190 * tells KControl if a RootOnly message should be shown 190 * tells KControl if a RootOnly message should be shown
191 * 191 *
192 * @see KCModule::setUseRootOnlyMsg 192 * @see KCModule::setUseRootOnlyMsg
193 */ 193 */
194 bool useRootOnlyMsg() const; 194 bool useRootOnlyMsg() const;
195 195
196 KPrefs* getPreferences();
196 197
197//US KInstance *instance() const; 198//US KInstance *instance() const;
198 199
199signals: 200signals:
200 201
201 /** 202 /**
202 * Indicate that the state of the modules contents has changed. 203 * Indicate that the state of the modules contents has changed.
203 * 204 *
204 * This signal is emitted whenever the state of the configuration 205 * This signal is emitted whenever the state of the configuration
205 * shown in the module changes. It allows the control center to 206 * shown in the module changes. It allows the control center to
206 * keep track of unsaved changes. 207 * keep track of unsaved changes.
207 * 208 *
diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp
index c2378fb..6c82e4f 100644
--- a/microkde/kutils/kcmultidialog.cpp
+++ b/microkde/kutils/kcmultidialog.cpp
@@ -25,31 +25,30 @@
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kglobal.h> 28#include <kglobal.h>
29#include <kdebug.h> 29#include <kdebug.h>
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kmessagebox.h> 31#include <kmessagebox.h>
32//US #include <klibloader.h> 32//US #include <klibloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kprocess.h> 34#include <kprocess.h>
35 35
36#include "kcmultidialog.h" 36#include "kcmultidialog.h"
37#include "kprefs.h"
38//US #include "kcmultidialog.moc" 37//US #include "kcmultidialog.moc"
39//US #include "kcmoduleloader.h" 38//US #include "kcmoduleloader.h"
40 39
41KCMultiDialog::KCMultiDialog(KPrefs* prefs, const QString& baseGroup, QWidget *parent, const char *name, bool modal) 40KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal)
42 : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok, 41 : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok,
43 parent, name, modal, true), mPrefs(prefs), d(0L) 42 parent, name, modal, true), d(0L)
44{ 43{
45 enableButton(Apply, false); 44 enableButton(Apply, false);
46 //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *))); 45 //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *)));
47 46
48 connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) ); 47 connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) );
49 48
50 _baseGroup = baseGroup; 49 _baseGroup = baseGroup;
51 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed ); 50 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed );
52 setMainWidget(mMainWidget ); 51 setMainWidget(mMainWidget );
53#ifdef DESKTOP_VERSION 52#ifdef DESKTOP_VERSION
54 resize(640,480); 53 resize(640,480);
55#else 54#else
@@ -66,53 +65,53 @@ KCMultiDialog::~KCMultiDialog()
66} 65}
67 66
68void KCMultiDialog::slotDefault() 67void KCMultiDialog::slotDefault()
69{ 68{
70 69
71 int curPageIndex = mMainWidget->activePageIndex(); 70 int curPageIndex = mMainWidget->activePageIndex();
72 71
73 QPtrListIterator<KCModule> it(modules); 72 QPtrListIterator<KCModule> it(modules);
74 for (; it.current(); ++it) 73 for (; it.current(); ++it)
75 { 74 {
76 if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex) 75 if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex)
77 { 76 {
78 (*it)->defaults(mPrefs); 77 (*it)->defaults();
79 clientChanged(true); 78 clientChanged(true);
80 return; 79 return;
81 } 80 }
82 } 81 }
83 82
84} 83}
85 84
86void KCMultiDialog::slotApply() 85void KCMultiDialog::slotApply()
87{ 86{
88qDebug("KCMultiDialog::slotApply clicked"); 87qDebug("KCMultiDialog::slotApply clicked");
89 88
90 QPtrListIterator<KCModule> it(modules); 89 QPtrListIterator<KCModule> it(modules);
91 for (; it.current(); ++it) 90 for (; it.current(); ++it)
92 (*it)->save(mPrefs); 91 (*it)->save();
93 clientChanged(false); 92 clientChanged(false);
94 93
95 emit applyClicked(); 94 emit applyClicked();
96 95
97} 96}
98 97
99 98
100void KCMultiDialog::slotOk() 99void KCMultiDialog::slotOk()
101{ 100{
102qDebug("KCMultiDialog::slotOk clicked"); 101qDebug("KCMultiDialog::slotOk clicked");
103 102
104 QPtrListIterator<KCModule> it(modules); 103 QPtrListIterator<KCModule> it(modules);
105 for (; it.current(); ++it) 104 for (; it.current(); ++it)
106 (*it)->save(mPrefs); 105 (*it)->save();
107 accept(); 106 accept();
108 107
109 emit okClicked(); 108 emit okClicked();
110} 109}
111 110
112void KCMultiDialog::slotHelp() 111void KCMultiDialog::slotHelp()
113{ 112{
114/*US 113/*US
115 KURL url( KURL("help:/"), _docPath ); 114 KURL url( KURL("help:/"), _docPath );
116 115
117 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") { 116 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") {
118 KProcess process; 117 KProcess process;
@@ -153,25 +152,25 @@ QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename )
153{ 152{
154 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() ); 153 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() );
155 return page; 154 return page;
156 155
157} 156}
158//US special method for microkde. We dop noty want to load everything dynamically. 157//US special method for microkde. We dop noty want to load everything dynamically.
159void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname) 158void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname)
160{ 159{
161 160
162 modules.append(module); 161 modules.append(module);
163 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 162 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
164//US 163//US
165 module->load(mPrefs); 164 module->load();
166 165
167 166
168} 167}
169 168
170void KCMultiDialog::slotAboutToShow(QWidget *page) 169void KCMultiDialog::slotAboutToShow(QWidget *page)
171{ 170{
172/*US 171/*US
173 LoadInfo *loadInfo = moduleDict[page]; 172 LoadInfo *loadInfo = moduleDict[page];
174 if (!loadInfo) 173 if (!loadInfo)
175 return; 174 return;
176 175
177 QApplication::setOverrideCursor(Qt::WaitCursor); 176 QApplication::setOverrideCursor(Qt::WaitCursor);
diff --git a/microkde/kutils/kcmultidialog.h b/microkde/kutils/kcmultidialog.h
index a42555f..1aa66b2 100644
--- a/microkde/kutils/kcmultidialog.h
+++ b/microkde/kutils/kcmultidialog.h
@@ -20,50 +20,48 @@
20*/ 20*/
21 21
22#ifndef KCMULTIDIALOG_H 22#ifndef KCMULTIDIALOG_H
23#define KCMULTIDIALOG_H 23#define KCMULTIDIALOG_H
24 24
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qptrdict.h> 26#include <qptrdict.h>
27 27
28#include <kdialogbase.h> 28#include <kdialogbase.h>
29#include <kjanuswidget.h> 29#include <kjanuswidget.h>
30#include <kcmodule.h> 30#include <kcmodule.h>
31 31
32class KPrefs;
33
34/** 32/**
35 * A class that offers a @ref KDialogBase containing arbitrary KControl Modules 33 * A class that offers a @ref KDialogBase containing arbitrary KControl Modules
36 * 34 *
37 * @short A method that offers a @ref KDialogBase containing arbitrary 35 * @short A method that offers a @ref KDialogBase containing arbitrary
38 * KControl Modules. 36 * KControl Modules.
39 * 37 *
40 * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org> 38 * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org>
41 * @since 3.2 39 * @since 3.2
42 */ 40 */
43class KCMultiDialog : public KDialogBase 41class KCMultiDialog : public KDialogBase
44{ 42{
45 Q_OBJECT 43 Q_OBJECT
46 44
47public: 45public:
48 /** 46 /**
49 * Constructs a new KCMultiDialog 47 * Constructs a new KCMultiDialog
50 * 48 *
51 * @param parent The parent Widget 49 * @param parent The parent Widget
52 * @param name The widget name 50 * @param name The widget name
53 * @param baseGroup The baseGroup, if you want to call a module out of 51 * @param baseGroup The baseGroup, if you want to call a module out of
54 * kcontrol, just keep "settings" 52 * kcontrol, just keep "settings"
55 * @param modal If you pass true here, the dialog will be modal 53 * @param modal If you pass true here, the dialog will be modal
56 **/ 54 **/
57 KCMultiDialog(KPrefs* prefs, const QString& baseGroup = QString::fromLatin1("settings"), 55 KCMultiDialog(const QString& baseGroup = QString::fromLatin1("settings"),
58 QWidget *parent=0, const char *name=0, 56 QWidget *parent=0, const char *name=0,
59 bool modal=false); 57 bool modal=false);
60 58
61 /** 59 /**
62 * Destructor 60 * Destructor
63 **/ 61 **/
64 virtual ~KCMultiDialog(); 62 virtual ~KCMultiDialog();
65 63
66 /** 64 /**
67 * Add a module. 65 * Add a module.
68 * 66 *
69 * @param module Specify the name of the module that is to be added 67 * @param module Specify the name of the module that is to be added
@@ -130,20 +128,19 @@ private:
130 bool withfallback; 128 bool withfallback;
131 }; 129 };
132*/ 130*/
133 QPtrList<KCModule> modules; 131 QPtrList<KCModule> modules;
134/* 132/*
135 QPtrDict<LoadInfo> moduleDict; 133 QPtrDict<LoadInfo> moduleDict;
136 QString _docPath; 134 QString _docPath;
137*/ 135*/
138 QString _baseGroup; 136 QString _baseGroup;
139 137
140//US 138//US
141 KJanusWidget* mMainWidget; 139 KJanusWidget* mMainWidget;
142 KPrefs* mPrefs;
143 140
144 // For future use 141 // For future use
145 class KCMultiDialogPrivate; 142 class KCMultiDialogPrivate;
146 KCMultiDialogPrivate *d; 143 KCMultiDialogPrivate *d;
147}; 144};
148 145
149#endif //KCMULTIDIALOG_H 146#endif //KCMULTIDIALOG_H