summaryrefslogtreecommitdiffabout
path: root/microkde/kutils/kcmultidialog.cpp
Unidiff
Diffstat (limited to 'microkde/kutils/kcmultidialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kutils/kcmultidialog.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp
index 13be2ce..c2378fb 100644
--- a/microkde/kutils/kcmultidialog.cpp
+++ b/microkde/kutils/kcmultidialog.cpp
@@ -1,204 +1,207 @@
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"
37//US #include "kcmultidialog.moc" 38//US #include "kcmultidialog.moc"
38//US #include "kcmoduleloader.h" 39//US #include "kcmoduleloader.h"
39 40
40KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal) 41KCMultiDialog::KCMultiDialog(KPrefs* prefs, const QString& baseGroup, QWidget *parent, const char *name, bool modal)
41 : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok, 42 : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok,
42 parent, name, modal, true), d(0L) 43 parent, name, modal, true), mPrefs(prefs), d(0L)
43{ 44{
44 enableButton(Apply, false); 45 enableButton(Apply, false);
45 //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *))); 46 //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *)));
46 47
47 connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) ); 48 connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) );
48 49
49 _baseGroup = baseGroup; 50 _baseGroup = baseGroup;
50 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed ); 51 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed );
51 setMainWidget(mMainWidget ); 52 setMainWidget(mMainWidget );
52#ifdef DESKTOP_VERSION 53#ifdef DESKTOP_VERSION
53 resize(640,480); 54 resize(640,480);
54#else 55#else
55 resize(640,480); 56 resize(640,480);
56 setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480)); 57 setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480));
57 //showMaximized(); 58 //showMaximized();
58#endif 59#endif
59 60
60} 61}
61 62
62KCMultiDialog::~KCMultiDialog() 63KCMultiDialog::~KCMultiDialog()
63{ 64{
64//US moduleDict.setAutoDelete(true); 65//US moduleDict.setAutoDelete(true);
65} 66}
66 67
67void KCMultiDialog::slotDefault() 68void KCMultiDialog::slotDefault()
68{ 69{
69 70
70 int curPageIndex = mMainWidget->activePageIndex(); 71 int curPageIndex = mMainWidget->activePageIndex();
71 72
72 QPtrListIterator<KCModule> it(modules); 73 QPtrListIterator<KCModule> it(modules);
73 for (; it.current(); ++it) 74 for (; it.current(); ++it)
74 { 75 {
75 if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex) 76 if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex)
76 { 77 {
77 (*it)->defaults(); 78 (*it)->defaults(mPrefs);
78 clientChanged(true); 79 clientChanged(true);
79 return; 80 return;
80 } 81 }
81 } 82 }
82 83
83} 84}
84 85
85void KCMultiDialog::slotApply() 86void KCMultiDialog::slotApply()
86{ 87{
87qDebug("KCMultiDialog::slotApply clicked"); 88qDebug("KCMultiDialog::slotApply clicked");
88 89
89 QPtrListIterator<KCModule> it(modules); 90 QPtrListIterator<KCModule> it(modules);
90 for (; it.current(); ++it) 91 for (; it.current(); ++it)
91 (*it)->save(); 92 (*it)->save(mPrefs);
92 clientChanged(false); 93 clientChanged(false);
93 94
94 emit applyClicked(); 95 emit applyClicked();
95 96
96} 97}
97 98
98 99
99void KCMultiDialog::slotOk() 100void KCMultiDialog::slotOk()
100{ 101{
101qDebug("KCMultiDialog::slotOk clicked"); 102qDebug("KCMultiDialog::slotOk clicked");
102 103
103 QPtrListIterator<KCModule> it(modules); 104 QPtrListIterator<KCModule> it(modules);
104 for (; it.current(); ++it) 105 for (; it.current(); ++it)
105 (*it)->save(); 106 (*it)->save(mPrefs);
106 accept(); 107 accept();
107 108
108 emit okClicked(); 109 emit okClicked();
109} 110}
110 111
111void KCMultiDialog::slotHelp() 112void KCMultiDialog::slotHelp()
112{ 113{
113/*US 114/*US
114 KURL url( KURL("help:/"), _docPath ); 115 KURL url( KURL("help:/"), _docPath );
115 116
116 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") { 117 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") {
117 KProcess process; 118 KProcess process;
118 process << "khelpcenter" 119 process << "khelpcenter"
119 << url.url(); 120 << url.url();
120 process.start(KProcess::DontCare); 121 process.start(KProcess::DontCare);
121 process.detach(); 122 process.detach();
122 } else { 123 } else {
123 new KRun(url); 124 new KRun(url);
124 } 125 }
125*/ 126*/
126} 127}
127 128
128void KCMultiDialog::clientChanged(bool state) 129void KCMultiDialog::clientChanged(bool state)
129{ 130{
130 enableButton(Apply, state); 131 enableButton(Apply, state);
131} 132}
132 133
133/*US 134/*US
134void KCMultiDialog::addModule(const QString& path, bool withfallback) 135void KCMultiDialog::addModule(const QString& path, bool withfallback)
135{ 136{
136 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl; 137 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl;
137 138
138 KCModuleInfo info(path, _baseGroup); 139 KCModuleInfo info(path, _baseGroup);
139 140
140 QHBox* page = addHBoxPage(info.moduleName(), info.comment(), 141 QHBox* page = addHBoxPage(info.moduleName(), info.comment(),
141 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium)); 142 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium));
142 if(!page) { 143 if(!page) {
143 KCModuleLoader::unloadModule(info); 144 KCModuleLoader::unloadModule(info);
144 return; 145 return;
145 } 146 }
146 moduleDict.insert(page, new LoadInfo(path, withfallback)); 147 moduleDict.insert(page, new LoadInfo(path, withfallback));
147 if (modules.isEmpty()) 148 if (modules.isEmpty())
148 slotAboutToShow(page); 149 slotAboutToShow(page);
149} 150}
150*/ 151*/
151QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename ) 152QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename )
152{ 153{
153 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() ); 154 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() );
154 return page; 155 return page;
155 156
156} 157}
157//US special method for microkde. We dop noty want to load everything dynamically. 158//US special method for microkde. We dop noty want to load everything dynamically.
158void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname) 159void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname)
159{ 160{
160 161
161 modules.append(module); 162 modules.append(module);
162 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 163 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
164//US
165 module->load(mPrefs);
163 166
164 167
165} 168}
166 169
167void KCMultiDialog::slotAboutToShow(QWidget *page) 170void KCMultiDialog::slotAboutToShow(QWidget *page)
168{ 171{
169/*US 172/*US
170 LoadInfo *loadInfo = moduleDict[page]; 173 LoadInfo *loadInfo = moduleDict[page];
171 if (!loadInfo) 174 if (!loadInfo)
172 return; 175 return;
173 176
174 QApplication::setOverrideCursor(Qt::WaitCursor); 177 QApplication::setOverrideCursor(Qt::WaitCursor);
175 178
176 moduleDict.remove(page); 179 moduleDict.remove(page);
177 180
178 KCModuleInfo info(loadInfo->path, _baseGroup); 181 KCModuleInfo info(loadInfo->path, _baseGroup);
179 182
180 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback); 183 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback);
181 184
182 if (!module) 185 if (!module)
183 { 186 {
184 QApplication::restoreOverrideCursor(); 187 QApplication::restoreOverrideCursor();
185 KCModuleLoader::showLastLoaderError(this); 188 KCModuleLoader::showLastLoaderError(this);
186 delete loadInfo; 189 delete loadInfo;
187 return; 190 return;
188 } 191 }
189 192
190 module->reparent(page,0,QPoint(0,0),true); 193 module->reparent(page,0,QPoint(0,0),true);
191 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 194 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
192 //setHelp( docpath, QString::null ); 195 //setHelp( docpath, QString::null );
193 _docPath = info.docPath(); 196 _docPath = info.docPath();
194 modules.append(module); 197 modules.append(module);
195 198
196 //KCGlobal::repairAccels( topLevelWidget() ); 199 //KCGlobal::repairAccels( topLevelWidget() );
197 200
198 delete loadInfo; 201 delete loadInfo;
199 202
200 QApplication::restoreOverrideCursor(); 203 QApplication::restoreOverrideCursor();
201*/ 204*/
202 205
203qDebug("KCMultiDialog::slotAboutToShow not implemented"); 206qDebug("KCMultiDialog::slotAboutToShow not implemented");
204} 207}