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