korganizer

koprefsdialog.cpp
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org>
5  Copyright (c) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of TQt, and distribute the resulting executable,
23  without including the source code for TQt in the source distribution.
24 */
25 
26 #include <tqlayout.h>
27 #include <tqlabel.h>
28 #include <tqgroupbox.h>
29 #include <tqbuttongroup.h>
30 #include <tqlineedit.h>
31 #include <tqslider.h>
32 #include <tqfile.h>
33 #include <tqcombobox.h>
34 #include <tqhbox.h>
35 #include <tqvbox.h>
36 #include <tqgrid.h>
37 #include <tqspinbox.h>
38 #include <tqcheckbox.h>
39 #include <tqradiobutton.h>
40 #include <tqpushbutton.h>
41 #include <tqstrlist.h>
42 #include <tqlistview.h>
43 #include <tqtabwidget.h>
44 #include <tqwhatsthis.h>
45 
46 #include <kcolorbutton.h>
47 #include <kcombobox.h>
48 #include <kdebug.h>
49 #include <tdelocale.h>
50 #include <tdeglobal.h>
51 #include <tdemessagebox.h>
52 #include <kiconloader.h>
53 #include <knuminput.h>
54 #include <tdeemailsettings.h>
55 #include <kcalendarsystem.h>
56 #include <ktrader.h>
57 #include <kpushbutton.h>
58 #include <kocore.h>
59 #include <kstandarddirs.h>
60 #include <ksimpleconfig.h>
61 #include <kholidays.h>
62 #include <kurlrequester.h>
63 
65 
66 #if defined(USE_SOLARIS)
67 #include <sys/param.h>
68 
69 #define ZONEINFODIR "/usr/share/lib/zoneinfo"
70 #define INITFILE "/etc/default/init"
71 #endif
72 
73 #include "koprefs.h"
74 
75 #include "koprefsdialog.h"
76 #include "kogroupwareprefspage.h"
77 #include "ktimeedit.h"
78 #include "koglobals.h"
79 #include "stdcalendar.h"
80 #include <tdemacros.h>
81 
82 
83 KOPrefsDialogMain::KOPrefsDialogMain( TQWidget *parent, const char *name )
84  : KPrefsModule( KOPrefs::instance(), parent, name )
85 {
86  TQBoxLayout *topTopLayout = new TQVBoxLayout( this );
87 
88  TQVBox *topFrame = new TQVBox( this );
89  topTopLayout->addWidget( topFrame );
90 
91  topFrame->setSpacing( KDialog::spacingHint() );
92 
93  KPrefsWidBool *emailControlCenter =
94  addWidBool( KOPrefs::instance()->emailControlCenterItem(), topFrame );
95  connect(emailControlCenter->checkBox(),TQ_SIGNAL(toggled(bool)),
96  TQ_SLOT(toggleEmailSettings(bool)));
97 
98  mUserEmailSettings = new TQGrid( 2, topFrame );
99 
100  addWidString( KOPrefs::instance()->userNameItem(), mUserEmailSettings );
101  addWidString( KOPrefs::instance()->userEmailItem(), mUserEmailSettings );
102 
103  TQGroupBox *saveGroup = new TQGroupBox(1,TQt::Horizontal,i18n("Saving Calendar"),
104  topFrame);
105 
106  addWidBool( KOPrefs::instance()->htmlWithSaveItem(), saveGroup );
107 
108  KPrefsWidBool *autoSave = addWidBool( KOPrefs::instance()->autoSaveItem(), saveGroup );
109 
110  TQHBox *intervalBox = new TQHBox( saveGroup );
111  addWidInt( KOPrefs::instance()->autoSaveIntervalItem(), intervalBox );
112  connect( autoSave->checkBox(), TQ_SIGNAL( toggled( bool ) ),
113  intervalBox, TQ_SLOT( setEnabled( bool ) ) );
114  intervalBox->setSpacing( KDialog::spacingHint() );
115  new TQWidget( intervalBox );
116 
117  addWidBool( KOPrefs::instance()->confirmItem(), topFrame );
118  addWidRadios( KOPrefs::instance()->destinationItem(), topFrame);
119  addWidRadios( KOPrefs::instance()->defaultEmailAttachMethodItem(), topFrame );
120 
121  topTopLayout->addStretch( 1 );
122 
123  load();
124 }
125 
126 void KOPrefsDialogMain::toggleEmailSettings( bool on )
127 {
128  mUserEmailSettings->setEnabled( !on );
129 /* if (on) {
130  KEMailSettings settings;
131  mNameEdit->setText( settings.getSetting(KEMailSettings::RealName) );
132  mEmailEdit->setText( settings.getSetting(KEMailSettings::EmailAddress) );
133  } else {
134  mNameEdit->setText( KOPrefs::instance()->mName );
135  mEmailEdit->setText( KOPrefs::instance()->mEmail );
136  }*/
137 }
138 
139 extern "C"
140 {
141  TDE_EXPORT TDECModule *create_korganizerconfigmain( TQWidget *parent, const char * )
142  {
143  return new KOPrefsDialogMain( parent, "kcmkorganizermain" );
144  }
145 }
146 
147 
148 class KOPrefsDialogTime : public KPrefsModule
149 {
150  public:
151  KOPrefsDialogTime( TQWidget *parent, const char *name )
152  : KPrefsModule( KOPrefs::instance(), parent, name )
153  {
154  TQBoxLayout *topTopLayout = new TQVBoxLayout( this );
155 
156  TQWidget *topFrame = new TQWidget( this );
157  topTopLayout->addWidget( topFrame );
158 
159  TQGridLayout *topLayout = new TQGridLayout(topFrame,6,2);
160  topLayout->setSpacing( KDialog::spacingHint() );
161 
162  TQHBox *timeZoneBox = new TQHBox( topFrame );
163  topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
164 
165  TQLabel *timeZoneLabel = new TQLabel( i18n("Timezone:"), timeZoneBox );
166  TQString whatsThis = i18n( "Select your timezone from the list of "
167  "locations on this drop down box. If your city "
168  "is not listed, select one which shares the "
169  "same timezone. KOrganizer will automatically "
170  "adjust for daylight savings." );
171  TQWhatsThis::add( timeZoneLabel, whatsThis );
172  mTimeZoneCombo = new TQComboBox( timeZoneBox );
173 
174  connect( mTimeZoneCombo, TQ_SIGNAL( activated( int ) ),
175  TQ_SLOT( slotWidChanged() ) );
176 
177  FILE *f;
178  char tempstring[101] = "Unknown";
179  TQString sCurrentlySet(i18n("Unknown"));
180  int nCurrentlySet = 0;
181  TQStringList list;
182 
183  // read the currently set time zone
184  #if defined(USE_SOLARIS) // MARCO
185  char buf[MAXPATHLEN];
186 
187  snprintf(buf, MAXPATHLEN,
188  "/bin/fgrep 'TZ=' %s | /bin/head -n 1 | /bin/cut -b 4-",
189  INITFILE);
190 
191  if (f = popen(buf, "r"))
192  {
193  if (fgets(buf, MAXPATHLEN - 1, f) != NULL)
194  {
195  buf[strlen(buf) - 1] = '\0';
196  sCurrentlySet = TQString(buf);
197  }
198  pclose(f);
199  }
200  #else
201  if((f = fopen("/etc/timezone", "r")) != NULL) {
202  // get the currently set timezone
203  fgets(tempstring, 100, f);
204  tempstring[strlen(tempstring) - 1] = '\0';
205  sCurrentlySet = TQString(tempstring);
206  fclose(f);
207  }
208  #endif // !USE_SOLARIS
209 
210  mTimeZoneCombo->insertItem(i18n("[No selection]"));
211 
212  // Read all system time zones
213  #if defined(USE_SOLARIS) // MARCO
214  snprintf(buf, MAXPATHLEN,
215  "/bin/find %s \\( -name src -prune \\) -o -type f -print | /bin/cut -b %d-",
216  ZONEINFODIR, strlen(ZONEINFODIR) + 2);
217 
218  if (f = popen(buf, "r"))
219  {
220  while(fgets(buf, MAXPATHLEN - 1, f) != NULL)
221  {
222  buf[strlen(buf) - 1] = '\0';
223  list.append(buf);
224  }
225  pclose(f);
226  }
227 
228  #else
229  f = popen("grep -e ^[^#] /usr/share/zoneinfo/zone.tab | cut -f 3","r");
230  if (!f) return;
231  while(fgets(tempstring, 100, f) != NULL) {
232  tempstring[strlen(tempstring)-1] = '\0';
233  list.append(i18n(tempstring));
234  tzonenames << tempstring;
235  }
236  pclose(f);
237  #endif // !USE_SOLARIS
238  list.sort();
239 
240  mTimeZoneCombo->insertStringList(list);
241 
242  // find the currently set time zone and select it
243  for ( int i = 0; i < mTimeZoneCombo->count(); ++i )
244  {
245  if (mTimeZoneCombo->text(i) == sCurrentlySet)
246  {
247  nCurrentlySet = i;
248  break;
249  }
250  }
251 
252  mTimeZoneCombo->setCurrentItem(nCurrentlySet);
253  TQWhatsThis::add( mTimeZoneCombo, whatsThis );
254 
255  // holiday region selection
256  TQHBox *holidayRegBox = new TQHBox( topFrame );
257  topLayout->addMultiCellWidget( holidayRegBox, 1, 1, 0, 1 );
258 
259  TQLabel *holidayLabel = new TQLabel( i18n( "Use holiday region:" ), holidayRegBox );
260  whatsThis = i18n( "Select from which region you want to use the "
261  "holidays here. Defined holidays are shown as "
262  "non-working days in the date navigator, the "
263  "agenda view, etc." );
264  TQWhatsThis::add( holidayLabel, whatsThis );
265 
266  mHolidayCombo = new TQComboBox( holidayRegBox );
267  connect( mHolidayCombo, TQ_SIGNAL( activated( int ) ),
268  TQ_SLOT( slotWidChanged() ) );
269 
270  TQWhatsThis::add( mHolidayCombo, whatsThis );
271 
272  TQString currentHolidayName;
273  TQStringList holidayList;
274  TQStringList countryList = KHolidays::locations();
275  TQStringList::ConstIterator it;
276 
277  for ( it = countryList.begin(); it != countryList.end(); ++it ) {
278  TQString countryFile = locate( "locale",
279  "l10n/" + (*it) + "/entry.desktop" );
280  TQString regionName;
281  if ( !countryFile.isEmpty() ) {
282  KSimpleConfig cfg( countryFile );
283  cfg.setGroup( "KCM Locale" );
284  regionName = cfg.readEntry( "Name" );
285  }
286  if (regionName.isEmpty()) regionName = (*it);
287 
288  holidayList << regionName;
289  mRegionMap[regionName] = (*it); //store region for saving to config file
290 
291  if ( KOGlobals::self()->holidays()
292  && ((*it) == KOGlobals::self()->holidays()->location()) )
293  currentHolidayName = regionName;
294  }
295  holidayList.sort();
296  holidayList.push_front( i18n("(None)") ); //be able to disable holidays
297 
298  mHolidayCombo->insertStringList(holidayList);
299 
300  for (int i=0; i < mHolidayCombo->count(); ++i) {
301  if ( mHolidayCombo->text(i) == currentHolidayName ) {
302  mHolidayCombo->setCurrentItem(i);
303  break;
304  }
305  }
306 
307  KPrefsWidTime *dayBegins =
308  addWidTime( KOPrefs::instance()->dayBeginsItem(), topFrame );
309  topLayout->addWidget( dayBegins->label(), 2, 0 );
310  topLayout->addWidget( dayBegins->timeEdit(), 2, 1 );
311 
312  KPrefsWidTime *defaultTime =
313  addWidTime( KOPrefs::instance()->startTimeItem(), topFrame );
314  topLayout->addWidget( defaultTime->label(), 3, 0);
315  topLayout->addWidget( defaultTime->timeEdit(), 3, 1);
316 
317  KPrefsWidDuration *defaultDuration =
318  addWidDuration( KOPrefs::instance()->defaultDurationItem(), topFrame );
319  topLayout->addWidget( defaultDuration->label(), 4, 0 );
320  topLayout->addWidget( defaultDuration->timeEdit(), 4, 1 );
321 
322  TQGroupBox *remindersGroupBox = new TQGroupBox( 1, TQt::Horizontal,
323  i18n( "Reminders" ),
324  topFrame );
325  topLayout->addMultiCellWidget( remindersGroupBox, 5, 5, 0, 1 );
326 
327  TQHBox *remindersBox = new TQHBox( remindersGroupBox );
328  new TQLabel( i18n( "Default reminder time:" ), remindersBox );
329 
330  mReminderTimeSpin = new KIntSpinBox( remindersBox );
331  connect( mReminderTimeSpin, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(slotWidChanged()) );
332 
333  mReminderUnitsCombo = new KComboBox( remindersBox );
334  connect( mReminderUnitsCombo, TQ_SIGNAL(activated(int)), TQ_SLOT(slotWidChanged()) );
335  mReminderUnitsCombo->insertItem( i18n( "minute(s)" ) );
336  mReminderUnitsCombo->insertItem( i18n( "hour(s)" ) );
337  mReminderUnitsCombo->insertItem( i18n( "day(s)" ) );
338 
339  TQHBox *audioFileRemindersBox = new TQHBox( remindersGroupBox );
340 
341  TQCheckBox *cb = addWidBool( KOPrefs::instance()->defaultAudioFileRemindersItem(),
342  audioFileRemindersBox )->checkBox();
343  cb->setText( TQString() );
344 
345  if ( KOPrefs::instance()->audioFilePathItem()->value().isEmpty() ) {
346  TQString defAudioFile = TDEGlobal::dirs()->findResourceDir( "sound", "KDE-Sys-Warning.ogg");
347  KOPrefs::instance()->audioFilePathItem()->setValue( defAudioFile + "KDE-Sys-Warning.ogg" );
348  }
349  TQString filter = i18n( "*.ogg *.wav *.mp3 *.wma *.flac *.aiff *.raw *.au *.ra|"
350  "Audio Files (*.ogg *.wav *.mp3 *.wma *.flac *.aiff *.raw *.au *.ra)" );
351  KURLRequester *rq = addWidPath( KOPrefs::instance()->audioFilePathItem(),
352  audioFileRemindersBox, filter )->urlRequester();
353  rq->setEnabled( cb->isChecked() );
354  connect( cb, TQ_SIGNAL(toggled(bool)),
355  rq, TQ_SLOT(setEnabled( bool)) );
356 
357  TQHBox *eventRemindersBox = new TQHBox( remindersGroupBox );
358  addWidBool( KOPrefs::instance()->defaultEventRemindersItem(), eventRemindersBox )->checkBox();
359 
360  TQHBox *todoRemindersBox = new TQHBox( remindersGroupBox );
361  addWidBool( KOPrefs::instance()->defaultTodoRemindersItem(), todoRemindersBox )->checkBox();
362 
363  TQLabel *alarmDefaultLabel = new TQLabel( i18n( "Enable reminders by default:" ), topFrame);
364  topLayout->addWidget( alarmDefaultLabel, 6, 0 );
365  mAlarmTimeDefaultCheckBox = new TQCheckBox( topFrame );
366  topLayout->addWidget( mAlarmTimeDefaultCheckBox, 6, 1 );
367  connect( mAlarmTimeDefaultCheckBox, TQ_SIGNAL( toggled( bool ) ),
368  TQ_SLOT( slotWidChanged() ) );
369 
370  TQGroupBox *workingHoursGroup = new TQGroupBox(1,TQt::Horizontal,
371  i18n("Working Hours"),
372  topFrame);
373  topLayout->addMultiCellWidget( workingHoursGroup, 7, 7, 0, 1 );
374 
375  TQHBox *workDaysBox = new TQHBox( workingHoursGroup );
376  // Respect start of week setting
377  int weekStart=TDEGlobal::locale()->weekStartDay();
378  for ( int i = 0; i < 7; ++i ) {
379  const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
380  TQString weekDayName = calSys->weekDayName( (i + weekStart + 6)%7 + 1, true );
381  if ( KOPrefs::instance()->mCompactDialogs ) {
382  weekDayName = weekDayName.left( 1 );
383  }
384  int index = ( i + weekStart + 6 ) % 7;
385  mWorkDays[ index ] = new TQCheckBox( weekDayName, workDaysBox );
386  TQWhatsThis::add( mWorkDays[ index ],
387  i18n( "Check this box to make KOrganizer mark the "
388  "working hours for this day of the week. "
389  "If this is a work day for you, check "
390  "this box, or the working hours will not be "
391  "marked with color." ) );
392 
393  connect( mWorkDays[ index ], TQ_SIGNAL( stateChanged( int ) ),
394  TQ_SLOT( slotWidChanged() ) );
395  }
396 
397  TQHBox *workStartBox = new TQHBox(workingHoursGroup);
398  addWidTime( KOPrefs::instance()->workingHoursStartItem(), workStartBox );
399 
400  TQHBox *workEndBox = new TQHBox(workingHoursGroup);
401  addWidTime( KOPrefs::instance()->workingHoursEndItem(), workEndBox );
402 
403 
404  addWidBool( KOPrefs::instance()->excludeHolidaysItem(),
405  workingHoursGroup );
406 
407  topLayout->setRowStretch(8,1);
408 
409  load();
410  }
411 
412  protected:
413  void usrReadConfig()
414  {
415  setCombo( mTimeZoneCombo,
416  i18n( KOPrefs::instance()->mTimeZoneId.utf8() ) );
417 
418  mReminderTimeSpin->setValue( KOPrefs::instance()->mReminderTime );
419  mReminderUnitsCombo->setCurrentItem( KOPrefs::instance()->mReminderTimeUnits );
420 
421  for ( int i = 0; i < 7; ++i ) {
422  mWorkDays[i]->setChecked( (1<<i) & (KOPrefs::instance()->mWorkWeekMask) );
423  }
424  }
425 
426  void usrWriteConfig()
427  {
428  // Find untranslated selected zone
429  TQStringList::Iterator tz;
430  for ( tz = tzonenames.begin(); tz != tzonenames.end(); ++tz )
431  if (mTimeZoneCombo->currentText() == i18n((*tz).utf8()))
432  break;
433  if (tz != tzonenames.end())
434  KOPrefs::instance()->mTimeZoneId = (*tz);
435  else
436  KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText();
437 
438  KOPrefs::instance()->mHolidays = ( mHolidayCombo->currentItem() == 0 ) ? // (None)
439  TQString() :
440  mRegionMap[mHolidayCombo->currentText()];
441 
442  KOPrefs::instance()->mReminderTime = mReminderTimeSpin->value();
443  KOPrefs::instance()->mReminderTimeUnits = mReminderUnitsCombo->currentItem();
444 
445  int mask = 0;
446  for ( int i = 0; i < 7; ++i ) {
447  if (mWorkDays[i]->isChecked()) mask = mask | (1<<i);
448  }
449  KOPrefs::instance()->mWorkWeekMask = mask;
450  KOPrefs::instance()->writeConfig();
451  }
452 
453  void setCombo( TQComboBox *combo, const TQString &text,
454  const TQStringList *tags = 0 )
455  {
456  if (tags) {
457  int i = tags->findIndex(text);
458  if (i > 0) combo->setCurrentItem(i);
459  } else {
460  for(int i=0;i<combo->count();++i) {
461  if (combo->text(i) == text) {
462  combo->setCurrentItem(i);
463  break;
464  }
465  }
466  }
467  }
468 
469  private:
470  TQComboBox *mTimeZoneCombo;
471  TQStringList tzonenames;
472  TQComboBox *mHolidayCombo;
473  TQMap<TQString,TQString> mRegionMap;
474  KIntSpinBox *mReminderTimeSpin;
475  KComboBox *mReminderUnitsCombo;
476  TQCheckBox *mAlarmTimeDefaultCheckBox;
477  TQCheckBox *mWorkDays[7];
478 };
479 
480 extern "C"
481 {
482  TDECModule *create_korganizerconfigtime( TQWidget *parent, const char * )
483  {
484  TDEGlobal::locale()->insertCatalogue( "timezones" );
485  return new KOPrefsDialogTime( parent, "kcmkorganizertime" );
486  }
487 }
488 
489 
490 class KOPrefsDialogViews : public KPrefsModule
491 {
492  public:
493  KOPrefsDialogViews( TQWidget *parent, const char *name )
494  : KPrefsModule( KOPrefs::instance(), parent, name )
495  {
496  TQBoxLayout *topTopLayout = new TQVBoxLayout( this );
497 
498  TQWidget *topFrame = new TQWidget( this );
499  topTopLayout->addWidget( topFrame );
500 
501  TQBoxLayout *topLayout = new TQVBoxLayout( topFrame );
502  topLayout->setSpacing( KDialog::spacingHint() );
503 
504  KPrefsWidBool *enableToolTips =
505  addWidBool( KOPrefs::instance()->enableToolTipsItem(), topFrame );
506  topLayout->addWidget( enableToolTips->checkBox() );
507 
508  KPrefsWidBool *showTodosAgenda =
509  addWidBool( KOPrefs::instance()->showAllDayTodoItem(), topFrame );
510  topLayout->addWidget( showTodosAgenda->checkBox() );
511 
512  /*** Date Navigator Group ***/
513  TQGroupBox *dateNavGroup = new TQGroupBox( 1, TQt::Horizontal,
514  i18n("Date Navigator"),
515  topFrame );
516  addWidBool( KOPrefs::instance()->dailyRecurItem(), dateNavGroup );
517  addWidBool( KOPrefs::instance()->weeklyRecurItem(), dateNavGroup );
518  addWidBool( KOPrefs::instance()->weekNumbersShowWorkItem(), dateNavGroup );
519  topLayout->addWidget( dateNavGroup );
520 
521 
522  /*** Agenda View Group ***/
523  TQGroupBox *agendaGroup = new TQGroupBox( 1, TQt::Horizontal,
524  i18n("Agenda View"),
525  topFrame );
526 
527  TQHBox *hourSizeBox = new TQHBox( agendaGroup );
528  KPrefsWidInt *hourSize =
529  addWidInt( KOPrefs::instance()->hourSizeItem(), hourSizeBox );
530  hourSize->spinBox()->setSuffix(i18n("suffix in the hour size spin box", " pixel"));
531  // horizontal spacer:
532  new TQWidget( hourSizeBox );
533 
534  TQHBox *nextDaysBox = new TQHBox( agendaGroup );
535  KPrefsWidInt *nextDays =
536  addWidInt( KOPrefs::instance()->nextXDaysItem(), nextDaysBox );
537  nextDays->spinBox()->setSuffix(i18n("suffix in the N days spin box", " days"));
538  new TQWidget( nextDaysBox );
539 
540  KPrefsWidBool *marcusBainsEnabled =
541  addWidBool( KOPrefs::instance()->marcusBainsEnabledItem(), agendaGroup );
542 
543  KPrefsWidBool *marcusBainsShowSeconds =
544  addWidBool( KOPrefs::instance()->marcusBainsShowSecondsItem(), agendaGroup );
545  connect( marcusBainsEnabled->checkBox(), TQ_SIGNAL( toggled( bool ) ),
546  marcusBainsShowSeconds->checkBox(), TQ_SLOT( setEnabled( bool ) ) );
547 
548  addWidBool( KOPrefs::instance()->selectionStartsEditorItem(), agendaGroup );
549 
550  addWidCombo( KOPrefs::instance()->agendaViewColorsItem(), agendaGroup );
551 
552  addWidCombo( KOPrefs::instance()->agendaViewCalendarDisplayItem(), agendaGroup );
553 
554  topLayout->addWidget( agendaGroup );
555 
556  /*** Month View Group ***/
557  TQGroupBox *monthGroup = new TQGroupBox( 1, TQt::Horizontal,
558  i18n("Month View"),
559  topFrame );
560  addWidBool( KOPrefs::instance()->enableMonthScrollItem(), monthGroup );
561  addWidBool( KOPrefs::instance()->fullViewMonthItem(), monthGroup );
562  addWidCombo( KOPrefs::instance()->monthItemColorsItem(), monthGroup );
563  topLayout->addWidget( monthGroup );
564 
565 
566  /*** Todo View Group ***/
567  TQGroupBox *todoGroup = new TQGroupBox( 1, TQt::Horizontal,
568  i18n("To-do View"),
569  topFrame );
570  addWidBool( KOPrefs::instance()->fullViewTodoItem(), todoGroup );
571  addWidBool( KOPrefs::instance()->recordTodosInJournalsItem(), todoGroup );
572  topLayout->addWidget( todoGroup );
573 
574  topLayout->addStretch( 1 );
575 
576  load();
577  }
578 };
579 
580 extern "C"
581 {
582  TDECModule *create_korganizerconfigviews( TQWidget *parent, const char * )
583  {
584  return new KOPrefsDialogViews( parent, "kcmkorganizerviews" );
585  }
586 }
587 
588 
589 class KOPrefsDialogFonts : public KPrefsModule
590 {
591  public:
592  KOPrefsDialogFonts( TQWidget *parent, const char *name )
593  : KPrefsModule( KOPrefs::instance(), parent, name )
594  {
595  TQBoxLayout *topTopLayout = new TQVBoxLayout( this );
596 
597  TQWidget *topFrame = new TQWidget( this );
598  topTopLayout->addWidget( topFrame );
599 
600  TQGridLayout *topLayout = new TQGridLayout(topFrame,5,3);
601  topLayout->setSpacing( KDialog::spacingHint() );
602 
603  KPrefsWidFont *timeBarFont =
604  addWidFont( KOPrefs::instance()->timeBarFontItem(), topFrame,
605  TDEGlobal::locale()->formatTime( TQTime( 12, 34 ) ) );
606  topLayout->addWidget(timeBarFont->label(),0,0);
607  topLayout->addWidget(timeBarFont->preview(),0,1);
608  topLayout->addWidget(timeBarFont->button(),0,2);
609 
610  KPrefsWidFont *monthViewFont =
611  addWidFont( KOPrefs::instance()->monthViewFontItem(), topFrame,
612  TDEGlobal::locale()->formatTime(TQTime(12,34)) + " " +
613  i18n("Event text") );
614 
615  topLayout->addWidget(monthViewFont->label(),1,0);
616  topLayout->addWidget(monthViewFont->preview(),1,1);
617  topLayout->addWidget(monthViewFont->button(),1,2);
618 
619  KPrefsWidFont *agendaViewFont =
620  addWidFont( KOPrefs::instance()->agendaViewFontItem(),
621  topFrame, i18n("Event text") );
622  topLayout->addWidget(agendaViewFont->label(),2,0);
623  topLayout->addWidget(agendaViewFont->preview(),2,1);
624  topLayout->addWidget(agendaViewFont->button(),2,2);
625 
626  KPrefsWidFont *marcusBainsFont =
627  addWidFont( KOPrefs::instance()->marcusBainsFontItem(), topFrame,
628  TDEGlobal::locale()->formatTime( TQTime( 12, 34, 23 ) ) );
629  topLayout->addWidget(marcusBainsFont->label(),3,0);
630  topLayout->addWidget(marcusBainsFont->preview(),3,1);
631  topLayout->addWidget(marcusBainsFont->button(),3,2);
632 
633  topLayout->setColStretch(1,1);
634  topLayout->setRowStretch(4,1);
635 
636  load();
637  }
638 };
639 
640 extern "C"
641 {
642  TDECModule *create_korganizerconfigfonts( TQWidget *parent, const char * )
643  {
644  return new KOPrefsDialogFonts( parent, "kcmkorganizerfonts" );
645  }
646 }
647 
648 
649 KOPrefsDialogColors::KOPrefsDialogColors( TQWidget *parent, const char *name )
650  : KPrefsModule( KOPrefs::instance(), parent, name )
651 {
652  TQBoxLayout *topTopLayout = new TQVBoxLayout( this );
653 
654  TQWidget *topFrame = new TQWidget( this );
655  topTopLayout->addWidget( topFrame );
656 
657  TQGridLayout *topLayout = new TQGridLayout(topFrame,7,2);
658  topLayout->setSpacing( KDialog::spacingHint() );
659 
660  // Holiday Color
661  KPrefsWidColor *holidayColor =
662  addWidColor( KOPrefs::instance()->holidayColorItem(), topFrame );
663  topLayout->addWidget(holidayColor->label(),0,0);
664  topLayout->addWidget(holidayColor->button(),0,1);
665 
666  // Highlight Color
667  KPrefsWidColor *highlightColor =
668  addWidColor( KOPrefs::instance()->highlightColorItem(), topFrame );
669  topLayout->addWidget(highlightColor->label(),1,0);
670  topLayout->addWidget(highlightColor->button(),1,1);
671 
672  // agenda view background color
673  KPrefsWidColor *agendaBgColor =
674  addWidColor( KOPrefs::instance()->agendaBgColorItem(), topFrame );
675  topLayout->addWidget(agendaBgColor->label(),2,0);
676  topLayout->addWidget(agendaBgColor->button(),2,1);
677 
678  // working hours color
679  KPrefsWidColor *workingHoursColor =
680  addWidColor( KOPrefs::instance()->workingHoursColorItem(), topFrame );
681  topLayout->addWidget(workingHoursColor->label(),3,0);
682  topLayout->addWidget(workingHoursColor->button(),3,1);
683 
684  // Todo due today color
685  KPrefsWidColor *todoDueTodayColor =
686  addWidColor( KOPrefs::instance()->todoDueTodayColorItem(), topFrame );
687  topLayout->addWidget(todoDueTodayColor->label(),4,0);
688  topLayout->addWidget(todoDueTodayColor->button(),4,1);
689 
690  // Todo overdue color
691  KPrefsWidColor *todoOverdueColor =
692  addWidColor( KOPrefs::instance()->todoOverdueColorItem(), topFrame );
693  topLayout->addWidget(todoOverdueColor->label(),5,0);
694  topLayout->addWidget(todoOverdueColor->button(),5,1);
695 
696  // "No Category" color
697  KPrefsWidColor *unsetCategoryColor =
698  addWidColor( KOPrefs::instance()->unsetCategoryColorItem(), topFrame );
699  topLayout->addWidget( unsetCategoryColor->label(), 6, 0 );
700  topLayout->addWidget( unsetCategoryColor->button(), 6, 1 );
701 
702  // categories colors
703  TQGroupBox *categoryGroup = new TQGroupBox(1,TQt::Horizontal,i18n("Categories"),
704  topFrame);
705  topLayout->addMultiCellWidget(categoryGroup,7,7,0,1);
706 
707 
708  mCategoryCombo = new TQComboBox(categoryGroup);
709  mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
710  TQWhatsThis::add( mCategoryCombo,
711  i18n( "Select here the event category you want to modify. "
712  "You can change the selected category color using "
713  "the button below." ) );
714  connect(mCategoryCombo,TQ_SIGNAL(activated(int)),TQ_SLOT(updateCategoryColor()));
715 
716  mCategoryButton = new KColorButton(categoryGroup);
717  TQWhatsThis::add( mCategoryButton,
718  i18n( "Choose here the color of the event category selected "
719  "using the combo box above." ) );
720  connect(mCategoryButton,TQ_SIGNAL(changed(const TQColor &)),TQ_SLOT(setCategoryColor()));
721  updateCategoryColor();
722 
723  // resources colors
724  TQGroupBox *resourceGroup = new TQGroupBox(1,TQt::Horizontal,i18n("Resources"),
725  topFrame);
726  topLayout->addMultiCellWidget(resourceGroup,8,8,0,1);
727 
728  mResourceCombo = new TQComboBox(resourceGroup);
729  TQWhatsThis::add( mResourceCombo,
730  i18n( "Select here resource you want to modify. "
731  "You can change the selected resource color using "
732  "the button below." ) );
733  connect(mResourceCombo,TQ_SIGNAL(activated(int)),TQ_SLOT(updateResourceColor()));
734 
735  mResourceButton = new KColorButton(resourceGroup);
736  TQWhatsThis::add( mResourceButton,
737  i18n( "Choose here the color of the resource selected "
738  "using the combo box above." ) );
739  connect(mResourceButton,TQ_SIGNAL(changed(const TQColor &)),TQ_SLOT(setResourceColor()));
740  updateResources();
741 
742  topLayout->setRowStretch(9,1);
743 
744  load();
745 }
746 
747 void KOPrefsDialogColors::usrWriteConfig()
748 {
749  TQDictIterator<TQColor> itCat(mCategoryDict);
750  while (itCat.current()) {
751  KOPrefs::instance()->setCategoryColor(itCat.currentKey(),*itCat.current());
752  ++itCat;
753  }
754 
755  TQDictIterator<TQColor> itRes(mResourceDict);
756  while (itRes.current()) {
757  KOPrefs::instance()->setResourceColor(itRes.currentKey(),*itRes.current());
758  ++itRes;
759  }
760 }
761 
762 void KOPrefsDialogColors::usrReadConfig()
763 {
764  updateCategories();
765  updateResources();
766 }
767 
768 void KOPrefsDialogColors::updateCategories()
769 {
770  mCategoryCombo->clear();
771  mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
772  updateCategoryColor();
773 }
774 
775 void KOPrefsDialogColors::setCategoryColor()
776 {
777  mCategoryDict.replace(mCategoryCombo->currentText(), new TQColor(mCategoryButton->color()));
778  slotWidChanged();
779 }
780 
781 void KOPrefsDialogColors::updateCategoryColor()
782 {
783  TQString cat = mCategoryCombo->currentText();
784  TQColor *color = mCategoryDict.find(cat);
785  if (!color) {
786  color = KOPrefs::instance()->categoryColor(cat);
787  }
788  if (color) {
789  mCategoryButton->setColor(*color);
790  }
791 }
792 
793 void KOPrefsDialogColors::updateResources()
794 {
795  mResourceCombo->clear();
796  mResourceIdentifier.clear();
797  kdDebug( 5850) << "KOPrefsDialogColors::updateResources()" << endl;
798 
799  KCal::CalendarResourceManager *manager = KOrg::StdCalendar::self()->resourceManager();
800 
801  kdDebug(5850) << "Loading Calendar resources...:" << endl;
802  KCal::CalendarResourceManager::Iterator it;
803  for( it = manager->begin(); it != manager->end(); ++it ) {
804  if ( !(*it)->subresources().isEmpty() ) {
805  TQStringList subresources = (*it)->subresources();
806  for ( uint i = 0; i < subresources.count(); ++i ) {
807  TQString resource = subresources[ i ];
808  if ( (*it)->subresourceActive( resource ) ) {
809  mResourceCombo->insertItem( (*it)->labelForSubresource( resource ) );
810  mResourceIdentifier.append( resource );
811  }
812  }
813  }
814 
815  mResourceCombo->insertItem( (*it)->resourceName() );
816  mResourceIdentifier.append( (*it)->identifier() );
817  }
818 
819  updateResourceColor();
820 }
821 
822 void KOPrefsDialogColors::setResourceColor()
823 {
824  kdDebug( 5850) << "KOPrefsDialogColors::setResorceColor()" << endl;
825 
826  mResourceDict.replace( mResourceIdentifier[mResourceCombo->currentItem()],
827  new TQColor( mResourceButton->color() ) );
828  slotWidChanged();
829 }
830 
831 void KOPrefsDialogColors::updateResourceColor()
832 {
833  kdDebug( 5850 ) << "KOPrefsDialogColors::updateResourceColor()" << endl;
834  TQString res= mResourceIdentifier[mResourceCombo->currentItem()];
835  TQColor *color = mCategoryDict.find(res);
836  if( !color ) {
837  color = KOPrefs::instance()->resourceColor( res );
838  }
839  if( color ) {
840  mResourceButton->setColor(*color);
841  }
842 }
843 extern "C"
844 {
845  TDECModule *create_korganizerconfigcolors( TQWidget *parent, const char * )
846  {
847  return new KOPrefsDialogColors( parent, "kcmkorganizercolors" );
848  }
849 }
850 
851 
852 KOPrefsDialogGroupScheduling::KOPrefsDialogGroupScheduling( TQWidget *parent, const char *name )
853  : KPrefsModule( KOPrefs::instance(), parent, name )
854 {
855  TQBoxLayout *topTopLayout = new TQVBoxLayout( this );
856 
857  TQWidget *topFrame = new TQWidget( this );
858  topTopLayout->addWidget( topFrame );
859 
860  TQGridLayout *topLayout = new TQGridLayout(topFrame,6,2);
861  topLayout->setSpacing( KDialog::spacingHint() );
862 
863  KPrefsWidBool *useGroupwareBool =
864  addWidBool( KOPrefs::instance()->useGroupwareCommunicationItem(),
865  topFrame );
866  topLayout->addMultiCellWidget(useGroupwareBool->checkBox(),0,0,0,1);
867  // FIXME: This radio button should only be available when KMail is chosen
868 // connect(thekmailradiobuttonupthere,TQ_SIGNAL(toggled(bool)),
869 // useGroupwareBool->checkBox(), TQ_SLOT(enabled(bool)));
870 
871  KPrefsWidBool *bcc =
872  addWidBool( KOPrefs::instance()->bccItem(), topFrame );
873  topLayout->addMultiCellWidget(bcc->checkBox(),1,1,0,1);
874 
875  KPrefsWidRadios *mailClientGroup =
876  addWidRadios( KOPrefs::instance()->mailClientItem(), topFrame );
877  topLayout->addMultiCellWidget(mailClientGroup->groupBox(),2,2,0,1);
878 
879 
880 #if 0
881  KPrefsWidRadios *schedulerGroup =
882  addWidRadios(i18n("Scheduler Mail Client"),KOPrefs::instance()->mIMIPScheduler,
883  topFrame);
884  schedulerGroup->addRadio("Dummy"); // Only for debugging
885  schedulerGroup->addRadio(i18n("Mail client"));
886 
887  topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1);
888 #endif
889 
890  TQLabel *aMailsLabel = new TQLabel(i18n("Additional email addresses:"),topFrame);
891  TQString whatsThis = i18n( "Add, edit or remove additional e-mails addresses "
892  "here. These email addresses are the ones you "
893  "have in addition to the one set in personal "
894  "preferences. If you are an attendee of one event, "
895  "but use another email address there, you need to "
896  "list this address here so KOrganizer can "
897  "recognize it as yours." );
898  TQWhatsThis::add( aMailsLabel, whatsThis );
899  topLayout->addMultiCellWidget(aMailsLabel,3,3,0,1);
900  mAMails = new TQListView(topFrame);
901  TQWhatsThis::add( mAMails, whatsThis );
902 
903  mAMails->addColumn(i18n("Email"),300);
904  topLayout->addMultiCellWidget(mAMails,4,4,0,1);
905 
906  TQLabel *aEmailsEditLabel = new TQLabel(i18n("Additional email address:"),topFrame);
907  whatsThis = i18n( "Edit additional e-mails addresses here. To edit an "
908  "address select it from the list above "
909  "or press the \"New\" button below. These email "
910  "addresses are the ones you have in addition to the "
911  "one set in personal preferences." );
912  TQWhatsThis::add( aEmailsEditLabel, whatsThis );
913  topLayout->addWidget(aEmailsEditLabel,5,0);
914  aEmailsEdit = new TQLineEdit(topFrame);
915  TQWhatsThis::add( aEmailsEdit, whatsThis );
916  aEmailsEdit->setEnabled(false);
917  topLayout->addWidget(aEmailsEdit,5,1);
918 
919  TQPushButton *add = new TQPushButton(i18n("New"),topFrame,"new");
920  whatsThis = i18n( "Press this button to add a new entry to the "
921  "additional e-mail addresses list. Use the edit "
922  "box above to edit the new entry." );
923  TQWhatsThis::add( add, whatsThis );
924  topLayout->addWidget(add,6,0);
925  TQPushButton *del = new TQPushButton(i18n("Remove"),topFrame,"remove");
926  TQWhatsThis::add( del, whatsThis );
927  topLayout->addWidget(del,6,1);
928 
929  //topLayout->setRowStretch(2,1);
930  connect(add, TQ_SIGNAL( clicked() ), this, TQ_SLOT(addItem()) );
931  connect(del, TQ_SIGNAL( clicked() ), this, TQ_SLOT(removeItem()) );
932  connect(aEmailsEdit,TQ_SIGNAL( textChanged(const TQString&) ), this,TQ_SLOT(updateItem()));
933  connect(mAMails,TQ_SIGNAL(selectionChanged(TQListViewItem *)),TQ_SLOT(updateInput()));
934 
935  load();
936 }
937 
938 void KOPrefsDialogGroupScheduling::usrReadConfig()
939 {
940  mAMails->clear();
941  for ( TQStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin();
942  it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) {
943  TQListViewItem *item = new TQListViewItem(mAMails);
944  item->setText(0,*it);
945  mAMails->insertItem(item);
946  }
947 }
948 
949 void KOPrefsDialogGroupScheduling::usrWriteConfig()
950 {
951  KOPrefs::instance()->mAdditionalMails.clear();
952  TQListViewItem *item;
953  item = mAMails->firstChild();
954  while (item)
955  {
956  KOPrefs::instance()->mAdditionalMails.append( item->text(0) );
957  item = item->nextSibling();
958  }
959 }
960 
961 void KOPrefsDialogGroupScheduling::addItem()
962 {
963  aEmailsEdit->setEnabled(true);
964  TQListViewItem *item = new TQListViewItem(mAMails);
965  mAMails->insertItem(item);
966  mAMails->setSelected(item,true);
967  aEmailsEdit->setText(i18n("(EmptyEmail)"));
968  slotWidChanged();
969 }
970 
971 void KOPrefsDialogGroupScheduling::removeItem()
972 {
973  TQListViewItem *item;
974  item = mAMails->selectedItem();
975  if (!item) return;
976  mAMails->takeItem(item);
977  item = mAMails->selectedItem();
978  if (!item) {
979  aEmailsEdit->setText("");
980  aEmailsEdit->setEnabled(false);
981  }
982  if (mAMails->childCount() == 0) {
983  aEmailsEdit->setEnabled(false);
984  }
985  slotWidChanged();
986 }
987 
988 void KOPrefsDialogGroupScheduling::updateItem()
989 {
990  TQListViewItem *item;
991  item = mAMails->selectedItem();
992  if (!item) return;
993  item->setText(0,aEmailsEdit->text());
994  slotWidChanged();
995 }
996 
997 void KOPrefsDialogGroupScheduling::updateInput()
998 {
999  TQListViewItem *item;
1000  item = mAMails->selectedItem();
1001  if (!item) return;
1002  aEmailsEdit->setEnabled(true);
1003  aEmailsEdit->setText(item->text(0));
1004 }
1005 
1006 extern "C"
1007 {
1008  TDECModule *create_korganizerconfiggroupscheduling( TQWidget *parent,
1009  const char * )
1010  {
1011  return new KOPrefsDialogGroupScheduling( parent,
1012  "kcmkorganizergroupscheduling" );
1013  }
1014 }
1015 
1016 
1017 KOPrefsDialogGroupwareScheduling::KOPrefsDialogGroupwareScheduling( TQWidget *parent, const char *name )
1018  : KPrefsModule( KOPrefs::instance(), parent, name )
1019 {
1020  mGroupwarePage = new KOGroupwarePrefsPage( this );
1021  connect( mGroupwarePage, TQ_SIGNAL( changed() ), TQ_SLOT( slotWidChanged() ) );
1022  ( new TQVBoxLayout( this ) )->addWidget( mGroupwarePage );
1023 
1024  load();
1025 }
1026 
1027 void KOPrefsDialogGroupwareScheduling::usrReadConfig()
1028 {
1029  mGroupwarePage->publishEnable->setChecked( KOPrefs::instance()->mFreeBusyPublishAuto );
1030  mGroupwarePage->publishDelay->setValue( KOPrefs::instance()->mFreeBusyPublishDelay );
1031  mGroupwarePage->publishDays->setValue( KOPrefs::instance()->mFreeBusyPublishDays );
1032 
1033  mGroupwarePage->publishUrl->setText( KOPrefs::instance()->mFreeBusyPublishUrl );
1034  mGroupwarePage->publishUser->setText( KOPrefs::instance()->mFreeBusyPublishUser );
1035  mGroupwarePage->publishPassword->setText( KOPrefs::instance()->mFreeBusyPublishPassword );
1036  mGroupwarePage->publishSavePassword->setChecked( KOPrefs::instance()->mFreeBusyPublishSavePassword );
1037 
1038  mGroupwarePage->retrieveEnable->setChecked( KOPrefs::instance()->mFreeBusyRetrieveAuto );
1039  mGroupwarePage->fullDomainRetrieval->setChecked( KOPrefs::instance()->mFreeBusyFullDomainRetrieval );
1040  mGroupwarePage->retrieveUrl->setText( KOPrefs::instance()->mFreeBusyRetrieveUrl );
1041  mGroupwarePage->retrieveUser->setText( KOPrefs::instance()->mFreeBusyRetrieveUser );
1042  mGroupwarePage->retrievePassword->setText( KOPrefs::instance()->mFreeBusyRetrievePassword );
1043  mGroupwarePage->retrieveSavePassword->setChecked( KOPrefs::instance()->mFreeBusyRetrieveSavePassword );
1044 }
1045 
1046 void KOPrefsDialogGroupwareScheduling::usrWriteConfig()
1047 {
1048  KOPrefs::instance()->mFreeBusyPublishAuto = mGroupwarePage->publishEnable->isChecked();
1049  KOPrefs::instance()->mFreeBusyPublishDelay = mGroupwarePage->publishDelay->value();
1050  KOPrefs::instance()->mFreeBusyPublishDays = mGroupwarePage->publishDays->value();
1051 
1052  KOPrefs::instance()->mFreeBusyPublishUrl = mGroupwarePage->publishUrl->text();
1053  KOPrefs::instance()->mFreeBusyPublishUser = mGroupwarePage->publishUser->text();
1054  KOPrefs::instance()->mFreeBusyPublishPassword = mGroupwarePage->publishPassword->text();
1055  KOPrefs::instance()->mFreeBusyPublishSavePassword = mGroupwarePage->publishSavePassword->isChecked();
1056 
1057  KOPrefs::instance()->mFreeBusyRetrieveAuto = mGroupwarePage->retrieveEnable->isChecked();
1058  KOPrefs::instance()->mFreeBusyFullDomainRetrieval = mGroupwarePage->fullDomainRetrieval->isChecked();
1059  KOPrefs::instance()->mFreeBusyRetrieveUrl = mGroupwarePage->retrieveUrl->text();
1060  KOPrefs::instance()->mFreeBusyRetrieveUser = mGroupwarePage->retrieveUser->text();
1061  KOPrefs::instance()->mFreeBusyRetrievePassword = mGroupwarePage->retrievePassword->text();
1062  KOPrefs::instance()->mFreeBusyRetrieveSavePassword = mGroupwarePage->retrieveSavePassword->isChecked();
1063 
1064  // clear the url cache for our user
1065  TQString configFile = locateLocal( "data", "korganizer/freebusyurls" );
1066  TDEConfig cfg( configFile );
1067  cfg.deleteGroup( KOPrefs::instance()->email() );
1068 }
1069 
1070 extern "C"
1071 {
1072  TDECModule *create_korganizerconfigfreebusy( TQWidget *parent, const char * )
1073  {
1074  return new KOPrefsDialogGroupwareScheduling( parent,
1075  "kcmkorganizerfreebusy" );
1076  }
1077 }
1078 
1079 
1080 
1081 class PluginItem : public TQCheckListItem {
1082  public:
1083  PluginItem( TQListView *parent, KService::Ptr service ) :
1084  TQCheckListItem( parent, service->name(), TQCheckListItem::CheckBox ), mService( service )
1085  {}
1086  KService::Ptr service() { return mService; }
1087  private:
1088  KService::Ptr mService;
1089 };
1090 
1091 
1095 KOPrefsDialogPlugins::KOPrefsDialogPlugins( TQWidget *parent, const char* name )
1096  : KPrefsModule( KOPrefs::instance(), parent, name )
1097 {
1098  TQBoxLayout *topTopLayout = new TQVBoxLayout( this );
1099 
1100  TQWidget *topFrame = new TQWidget( this );
1101  topTopLayout->addWidget( topFrame );
1102  TQBoxLayout *topLayout = new TQVBoxLayout( topFrame );
1103  topLayout->setSpacing( KDialog::spacingHint() );
1104 
1105  mListView = new TQListView( topFrame );
1106  mListView->addColumn( i18n("Name") );
1107  mListView->setResizeMode( TQListView::LastColumn );
1108  topLayout->addWidget( mListView );
1109 
1110  mDescription = new TQLabel( topFrame );
1111  mDescription->setAlignment( TQLabel::NoAccel | TQLabel::WordBreak | TQLabel::AlignVCenter );
1112  mDescription->setFrameShape( TQLabel::Panel );
1113  mDescription->setFrameShadow( TQLabel::Sunken );
1114  mDescription->setMinimumSize( TQSize( 0, 55 ) );
1115  mDescription->setSizePolicy(
1116  TQSizePolicy( (TQSizePolicy::SizeType)5, (TQSizePolicy::SizeType)0,
1117  0, 0, mDescription->sizePolicy().hasHeightForWidth() ) );
1118  topLayout->addWidget( mDescription );
1119 
1120 
1121  TQWidget *buttonRow = new TQWidget( topFrame );
1122  TQBoxLayout *buttonRowLayout = new TQHBoxLayout( buttonRow );
1123  mConfigureButton = new KPushButton( KGuiItem( i18n("Configure &Plugin..."),
1124  "configure", TQString(), i18n("This button allows you to configure"
1125  " the plugin that you have selected in the list above") ), buttonRow );
1126 
1127  buttonRowLayout->addWidget( mConfigureButton );
1128  buttonRowLayout->addItem( new TQSpacerItem(1, 1, TQSizePolicy::Expanding) );
1129  topLayout->addWidget( buttonRow );
1130  connect( mConfigureButton, TQ_SIGNAL( clicked() ), TQ_SLOT( configure() ) );
1131 
1132  connect( mListView, TQ_SIGNAL( selectionChanged( TQListViewItem* ) ),
1133  TQ_SLOT( selectionChanged( TQListViewItem* ) ) );
1134  connect( mListView, TQ_SIGNAL( clicked( TQListViewItem* ) ),
1135  TQ_SLOT( slotWidChanged() ) );
1136 
1137  load();
1138 // usrReadConfig();
1139  selectionChanged( 0 );
1140 }
1141 
1142 void KOPrefsDialogPlugins::usrReadConfig()
1143 {
1144  mListView->clear();
1145  TDETrader::OfferList plugins = KOCore::self()->availablePlugins();
1146  plugins += KOCore::self()->availableParts();
1147 
1148  TQStringList selectedPlugins = KOPrefs::instance()->mSelectedPlugins;
1149 
1150  TDETrader::OfferList::ConstIterator it;
1151  for( it = plugins.begin(); it != plugins.end(); ++it ) {
1152  TQCheckListItem *item = new PluginItem( mListView, *it );
1153  if ( selectedPlugins.find( (*it)->desktopEntryName() ) !=
1154  selectedPlugins.end() ) {
1155  item->setOn( true );
1156  }
1157  }
1158 }
1159 
1160 void KOPrefsDialogPlugins::usrWriteConfig()
1161 {
1162  TQStringList selectedPlugins;
1163 
1164  PluginItem *item = static_cast<PluginItem *>( mListView->firstChild() );
1165  while( item ) {
1166  if( item->isOn() ) {
1167  selectedPlugins.append( item->service()->desktopEntryName() );
1168  }
1169  item = static_cast<PluginItem *>( item->nextSibling() );
1170  }
1171  KOPrefs::instance()->mSelectedPlugins = selectedPlugins;
1172 }
1173 
1174 void KOPrefsDialogPlugins::configure()
1175 {
1176  PluginItem *item = static_cast<PluginItem *>( mListView->selectedItem() );
1177  if ( !item ) return;
1178 
1179  KOrg::Plugin *plugin = KOCore::self()->loadPlugin( item->service() );
1180 
1181  if ( plugin ) {
1182  plugin->configure( this );
1183  delete plugin;
1184  } else {
1185  KMessageBox::sorry( this, i18n( "Unable to configure this plugin" ),
1186  "PluginConfigUnable" );
1187  }
1188 }
1189 
1190 void KOPrefsDialogPlugins::selectionChanged( TQListViewItem *i )
1191 {
1192  PluginItem *item = dynamic_cast<PluginItem*>( i );
1193  if ( !item ) {
1194  mConfigureButton->setEnabled( false );
1195  mDescription->setText( TQString() );
1196  return;
1197  }
1198 
1199  TQVariant variant = item->service()->property( "X-TDE-KOrganizer-HasSettings" );
1200 
1201  bool hasSettings = true;
1202  if ( variant.isValid() )
1203  hasSettings = variant.toBool();
1204 
1205  mDescription->setText( item->service()->comment() );
1206  mConfigureButton->setEnabled( hasSettings );
1207 
1208  slotWidChanged();
1209 }
1210 
1211 extern "C"
1212 {
1213  TDECModule *create_korganizerconfigplugins( TQWidget *parent, const char * )
1214  {
1215  return new KOPrefsDialogPlugins( parent,
1216  "kcmkorganizerplugins" );
1217  }
1218 }
1219 
1220 
1221 extern "C"
1222 {
1223  TDECModule *create_korgdesignerfields( TQWidget *parent, const char * ) {
1224  return new KOPrefsDesignerFields( parent, "kcmkorgdesignerfields" );
1225  }
1226 }
1227 
1228 KOPrefsDesignerFields::KOPrefsDesignerFields( TQWidget *parent, const char *name )
1229  : KCMDesignerFields( parent, name )
1230 {
1231 }
1232 
1233 TQString KOPrefsDesignerFields::localUiDir()
1234 {
1235  TQString dir = locateLocal( "data", "korganizer/designer/event/");
1236  kdDebug() << "KOPrefsDesignerFields::localUiDir(): " << dir << endl;
1237  return dir;
1238 }
1239 
1240 TQString KOPrefsDesignerFields::uiPath()
1241 {
1242  return "korganizer/designer/event/";
1243 }
1244 
1245 void KOPrefsDesignerFields::writeActivePages( const TQStringList &activePages )
1246 {
1247  KOPrefs::instance()->setActiveDesignerFields( activePages );
1248  KOPrefs::instance()->writeConfig();
1249 }
1250 
1251 TQStringList KOPrefsDesignerFields::readActivePages()
1252 {
1253  return KOPrefs::instance()->activeDesignerFields();
1254 }
1255 
1256 TQString KOPrefsDesignerFields::applicationName()
1257 {
1258  return "KORGANIZER";
1259 }
1260 
1261 #include "koprefsdialog.moc"