summaryrefslogtreecommitdiffabout
path: root/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
Unidiff
Diffstat (limited to 'libkdepim/kcmconfigs/kdepimconfigwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kcmconfigs/kdepimconfigwidget.cpp273
1 files changed, 273 insertions, 0 deletions
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
new file mode 100644
index 0000000..477267c
--- a/dev/null
+++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
@@ -0,0 +1,273 @@
1/*
2 This file is part of KdePim/Pi.
3 Copyright (c) 2004 Ulf Schenk
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program 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
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24/*
25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk
27
28$Id$
29*/
30
31#include <qlayout.h>
32#include <qtabwidget.h>
33#include <qcombobox.h>
34#include <qgroupbox.h>
35#include <qlabel.h>
36#include <qlineedit.h>
37#include <qfile.h>
38
39#include <kdialog.h>
40#include <klocale.h>
41
42#include <stdlib.h>
43
44/*US
45#include <qcheckbox.h>
46#include <qframe.h>
47#include <qpushbutton.h>
48#include <qcombobox.h>
49#include <qlineedit.h>
50#include <qlabel.h>
51#include <qfile.h>
52
53#include <kconfig.h>
54#include <kdebug.h>
55#include <kdialog.h>
56#include <klistview.h>
57#include <klocale.h>
58#include <kglobal.h>
59#include <kmessagebox.h>
60#include <kstandarddirs.h>
61
62#ifndef KAB_EMBEDDED
63#include <ktrader.h>
64#else // KAB_EMBEDDED
65#include <mergewidget.h>
66#include <distributionlistwidget.h>
67#endif // KAB_EMBEDDED
68
69#include "addresseewidget.h"
70#include "extensionconfigdialog.h"
71#include "extensionwidget.h"
72*/
73
74#include "kpimprefs.h"
75
76#include "kdepimconfigwidget.h"
77
78
79KDEPIMConfigWidget::KDEPIMConfigWidget( QWidget *parent, const char *name )
80 : QWidget( parent, name )
81{
82 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
83 KDialog::spacingHint() );
84
85 QTabWidget *tabWidget = new QTabWidget( this );
86 topLayout->addWidget( tabWidget );
87/*US
88 // General page
89 QWidget *generalPage = new QWidget( this );
90 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(),
91 KDialog::spacingHintSmall() );
92 //general groupbox
93 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage );
94 QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() );
95 boxLayout->setAlignment( Qt::AlignTop );
96 boxLayout->setMargin(KDialog::marginHintSmall() );
97 groupBox->layout()->setMargin(KDialog::marginHintSmall()) ;
98 groupBox->layout()->setSpacing(KDialog::spacingHintSmall());
99 boxLayout->setSpacing( KDialog::spacingHintSmall() );
100 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" );
101 boxLayout->addWidget( mViewsSingleClickBox );
102
103 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" );
104 boxLayout->addWidget( mNameParsing );
105
106 layout->addWidget( groupBox );
107
108
109 //extensions groupbox
110
111 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage );
112 QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() );
113 boxLayout->setAlignment( Qt::AlignTop );
114 boxLayout->setMargin(KDialog::marginHintSmall());
115 boxLayout->setSpacing(KDialog::spacingHintSmall());
116 groupBox->layout()->setMargin(1) ;
117 groupBox->layout()->setSpacing(0);
118 mExtensionView = new KListView( groupBox );
119 mExtensionView->setAllColumnsShowFocus( true );
120 mExtensionView->addColumn( i18n( "Name" ) );
121 mExtensionView->addColumn( i18n( "Description" ) );
122 mExtensionView->setMaximumHeight(80);
123
124 boxLayout->addWidget( mExtensionView );
125
126 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox );
127 mConfigureButton->setEnabled( false );
128 boxLayout->addWidget( mConfigureButton );
129
130 layout->addWidget( groupBox );
131
132 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
133 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
134 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ),
135 SLOT( selectionChanged( QListViewItem* ) ) );
136 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ),
137 SLOT( itemClicked( QListViewItem* ) ) );
138 connect( mConfigureButton, SIGNAL( clicked() ),
139 SLOT( configureExtension() ) );
140
141 tabWidget->addTab( generalPage, i18n( "General" ) );
142
143 // Addressee page
144 mAddresseeWidget = new AddresseeWidget( this );
145 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
146 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
147*/
148
149 // mailclient page
150 QWidget *mailclientPage = new QWidget( this );
151 QVBoxLayout* layout = new QVBoxLayout( mailclientPage, KDialog::marginHintSmall(),
152 KDialog::spacingHintSmall() );
153
154 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), mailclientPage );
155 QVBoxLayout* boxLayout = new QVBoxLayout( groupBox->layout() );
156 boxLayout->setAlignment( Qt::AlignTop );
157// boxLayout->setMargin(KDialog::marginHintSmall() );
158// groupBox->layout()->setMargin(KDialog::marginHintSmall()) ;
159// groupBox->layout()->setSpacing(KDialog::spacingHintSmall());
160// boxLayout->setSpacing( KDialog::spacingHintSmall() );
161
162 mEmailClient = new QComboBox( groupBox );
163 mEmailClient->insertItem( i18n("OM/Pi"), KPimPrefs::OMPI );
164 mEmailClient->insertItem( i18n("Qtopia mail"), KPimPrefs::QTOPIA );
165 mEmailClient->insertItem( i18n("Opie mail"), KPimPrefs::OPIE );
166 mEmailClient->insertItem( i18n("Other"), KPimPrefs::OTHER );
167 boxLayout->addWidget( mEmailClient );
168
169 connect( mEmailClient, SIGNAL( activated( int ) ),
170 this, SLOT (emailclient_changed( int ) ) );
171
172 QLabel* lab = new QLabel( i18n("Channel:"), groupBox);
173 boxLayout->addWidget( lab );
174 mEmailChannel = new QLineEdit(groupBox);
175 mEmailChannel->setReadOnly(true);
176 boxLayout->addWidget( mEmailChannel );
177
178 layout->addWidget( groupBox );
179 tabWidget->addTab( mailclientPage, i18n( "Mail" ) );
180
181
182
183}
184
185
186
187void KDEPIMConfigWidget::emailclient_changed( int newClient )
188{
189 if (newClient == KPimPrefs::OTHER)
190 mEmailChannel->setReadOnly(false);
191 else
192 mEmailChannel->setReadOnly(true);
193
194 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
195 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
196
197 if (opiepath.isEmpty())
198 opiepath = qtopiapath;
199
200 QString text = mEmailChannel->text();
201
202 if (newClient == KPimPrefs::OPIE)
203 {
204 if ( QFile::exists( opiepath + "/bin/opiemail" ))
205 text = "QPE/Application/opiemail";
206 else
207 text = "FILENOTFOUND: " + opiepath + "/bin/opiemail";
208 }
209 else if (newClient == KPimPrefs::QTOPIA)
210 {
211 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
212 text = "QPE/Application/qtmail";
213 else
214 text = "FILENOTFOUND: " + qtopiapath + "/bin/qtmail";
215
216 }
217 else if (newClient == KPimPrefs::OMPI)
218 {
219 if ( QFile::exists( qtopiapath + "/bin/ompi" ))
220 text = "QPE/Application/ompi";
221 else if ( QFile::exists( opiepath + "/bin/ompi" ))
222 text = "QPE/Application/ompi";
223 else
224 text = "FILENOTFOUND: " + qtopiapath + "/bin/ompi";
225
226 }
227 else
228 {
229 //do nothing if we choosed other
230 }
231
232 mEmailChannel->setText( text );
233
234
235}
236
237
238void KDEPIMConfigWidget::restoreSettings(KPimPrefs* prefs)
239{
240 bool blocked = signalsBlocked();
241 blockSignals( true );
242
243 mEmailChannel->setText( prefs->mEmailChannel );
244 mEmailClient->setCurrentItem(prefs->mEmailClient);
245
246 blockSignals( blocked );
247
248 emit changed( false );
249}
250
251void KDEPIMConfigWidget::saveSettings(KPimPrefs* prefs)
252{
253 prefs->mEmailClient = mEmailClient->currentItem();
254 prefs->mEmailChannel = mEmailChannel->text();
255
256 prefs->writeConfig();
257
258 emit changed( false );
259}
260
261void KDEPIMConfigWidget::defaults(KPimPrefs* prefs)
262{
263 mEmailClient->setCurrentItem(KPimPrefs::OMPI);
264 emailclient_changed( KPimPrefs::OMPI );
265
266
267 emit changed( true );
268}
269
270void KDEPIMConfigWidget::modified()
271{
272 emit changed( true );
273}