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