summaryrefslogtreecommitdiffabout
path: root/microkde/kutils
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /microkde/kutils
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'microkde/kutils') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kutils/kcmultidialog.cpp201
-rw-r--r--microkde/kutils/kcmultidialog.h147
2 files changed, 348 insertions, 0 deletions
diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp
new file mode 100644
index 0000000..4136622
--- a/dev/null
+++ b/microkde/kutils/kcmultidialog.cpp
@@ -0,0 +1,201 @@
1/*
2 Copyright (c) 2000 Matthias Elter <elter@kde.org>
3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
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
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19
20*/
21
22#include <qhbox.h>
23#include <qvbox.h>
24#include <qcursor.h>
25#include <qlayout.h>
26
27#include <klocale.h>
28#include <kglobal.h>
29#include <kdebug.h>
30#include <kiconloader.h>
31#include <kmessagebox.h>
32//US #include <klibloader.h>
33#include <krun.h>
34#include <kprocess.h>
35
36#include "kcmultidialog.h"
37//US #include "kcmultidialog.moc"
38//US #include "kcmoduleloader.h"
39
40KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal)
41 : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok,
42 parent, name, modal, true), d(0L)
43{
44 enableButton(Apply, false);
45 //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *)));
46 _baseGroup = baseGroup;
47 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed );
48 setMainWidget(mMainWidget );
49#ifdef DESKTOP_VERSION
50 resize(640,480);
51#else
52 resize(640,480);
53 setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480));
54 //showMaximized();
55#endif
56
57}
58
59KCMultiDialog::~KCMultiDialog()
60{
61//US moduleDict.setAutoDelete(true);
62}
63
64void KCMultiDialog::slotDefault()
65{
66
67 int curPageIndex = mMainWidget->activePageIndex();
68
69 QPtrListIterator<KCModule> it(modules);
70 for (; it.current(); ++it)
71 {
72 if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex)
73 {
74 (*it)->defaults();
75 clientChanged(true);
76 return;
77 }
78 }
79
80}
81
82void KCMultiDialog::slotApply()
83{
84qDebug("KCMultiDialog::slotApply clicked");
85
86 QPtrListIterator<KCModule> it(modules);
87 for (; it.current(); ++it)
88 (*it)->save();
89 clientChanged(false);
90
91 emit applyClicked();
92
93}
94
95
96void KCMultiDialog::slotOk()
97{
98qDebug("KCMultiDialog::slotOk clicked");
99
100 QPtrListIterator<KCModule> it(modules);
101 for (; it.current(); ++it)
102 (*it)->save();
103 accept();
104
105 emit okClicked();
106}
107
108void KCMultiDialog::slotHelp()
109{
110/*US
111 KURL url( KURL("help:/"), _docPath );
112
113 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") {
114 KProcess process;
115 process << "khelpcenter"
116 << url.url();
117 process.start(KProcess::DontCare);
118 process.detach();
119 } else {
120 new KRun(url);
121 }
122*/
123}
124
125void KCMultiDialog::clientChanged(bool state)
126{
127 enableButton(Apply, state);
128}
129
130/*US
131void KCMultiDialog::addModule(const QString& path, bool withfallback)
132{
133 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl;
134
135 KCModuleInfo info(path, _baseGroup);
136
137 QHBox* page = addHBoxPage(info.moduleName(), info.comment(),
138 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium));
139 if(!page) {
140 KCModuleLoader::unloadModule(info);
141 return;
142 }
143 moduleDict.insert(page, new LoadInfo(path, withfallback));
144 if (modules.isEmpty())
145 slotAboutToShow(page);
146}
147*/
148QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename )
149{
150 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() );
151 return page;
152
153}
154//US special method for microkde. We dop noty want to load everything dynamically.
155void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname)
156{
157
158 modules.append(module);
159 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
160
161
162}
163
164void KCMultiDialog::slotAboutToShow(QWidget *page)
165{
166/*US
167 LoadInfo *loadInfo = moduleDict[page];
168 if (!loadInfo)
169 return;
170
171 QApplication::setOverrideCursor(Qt::WaitCursor);
172
173 moduleDict.remove(page);
174
175 KCModuleInfo info(loadInfo->path, _baseGroup);
176
177 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback);
178
179 if (!module)
180 {
181 QApplication::restoreOverrideCursor();
182 KCModuleLoader::showLastLoaderError(this);
183 delete loadInfo;
184 return;
185 }
186
187 module->reparent(page,0,QPoint(0,0),true);
188 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
189 //setHelp( docpath, QString::null );
190 _docPath = info.docPath();
191 modules.append(module);
192
193 //KCGlobal::repairAccels( topLevelWidget() );
194
195 delete loadInfo;
196
197 QApplication::restoreOverrideCursor();
198*/
199
200qDebug("KCMultiDialog::slotAboutToShow not implemented");
201}
diff --git a/microkde/kutils/kcmultidialog.h b/microkde/kutils/kcmultidialog.h
new file mode 100644
index 0000000..63d5d42
--- a/dev/null
+++ b/microkde/kutils/kcmultidialog.h
@@ -0,0 +1,147 @@
1/*
2 Copyright (c) 2000 Matthias Elter <elter@kde.org>
3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
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
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19
20*/
21
22#ifndef KCMULTIDIALOG_H
23#define KCMULTIDIALOG_H
24
25#include <qptrlist.h>
26#include <qptrdict.h>
27
28#include <kdialogbase.h>
29#include <kjanuswidget.h>
30#include <kcmodule.h>
31
32
33/**
34 * A class that offers a @ref KDialogBase containing arbitrary KControl Modules
35 *
36 * @short A method that offers a @ref KDialogBase containing arbitrary
37 * KControl Modules.
38 *
39 * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org>
40 * @since 3.2
41 */
42class KCMultiDialog : public KDialogBase
43{
44 Q_OBJECT
45
46public:
47 /**
48 * Constructs a new KCMultiDialog
49 *
50 * @param parent The parent Widget
51 * @param name The widget name
52 * @param baseGroup The baseGroup, if you want to call a module out of
53 * kcontrol, just keep "settings"
54 * @param modal If you pass true here, the dialog will be modal
55 **/
56 KCMultiDialog(const QString& baseGroup = QString::fromLatin1("settings"),
57 QWidget *parent=0, const char *name=0,
58 bool modal=false);
59
60 /**
61 * Destructor
62 **/
63 virtual ~KCMultiDialog();
64
65 /**
66 * Add a module.
67 *
68 * @param module Specify the name of the module that is to be added
69 * to the list of modules the dialog will show.
70 *
71 * @param withfallback Try harder to load the module. Might result
72 * in the module appearing outside the dialog.
73 **/
74//US void addModule(const QString& module, bool withfallback=true);
75
76
77//US special method for microkde. We dop noty want to load everything dynamically.
78 void addModule(KCModule* module );//, const QString& modulename, const QString& iconname);
79 QVBox* getNewVBoxPage(const QString & modulename) ;
80
81
82
83protected slots:
84 /**
85 * This slot is called when the user presses the "Default" Button
86 * You can reimplement it if needed.
87 *
88 * @note Make sure you call the original implementation!
89 **/
90 virtual void slotDefault();
91
92 /**
93 * This slot is called when the user presses the "Apply" Button
94 * You can reimplement it if needed
95 *
96 * @note Make sure you call the original implementation!
97 **/
98 virtual void slotApply();
99
100 /**
101 * This slot is called when the user presses the "OK" Button
102 * You can reimplement it if needed
103 *
104 * @note Make sure you call the original implementation!
105 **/
106 virtual void slotOk();
107
108 /**
109 * This slot is called when the user presses the "Help" Button
110 * You can reimplement it if needed
111 *
112 * @note Make sure you call the original implementation!
113 **/
114 virtual void slotHelp();
115
116private slots:
117
118 void slotAboutToShow(QWidget *);
119
120 void clientChanged(bool state);
121
122private:
123/*US
124 struct LoadInfo {
125 LoadInfo(const QString &_path, bool _withfallback)
126 : path(_path), withfallback(_withfallback)
127 { }
128 QString path;
129 bool withfallback;
130 };
131*/
132 QPtrList<KCModule> modules;
133/*
134 QPtrDict<LoadInfo> moduleDict;
135 QString _docPath;
136*/
137 QString _baseGroup;
138
139//US
140 KJanusWidget* mMainWidget;
141
142 // For future use
143 class KCMultiDialogPrivate;
144 KCMultiDialogPrivate *d;
145};
146
147#endif //KCMULTIDIALOG_H