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