summaryrefslogtreecommitdiffabout
path: root/microkde/kutils
authorulf69 <ulf69>2004-09-21 19:47:57 (UTC)
committer ulf69 <ulf69>2004-09-21 19:47:57 (UTC)
commitc2cce86fdb2d0b291c3d3bdfa9fac47452153d1a (patch) (unidiff)
tree6f8ac380b5db0831f02e4cc35cd0a6fd5ece5ff9 /microkde/kutils
parent427906b75a4672531f2b7d86b2a4a27427f5d4a4 (diff)
downloadkdepimpi-c2cce86fdb2d0b291c3d3bdfa9fac47452153d1a.zip
kdepimpi-c2cce86fdb2d0b291c3d3bdfa9fac47452153d1a.tar.gz
kdepimpi-c2cce86fdb2d0b291c3d3bdfa9fac47452153d1a.tar.bz2
added prefwriting prefreading for size and font object
Diffstat (limited to 'microkde/kutils') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kutils/kcmultidialog.cpp20
-rw-r--r--microkde/kutils/kcmultidialog.h5
2 files changed, 23 insertions, 2 deletions
diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp
index e7aa9d1..c4ccede 100644
--- a/microkde/kutils/kcmultidialog.cpp
+++ b/microkde/kutils/kcmultidialog.cpp
@@ -1,209 +1,227 @@
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 = 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}
84void KCMultiDialog::accept() 84void KCMultiDialog::accept()
85{ 85{
86 slotOk(); 86 slotOk();
87} 87}
88void KCMultiDialog::slotApply() 88void KCMultiDialog::slotApply()
89{ 89{
90qDebug("KCMultiDialog::slotApply clicked"); 90qDebug("KCMultiDialog::slotApply clicked");
91 91
92 QPtrListIterator<KCModule> it(modules); 92 QPtrListIterator<KCModule> it(modules);
93 for (; it.current(); ++it) 93 for (; it.current(); ++it)
94 (*it)->save(); 94 (*it)->save();
95 clientChanged(false); 95 clientChanged(false);
96 96
97 emit applyClicked(); 97 emit applyClicked();
98 98
99} 99}
100 100
101 101
102void KCMultiDialog::slotOk() 102void KCMultiDialog::slotOk()
103{ 103{
104qDebug("KCMultiDialog::slotOk clicked"); 104qDebug("KCMultiDialog::slotOk clicked");
105 105
106 QPtrListIterator<KCModule> it(modules); 106 QPtrListIterator<KCModule> it(modules);
107 for (; it.current(); ++it) 107 for (; it.current(); ++it)
108 (*it)->save(); 108 (*it)->save();
109 QDialog::accept(); 109 QDialog::accept();
110 110
111 emit okClicked(); 111 emit okClicked();
112} 112}
113 113
114void KCMultiDialog::slotHelp() 114void KCMultiDialog::slotHelp()
115{ 115{
116/*US 116/*US
117 KURL url( KURL("help:/"), _docPath ); 117 KURL url( KURL("help:/"), _docPath );
118 118
119 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") { 119 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") {
120 KProcess process; 120 KProcess process;
121 process << "khelpcenter" 121 process << "khelpcenter"
122 << url.url(); 122 << url.url();
123 process.start(KProcess::DontCare); 123 process.start(KProcess::DontCare);
124 process.detach(); 124 process.detach();
125 } else { 125 } else {
126 new KRun(url); 126 new KRun(url);
127 } 127 }
128*/ 128*/
129} 129}
130 130
131void KCMultiDialog::clientChanged(bool state) 131void KCMultiDialog::clientChanged(bool state)
132{ 132{
133 enableButton(Apply, state); 133 enableButton(Apply, state);
134} 134}
135 135
136/*US 136/*US
137void KCMultiDialog::addModule(const QString& path, bool withfallback) 137void KCMultiDialog::addModule(const QString& path, bool withfallback)
138{ 138{
139 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl; 139 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl;
140 140
141 KCModuleInfo info(path, _baseGroup); 141 KCModuleInfo info(path, _baseGroup);
142 142
143 QHBox* page = addHBoxPage(info.moduleName(), info.comment(), 143 QHBox* page = addHBoxPage(info.moduleName(), info.comment(),
144 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium)); 144 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium));
145 if(!page) { 145 if(!page) {
146 KCModuleLoader::unloadModule(info); 146 KCModuleLoader::unloadModule(info);
147 return; 147 return;
148 } 148 }
149 moduleDict.insert(page, new LoadInfo(path, withfallback)); 149 moduleDict.insert(page, new LoadInfo(path, withfallback));
150 if (modules.isEmpty()) 150 if (modules.isEmpty())
151 slotAboutToShow(page); 151 slotAboutToShow(page);
152} 152}
153*/ 153*/
154QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename ) 154QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename )
155{ 155{
156 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() ); 156 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() );
157 return page; 157 return page;
158 158
159} 159}
160//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.
161void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname) 161void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname)
162{ 162{
163 163
164 modules.append(module); 164 modules.append(module);
165 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 165 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
166//US 166//US
167 module->load(); 167 module->load();
168 168
169 169
170} 170}
171 171
172void KCMultiDialog::slotAboutToShow(QWidget *page) 172void KCMultiDialog::slotAboutToShow(QWidget *page)
173{ 173{
174/*US 174/*US
175 LoadInfo *loadInfo = moduleDict[page]; 175 LoadInfo *loadInfo = moduleDict[page];
176 if (!loadInfo) 176 if (!loadInfo)
177 return; 177 return;
178 178
179 QApplication::setOverrideCursor(Qt::WaitCursor); 179 QApplication::setOverrideCursor(Qt::WaitCursor);
180 180
181 moduleDict.remove(page); 181 moduleDict.remove(page);
182 182
183 KCModuleInfo info(loadInfo->path, _baseGroup); 183 KCModuleInfo info(loadInfo->path, _baseGroup);
184 184
185 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback); 185 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback);
186 186
187 if (!module) 187 if (!module)
188 { 188 {
189 QApplication::restoreOverrideCursor(); 189 QApplication::restoreOverrideCursor();
190 KCModuleLoader::showLastLoaderError(this); 190 KCModuleLoader::showLastLoaderError(this);
191 delete loadInfo; 191 delete loadInfo;
192 return; 192 return;
193 } 193 }
194 194
195 module->reparent(page,0,QPoint(0,0),true); 195 module->reparent(page,0,QPoint(0,0),true);
196 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 196 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
197 //setHelp( docpath, QString::null ); 197 //setHelp( docpath, QString::null );
198 _docPath = info.docPath(); 198 _docPath = info.docPath();
199 modules.append(module); 199 modules.append(module);
200 200
201 //KCGlobal::repairAccels( topLevelWidget() ); 201 //KCGlobal::repairAccels( topLevelWidget() );
202 202
203 delete loadInfo; 203 delete loadInfo;
204 204
205 QApplication::restoreOverrideCursor(); 205 QApplication::restoreOverrideCursor();
206*/ 206*/
207 207
208qDebug("KCMultiDialog::slotAboutToShow not implemented"); 208qDebug("KCMultiDialog::slotAboutToShow not implemented");
209} 209}
210
211
212bool KCMultiDialog::showPage( int index )
213{
214 return(mMainWidget->showPage(index) );
215}
216
217
218int KCMultiDialog::activePageIndex() const
219{
220 return( mMainWidget->activePageIndex() );
221}
222
223
224int KCMultiDialog::pageIndex( QWidget *widget ) const
225{
226 return( mMainWidget->pageIndex( widget) );
227}
diff --git a/microkde/kutils/kcmultidialog.h b/microkde/kutils/kcmultidialog.h
index 768faea..66412ac 100644
--- a/microkde/kutils/kcmultidialog.h
+++ b/microkde/kutils/kcmultidialog.h
@@ -1,148 +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 <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 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 QVBox* getNewVBoxPage(const QString & modulename) ;
79 79
80 80
81 bool showPage( int index );
82 int activePageIndex() const;
83 int pageIndex( QWidget *widget ) const;
81 84
82protected slots: 85protected slots:
83 /** 86 /**
84 * This slot is called when the user presses the "Default" Button 87 * This slot is called when the user presses the "Default" Button
85 * You can reimplement it if needed. 88 * You can reimplement it if needed.
86 * 89 *
87 * @note Make sure you call the original implementation! 90 * @note Make sure you call the original implementation!
88 **/ 91 **/
89 virtual void slotDefault(); 92 virtual void slotDefault();
90 93
91 /** 94 /**
92 * This slot is called when the user presses the "Apply" Button 95 * This slot is called when the user presses the "Apply" Button
93 * You can reimplement it if needed 96 * You can reimplement it if needed
94 * 97 *
95 * @note Make sure you call the original implementation! 98 * @note Make sure you call the original implementation!
96 **/ 99 **/
97 virtual void slotApply(); 100 virtual void slotApply();
98 101
99 /** 102 /**
100 * This slot is called when the user presses the "OK" Button 103 * This slot is called when the user presses the "OK" Button
101 * You can reimplement it if needed 104 * You can reimplement it if needed
102 * 105 *
103 * @note Make sure you call the original implementation! 106 * @note Make sure you call the original implementation!
104 **/ 107 **/
105 virtual void slotOk(); 108 virtual void slotOk();
106 109
107 /** 110 /**
108 * This slot is called when the user presses the "Help" Button 111 * This slot is called when the user presses the "Help" Button
109 * You can reimplement it if needed 112 * You can reimplement it if needed
110 * 113 *
111 * @note Make sure you call the original implementation! 114 * @note Make sure you call the original implementation!
112 **/ 115 **/
113 virtual void slotHelp(); 116 virtual void slotHelp();
114 117
115 void accept(); 118 void accept();
116 119
117private slots: 120private slots:
118 121
119 void slotAboutToShow(QWidget *); 122 void slotAboutToShow(QWidget *);
120 123
121 void clientChanged(bool state); 124 void clientChanged(bool state);
122 125
123private: 126private:
124/*US 127/*US
125 struct LoadInfo { 128 struct LoadInfo {
126 LoadInfo(const QString &_path, bool _withfallback) 129 LoadInfo(const QString &_path, bool _withfallback)
127 : path(_path), withfallback(_withfallback) 130 : path(_path), withfallback(_withfallback)
128 { } 131 { }
129 QString path; 132 QString path;
130 bool withfallback; 133 bool withfallback;
131 }; 134 };
132*/ 135*/
133 QPtrList<KCModule> modules; 136 QPtrList<KCModule> modules;
134/* 137/*
135 QPtrDict<LoadInfo> moduleDict; 138 QPtrDict<LoadInfo> moduleDict;
136 QString _docPath; 139 QString _docPath;
137*/ 140*/
138 QString _baseGroup; 141 QString _baseGroup;
139 142
140//US 143//US
141 KJanusWidget* mMainWidget; 144 KJanusWidget* mMainWidget;
142 145
143 // For future use 146 // For future use
144 class KCMultiDialogPrivate; 147 class KCMultiDialogPrivate;
145 KCMultiDialogPrivate *d; 148 KCMultiDialogPrivate *d;
146}; 149};
147 150
148#endif //KCMULTIDIALOG_H 151#endif //KCMULTIDIALOG_H