summaryrefslogtreecommitdiffabout
path: root/microkde/kutils
Unidiff
Diffstat (limited to 'microkde/kutils') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kutils/kcmultidialog.cpp13
-rw-r--r--microkde/kutils/kcmultidialog.h5
2 files changed, 7 insertions, 11 deletions
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
@@ -1,207 +1,206 @@
1/* 1/*
2 Copyright (c) 2000 Matthias Elter <elter@kde.org> 2 Copyright (c) 2000 Matthias Elter <elter@kde.org>
3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org> 3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20*/ 20*/
21 21
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qcursor.h> 24#include <qcursor.h>
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
56 resize(640,480); 55 resize(640,480);
57 setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480)); 56 setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480));
58 //showMaximized(); 57 //showMaximized();
59#endif 58#endif
60 59
61} 60}
62 61
63KCMultiDialog::~KCMultiDialog() 62KCMultiDialog::~KCMultiDialog()
64{ 63{
65//US moduleDict.setAutoDelete(true); 64//US moduleDict.setAutoDelete(true);
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;
119 process << "khelpcenter" 118 process << "khelpcenter"
120 << url.url(); 119 << url.url();
121 process.start(KProcess::DontCare); 120 process.start(KProcess::DontCare);
122 process.detach(); 121 process.detach();
123 } else { 122 } else {
124 new KRun(url); 123 new KRun(url);
125 } 124 }
126*/ 125*/
127} 126}
128 127
129void KCMultiDialog::clientChanged(bool state) 128void KCMultiDialog::clientChanged(bool state)
130{ 129{
131 enableButton(Apply, state); 130 enableButton(Apply, state);
132} 131}
133 132
134/*US 133/*US
135void KCMultiDialog::addModule(const QString& path, bool withfallback) 134void KCMultiDialog::addModule(const QString& path, bool withfallback)
136{ 135{
137 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl; 136 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl;
138 137
139 KCModuleInfo info(path, _baseGroup); 138 KCModuleInfo info(path, _baseGroup);
140 139
141 QHBox* page = addHBoxPage(info.moduleName(), info.comment(), 140 QHBox* page = addHBoxPage(info.moduleName(), info.comment(),
142 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium)); 141 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium));
143 if(!page) { 142 if(!page) {
144 KCModuleLoader::unloadModule(info); 143 KCModuleLoader::unloadModule(info);
145 return; 144 return;
146 } 145 }
147 moduleDict.insert(page, new LoadInfo(path, withfallback)); 146 moduleDict.insert(page, new LoadInfo(path, withfallback));
148 if (modules.isEmpty()) 147 if (modules.isEmpty())
149 slotAboutToShow(page); 148 slotAboutToShow(page);
150} 149}
151*/ 150*/
152QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename ) 151QVBox * 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);
178 177
179 moduleDict.remove(page); 178 moduleDict.remove(page);
180 179
181 KCModuleInfo info(loadInfo->path, _baseGroup); 180 KCModuleInfo info(loadInfo->path, _baseGroup);
182 181
183 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback); 182 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback);
184 183
185 if (!module) 184 if (!module)
186 { 185 {
187 QApplication::restoreOverrideCursor(); 186 QApplication::restoreOverrideCursor();
188 KCModuleLoader::showLastLoaderError(this); 187 KCModuleLoader::showLastLoaderError(this);
189 delete loadInfo; 188 delete loadInfo;
190 return; 189 return;
191 } 190 }
192 191
193 module->reparent(page,0,QPoint(0,0),true); 192 module->reparent(page,0,QPoint(0,0),true);
194 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 193 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
195 //setHelp( docpath, QString::null ); 194 //setHelp( docpath, QString::null );
196 _docPath = info.docPath(); 195 _docPath = info.docPath();
197 modules.append(module); 196 modules.append(module);
198 197
199 //KCGlobal::repairAccels( topLevelWidget() ); 198 //KCGlobal::repairAccels( topLevelWidget() );
200 199
201 delete loadInfo; 200 delete loadInfo;
202 201
203 QApplication::restoreOverrideCursor(); 202 QApplication::restoreOverrideCursor();
204*/ 203*/
205 204
206qDebug("KCMultiDialog::slotAboutToShow not implemented"); 205qDebug("KCMultiDialog::slotAboutToShow not implemented");
207} 206}
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
@@ -1,149 +1,146 @@
1/* 1/*
2 Copyright (c) 2000 Matthias Elter <elter@kde.org> 2 Copyright (c) 2000 Matthias Elter <elter@kde.org>
3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org> 3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
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
70 * to the list of modules the dialog will show. 68 * to the list of modules the dialog will show.
71 * 69 *
72 * @param withfallback Try harder to load the module. Might result 70 * @param withfallback Try harder to load the module. Might result
73 * in the module appearing outside the dialog. 71 * in the module appearing outside the dialog.
74 **/ 72 **/
75//US void addModule(const QString& module, bool withfallback=true); 73//US void addModule(const QString& module, bool withfallback=true);
76 74
77 75
78//US special method for microkde. We dop noty want to load everything dynamically. 76//US special method for microkde. We dop noty want to load everything dynamically.
79 void addModule(KCModule* module );//, const QString& modulename, const QString& iconname); 77 void addModule(KCModule* module );//, const QString& modulename, const QString& iconname);
80 QVBox* getNewVBoxPage(const QString & modulename) ; 78 QVBox* getNewVBoxPage(const QString & modulename) ;
81 79
82 80
83 81
84protected slots: 82protected slots:
85 /** 83 /**
86 * This slot is called when the user presses the "Default" Button 84 * This slot is called when the user presses the "Default" Button
87 * You can reimplement it if needed. 85 * You can reimplement it if needed.
88 * 86 *
89 * @note Make sure you call the original implementation! 87 * @note Make sure you call the original implementation!
90 **/ 88 **/
91 virtual void slotDefault(); 89 virtual void slotDefault();
92 90
93 /** 91 /**
94 * This slot is called when the user presses the "Apply" Button 92 * This slot is called when the user presses the "Apply" Button
95 * You can reimplement it if needed 93 * You can reimplement it if needed
96 * 94 *
97 * @note Make sure you call the original implementation! 95 * @note Make sure you call the original implementation!
98 **/ 96 **/
99 virtual void slotApply(); 97 virtual void slotApply();
100 98
101 /** 99 /**
102 * This slot is called when the user presses the "OK" Button 100 * This slot is called when the user presses the "OK" Button
103 * You can reimplement it if needed 101 * You can reimplement it if needed
104 * 102 *
105 * @note Make sure you call the original implementation! 103 * @note Make sure you call the original implementation!
106 **/ 104 **/
107 virtual void slotOk(); 105 virtual void slotOk();
108 106
109 /** 107 /**
110 * This slot is called when the user presses the "Help" Button 108 * This slot is called when the user presses the "Help" Button
111 * You can reimplement it if needed 109 * You can reimplement it if needed
112 * 110 *
113 * @note Make sure you call the original implementation! 111 * @note Make sure you call the original implementation!
114 **/ 112 **/
115 virtual void slotHelp(); 113 virtual void slotHelp();
116 114
117private slots: 115private slots:
118 116
119 void slotAboutToShow(QWidget *); 117 void slotAboutToShow(QWidget *);
120 118
121 void clientChanged(bool state); 119 void clientChanged(bool state);
122 120
123private: 121private:
124/*US 122/*US
125 struct LoadInfo { 123 struct LoadInfo {
126 LoadInfo(const QString &_path, bool _withfallback) 124 LoadInfo(const QString &_path, bool _withfallback)
127 : path(_path), withfallback(_withfallback) 125 : path(_path), withfallback(_withfallback)
128 { } 126 { }
129 QString path; 127 QString path;
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