summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kutils/kcmultidialog.cpp7
-rw-r--r--microkde/kutils/kcmultidialog.h2
2 files changed, 7 insertions, 2 deletions
diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp
index 6c82e4f..e7aa9d1 100644
--- a/microkde/kutils/kcmultidialog.cpp
+++ b/microkde/kutils/kcmultidialog.cpp
@@ -1,206 +1,209 @@
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//US #include "kcmultidialog.moc" 37//US #include "kcmultidialog.moc"
38//US #include "kcmoduleloader.h" 38//US #include "kcmoduleloader.h"
39 39
40KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal) 40KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal)
41 : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok, 41 : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok,
42 parent, name, modal, true), d(0L) 42 parent, name, modal, true), d(0L)
43{ 43{
44 enableButton(Apply, false); 44 enableButton(Apply, false);
45 //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *))); 45 //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *)));
46 46
47 connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) ); 47 connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) );
48 48
49 _baseGroup = baseGroup; 49 _baseGroup = baseGroup;
50 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed ); 50 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed );
51 setMainWidget(mMainWidget ); 51 setMainWidget(mMainWidget );
52#ifdef DESKTOP_VERSION 52#ifdef DESKTOP_VERSION
53 resize(640,480); 53 resize(640,480);
54#else 54#else
55 resize(640,480); 55 resize(640,480);
56 setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480)); 56 setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480));
57 //showMaximized(); 57 //showMaximized();
58#endif 58#endif
59 59
60} 60}
61 61
62KCMultiDialog::~KCMultiDialog() 62KCMultiDialog::~KCMultiDialog()
63{ 63{
64//US moduleDict.setAutoDelete(true); 64//US moduleDict.setAutoDelete(true);
65} 65}
66 66
67void KCMultiDialog::slotDefault() 67void KCMultiDialog::slotDefault()
68{ 68{
69 69
70 int curPageIndex = mMainWidget->activePageIndex(); 70 int curPageIndex = mMainWidget->activePageIndex();
71 71
72 QPtrListIterator<KCModule> it(modules); 72 QPtrListIterator<KCModule> it(modules);
73 for (; it.current(); ++it) 73 for (; it.current(); ++it)
74 { 74 {
75 if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex) 75 if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex)
76 { 76 {
77 (*it)->defaults(); 77 (*it)->defaults();
78 clientChanged(true); 78 clientChanged(true);
79 return; 79 return;
80 } 80 }
81 } 81 }
82 82
83} 83}
84 84void KCMultiDialog::accept()
85{
86 slotOk();
87}
85void KCMultiDialog::slotApply() 88void KCMultiDialog::slotApply()
86{ 89{
87qDebug("KCMultiDialog::slotApply clicked"); 90qDebug("KCMultiDialog::slotApply clicked");
88 91
89 QPtrListIterator<KCModule> it(modules); 92 QPtrListIterator<KCModule> it(modules);
90 for (; it.current(); ++it) 93 for (; it.current(); ++it)
91 (*it)->save(); 94 (*it)->save();
92 clientChanged(false); 95 clientChanged(false);
93 96
94 emit applyClicked(); 97 emit applyClicked();
95 98
96} 99}
97 100
98 101
99void KCMultiDialog::slotOk() 102void KCMultiDialog::slotOk()
100{ 103{
101qDebug("KCMultiDialog::slotOk clicked"); 104qDebug("KCMultiDialog::slotOk clicked");
102 105
103 QPtrListIterator<KCModule> it(modules); 106 QPtrListIterator<KCModule> it(modules);
104 for (; it.current(); ++it) 107 for (; it.current(); ++it)
105 (*it)->save(); 108 (*it)->save();
106 accept(); 109 QDialog::accept();
107 110
108 emit okClicked(); 111 emit okClicked();
109} 112}
110 113
111void KCMultiDialog::slotHelp() 114void KCMultiDialog::slotHelp()
112{ 115{
113/*US 116/*US
114 KURL url( KURL("help:/"), _docPath ); 117 KURL url( KURL("help:/"), _docPath );
115 118
116 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") { 119 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") {
117 KProcess process; 120 KProcess process;
118 process << "khelpcenter" 121 process << "khelpcenter"
119 << url.url(); 122 << url.url();
120 process.start(KProcess::DontCare); 123 process.start(KProcess::DontCare);
121 process.detach(); 124 process.detach();
122 } else { 125 } else {
123 new KRun(url); 126 new KRun(url);
124 } 127 }
125*/ 128*/
126} 129}
127 130
128void KCMultiDialog::clientChanged(bool state) 131void KCMultiDialog::clientChanged(bool state)
129{ 132{
130 enableButton(Apply, state); 133 enableButton(Apply, state);
131} 134}
132 135
133/*US 136/*US
134void KCMultiDialog::addModule(const QString& path, bool withfallback) 137void KCMultiDialog::addModule(const QString& path, bool withfallback)
135{ 138{
136 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl; 139 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl;
137 140
138 KCModuleInfo info(path, _baseGroup); 141 KCModuleInfo info(path, _baseGroup);
139 142
140 QHBox* page = addHBoxPage(info.moduleName(), info.comment(), 143 QHBox* page = addHBoxPage(info.moduleName(), info.comment(),
141 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium)); 144 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium));
142 if(!page) { 145 if(!page) {
143 KCModuleLoader::unloadModule(info); 146 KCModuleLoader::unloadModule(info);
144 return; 147 return;
145 } 148 }
146 moduleDict.insert(page, new LoadInfo(path, withfallback)); 149 moduleDict.insert(page, new LoadInfo(path, withfallback));
147 if (modules.isEmpty()) 150 if (modules.isEmpty())
148 slotAboutToShow(page); 151 slotAboutToShow(page);
149} 152}
150*/ 153*/
151QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename ) 154QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename )
152{ 155{
153 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() ); 156 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() );
154 return page; 157 return page;
155 158
156} 159}
157//US special method for microkde. We dop noty want to load everything dynamically. 160//US special method for microkde. We dop noty want to load everything dynamically.
158void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname) 161void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname)
159{ 162{
160 163
161 modules.append(module); 164 modules.append(module);
162 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 165 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
163//US 166//US
164 module->load(); 167 module->load();
165 168
166 169
167} 170}
168 171
169void KCMultiDialog::slotAboutToShow(QWidget *page) 172void KCMultiDialog::slotAboutToShow(QWidget *page)
170{ 173{
171/*US 174/*US
172 LoadInfo *loadInfo = moduleDict[page]; 175 LoadInfo *loadInfo = moduleDict[page];
173 if (!loadInfo) 176 if (!loadInfo)
174 return; 177 return;
175 178
176 QApplication::setOverrideCursor(Qt::WaitCursor); 179 QApplication::setOverrideCursor(Qt::WaitCursor);
177 180
178 moduleDict.remove(page); 181 moduleDict.remove(page);
179 182
180 KCModuleInfo info(loadInfo->path, _baseGroup); 183 KCModuleInfo info(loadInfo->path, _baseGroup);
181 184
182 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback); 185 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback);
183 186
184 if (!module) 187 if (!module)
185 { 188 {
186 QApplication::restoreOverrideCursor(); 189 QApplication::restoreOverrideCursor();
187 KCModuleLoader::showLastLoaderError(this); 190 KCModuleLoader::showLastLoaderError(this);
188 delete loadInfo; 191 delete loadInfo;
189 return; 192 return;
190 } 193 }
191 194
192 module->reparent(page,0,QPoint(0,0),true); 195 module->reparent(page,0,QPoint(0,0),true);
193 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 196 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
194 //setHelp( docpath, QString::null ); 197 //setHelp( docpath, QString::null );
195 _docPath = info.docPath(); 198 _docPath = info.docPath();
196 modules.append(module); 199 modules.append(module);
197 200
198 //KCGlobal::repairAccels( topLevelWidget() ); 201 //KCGlobal::repairAccels( topLevelWidget() );
199 202
200 delete loadInfo; 203 delete loadInfo;
201 204
202 QApplication::restoreOverrideCursor(); 205 QApplication::restoreOverrideCursor();
203*/ 206*/
204 207
205qDebug("KCMultiDialog::slotAboutToShow not implemented"); 208qDebug("KCMultiDialog::slotAboutToShow not implemented");
206} 209}
diff --git a/microkde/kutils/kcmultidialog.h b/microkde/kutils/kcmultidialog.h
index 1aa66b2..768faea 100644
--- a/microkde/kutils/kcmultidialog.h
+++ b/microkde/kutils/kcmultidialog.h
@@ -1,146 +1,148 @@
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
32/** 32/**
33 * A class that offers a @ref KDialogBase containing arbitrary KControl Modules 33 * A class that offers a @ref KDialogBase containing arbitrary KControl Modules
34 * 34 *
35 * @short A method that offers a @ref KDialogBase containing arbitrary 35 * @short A method that offers a @ref KDialogBase containing arbitrary
36 * KControl Modules. 36 * KControl Modules.
37 * 37 *
38 * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org> 38 * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org>
39 * @since 3.2 39 * @since 3.2
40 */ 40 */
41class KCMultiDialog : public KDialogBase 41class KCMultiDialog : public KDialogBase
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44 44
45public: 45public:
46 /** 46 /**
47 * Constructs a new KCMultiDialog 47 * Constructs a new KCMultiDialog
48 * 48 *
49 * @param parent The parent Widget 49 * @param parent The parent Widget
50 * @param name The widget name 50 * @param name The widget name
51 * @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
52 * kcontrol, just keep "settings" 52 * kcontrol, just keep "settings"
53 * @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
54 **/ 54 **/
55 KCMultiDialog(const QString& baseGroup = QString::fromLatin1("settings"), 55 KCMultiDialog(const QString& baseGroup = QString::fromLatin1("settings"),
56 QWidget *parent=0, const char *name=0, 56 QWidget *parent=0, const char *name=0,
57 bool modal=false); 57 bool modal=false);
58 58
59 /** 59 /**
60 * Destructor 60 * Destructor
61 **/ 61 **/
62 virtual ~KCMultiDialog(); 62 virtual ~KCMultiDialog();
63 63
64 /** 64 /**
65 * Add a module. 65 * Add a module.
66 * 66 *
67 * @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
68 * to the list of modules the dialog will show. 68 * to the list of modules the dialog will show.
69 * 69 *
70 * @param withfallback Try harder to load the module. Might result 70 * @param withfallback Try harder to load the module. Might result
71 * in the module appearing outside the dialog. 71 * in the module appearing outside the dialog.
72 **/ 72 **/
73//US void addModule(const QString& module, bool withfallback=true); 73//US void addModule(const QString& module, bool withfallback=true);
74 74
75 75
76//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.
77 void addModule(KCModule* module );//, const QString& modulename, const QString& iconname); 77 void addModule(KCModule* module );//, const QString& modulename, const QString& iconname);
78 QVBox* getNewVBoxPage(const QString & modulename) ; 78 QVBox* getNewVBoxPage(const QString & modulename) ;
79 79
80 80
81 81
82protected slots: 82protected slots:
83 /** 83 /**
84 * This slot is called when the user presses the "Default" Button 84 * This slot is called when the user presses the "Default" Button
85 * You can reimplement it if needed. 85 * You can reimplement it if needed.
86 * 86 *
87 * @note Make sure you call the original implementation! 87 * @note Make sure you call the original implementation!
88 **/ 88 **/
89 virtual void slotDefault(); 89 virtual void slotDefault();
90 90
91 /** 91 /**
92 * This slot is called when the user presses the "Apply" Button 92 * This slot is called when the user presses the "Apply" Button
93 * You can reimplement it if needed 93 * You can reimplement it if needed
94 * 94 *
95 * @note Make sure you call the original implementation! 95 * @note Make sure you call the original implementation!
96 **/ 96 **/
97 virtual void slotApply(); 97 virtual void slotApply();
98 98
99 /** 99 /**
100 * This slot is called when the user presses the "OK" Button 100 * This slot is called when the user presses the "OK" Button
101 * You can reimplement it if needed 101 * You can reimplement it if needed
102 * 102 *
103 * @note Make sure you call the original implementation! 103 * @note Make sure you call the original implementation!
104 **/ 104 **/
105 virtual void slotOk(); 105 virtual void slotOk();
106 106
107 /** 107 /**
108 * This slot is called when the user presses the "Help" Button 108 * This slot is called when the user presses the "Help" Button
109 * You can reimplement it if needed 109 * You can reimplement it if needed
110 * 110 *
111 * @note Make sure you call the original implementation! 111 * @note Make sure you call the original implementation!
112 **/ 112 **/
113 virtual void slotHelp(); 113 virtual void slotHelp();
114 114
115 void accept();
116
115private slots: 117private slots:
116 118
117 void slotAboutToShow(QWidget *); 119 void slotAboutToShow(QWidget *);
118 120
119 void clientChanged(bool state); 121 void clientChanged(bool state);
120 122
121private: 123private:
122/*US 124/*US
123 struct LoadInfo { 125 struct LoadInfo {
124 LoadInfo(const QString &_path, bool _withfallback) 126 LoadInfo(const QString &_path, bool _withfallback)
125 : path(_path), withfallback(_withfallback) 127 : path(_path), withfallback(_withfallback)
126 { } 128 { }
127 QString path; 129 QString path;
128 bool withfallback; 130 bool withfallback;
129 }; 131 };
130*/ 132*/
131 QPtrList<KCModule> modules; 133 QPtrList<KCModule> modules;
132/* 134/*
133 QPtrDict<LoadInfo> moduleDict; 135 QPtrDict<LoadInfo> moduleDict;
134 QString _docPath; 136 QString _docPath;
135*/ 137*/
136 QString _baseGroup; 138 QString _baseGroup;
137 139
138//US 140//US
139 KJanusWidget* mMainWidget; 141 KJanusWidget* mMainWidget;
140 142
141 // For future use 143 // For future use
142 class KCMultiDialogPrivate; 144 class KCMultiDialogPrivate;
143 KCMultiDialogPrivate *d; 145 KCMultiDialogPrivate *d;
144}; 146};
145 147
146#endif //KCMULTIDIALOG_H 148#endif //KCMULTIDIALOG_H