00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <qlayout.h>
00027 #include <qlabel.h>
00028 #include <qgroupbox.h>
00029 #include <qbuttongroup.h>
00030 #include <qlineedit.h>
00031 #include <qslider.h>
00032 #include <qfile.h>
00033 #include <qcombobox.h>
00034 #include <qhbox.h>
00035 #include <qvbox.h>
00036 #include <qgrid.h>
00037 #include <qspinbox.h>
00038 #include <qcheckbox.h>
00039 #include <qradiobutton.h>
00040 #include <qpushbutton.h>
00041 #include <qstrlist.h>
00042 #include <qlistview.h>
00043 #include <qtabwidget.h>
00044 #include <qwhatsthis.h>
00045
00046 #include <kcolorbutton.h>
00047 #include <kcombobox.h>
00048 #include <kdebug.h>
00049 #include <klocale.h>
00050 #include <kglobal.h>
00051 #include <kmessagebox.h>
00052 #include <kiconloader.h>
00053 #include <knuminput.h>
00054 #include <kemailsettings.h>
00055 #include <kcalendarsystem.h>
00056 #include <ktrader.h>
00057 #include <kpushbutton.h>
00058 #include <kocore.h>
00059 #include <kstandarddirs.h>
00060 #include <ksimpleconfig.h>
00061 #include <kholidays.h>
00062 #include <kurlrequester.h>
00063
00064 #include <libkcal/calendarresources.h>
00065
00066 #if defined(USE_SOLARIS)
00067 #include <sys/param.h>
00068
00069 #define ZONEINFODIR "/usr/share/lib/zoneinfo"
00070 #define INITFILE "/etc/default/init"
00071 #endif
00072
00073 #include "koprefs.h"
00074
00075 #include "koprefsdialog.h"
00076 #include "kogroupwareprefspage.h"
00077 #include "ktimeedit.h"
00078 #include "koglobals.h"
00079 #include "stdcalendar.h"
00080 #include <kdepimmacros.h>
00081
00082
00083 KOPrefsDialogMain::KOPrefsDialogMain( QWidget *parent, const char *name )
00084 : KPrefsModule( KOPrefs::instance(), parent, name )
00085 {
00086 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00087
00088 QVBox *topFrame = new QVBox( this );
00089 topTopLayout->addWidget( topFrame );
00090
00091 topFrame->setSpacing( KDialog::spacingHint() );
00092
00093 KPrefsWidBool *emailControlCenter =
00094 addWidBool( KOPrefs::instance()->emailControlCenterItem(), topFrame );
00095 connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)),
00096 SLOT(toggleEmailSettings(bool)));
00097
00098 mUserEmailSettings = new QGrid( 2, topFrame );
00099
00100 addWidString( KOPrefs::instance()->userNameItem(), mUserEmailSettings );
00101 addWidString( KOPrefs::instance()->userEmailItem(), mUserEmailSettings );
00102
00103 QGroupBox *saveGroup = new QGroupBox(1,Horizontal,i18n("Saving Calendar"),
00104 topFrame);
00105
00106 addWidBool( KOPrefs::instance()->htmlWithSaveItem(), saveGroup );
00107
00108 KPrefsWidBool *autoSave = addWidBool( KOPrefs::instance()->autoSaveItem(), saveGroup );
00109
00110 QHBox *intervalBox = new QHBox( saveGroup );
00111 addWidInt( KOPrefs::instance()->autoSaveIntervalItem(), intervalBox );
00112 connect( autoSave->checkBox(), SIGNAL( toggled( bool ) ),
00113 intervalBox, SLOT( setEnabled( bool ) ) );
00114 intervalBox->setSpacing( KDialog::spacingHint() );
00115 new QWidget( intervalBox );
00116
00117 addWidBool( KOPrefs::instance()->confirmItem(), topFrame );
00118 addWidRadios( KOPrefs::instance()->destinationItem(), topFrame);
00119 addWidRadios( KOPrefs::instance()->defaultEmailAttachMethodItem(), topFrame );
00120
00121 topTopLayout->addStretch( 1 );
00122
00123 load();
00124 }
00125
00126 void KOPrefsDialogMain::toggleEmailSettings( bool on )
00127 {
00128 mUserEmailSettings->setEnabled( !on );
00129
00130
00131
00132
00133
00134
00135
00136
00137 }
00138
00139 extern "C"
00140 {
00141 KDE_EXPORT KCModule *create_korganizerconfigmain( QWidget *parent, const char * )
00142 {
00143 return new KOPrefsDialogMain( parent, "kcmkorganizermain" );
00144 }
00145 }
00146
00147
00148 class KOPrefsDialogTime : public KPrefsModule
00149 {
00150 public:
00151 KOPrefsDialogTime( QWidget *parent, const char *name )
00152 : KPrefsModule( KOPrefs::instance(), parent, name )
00153 {
00154 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00155
00156 QWidget *topFrame = new QWidget( this );
00157 topTopLayout->addWidget( topFrame );
00158
00159 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
00160 topLayout->setSpacing( KDialog::spacingHint() );
00161
00162 QHBox *timeZoneBox = new QHBox( topFrame );
00163 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
00164
00165 QLabel *timeZoneLabel = new QLabel( i18n("Timezone:"), timeZoneBox );
00166 QString whatsThis = i18n( "Select your timezone from the list of "
00167 "locations on this drop down box. If your city "
00168 "is not listed, select one which shares the "
00169 "same timezone. KOrganizer will automatically "
00170 "adjust for daylight savings." );
00171 QWhatsThis::add( timeZoneLabel, whatsThis );
00172 mTimeZoneCombo = new QComboBox( timeZoneBox );
00173
00174 connect( mTimeZoneCombo, SIGNAL( activated( int ) ),
00175 SLOT( slotWidChanged() ) );
00176
00177 FILE *f;
00178 char tempstring[101] = "Unknown";
00179 QString sCurrentlySet(i18n("Unknown"));
00180 int nCurrentlySet = 0;
00181 QStringList list;
00182
00183
00184 #if defined(USE_SOLARIS) // MARCO
00185 char buf[MAXPATHLEN];
00186
00187 snprintf(buf, MAXPATHLEN,
00188 "/bin/fgrep 'TZ=' %s | /bin/head -n 1 | /bin/cut -b 4-",
00189 INITFILE);
00190
00191 if (f = popen(buf, "r"))
00192 {
00193 if (fgets(buf, MAXPATHLEN - 1, f) != NULL)
00194 {
00195 buf[strlen(buf) - 1] = '\0';
00196 sCurrentlySet = QString(buf);
00197 }
00198 pclose(f);
00199 }
00200 #else
00201 if((f = fopen("/etc/timezone", "r")) != NULL) {
00202
00203 fgets(tempstring, 100, f);
00204 tempstring[strlen(tempstring) - 1] = '\0';
00205 sCurrentlySet = QString(tempstring);
00206 fclose(f);
00207 }
00208 #endif // !USE_SOLARIS
00209
00210 mTimeZoneCombo->insertItem(i18n("[No selection]"));
00211
00212
00213 #if defined(USE_SOLARIS) // MARCO
00214 snprintf(buf, MAXPATHLEN,
00215 "/bin/find %s \\( -name src -prune \\) -o -type f -print | /bin/cut -b %d-",
00216 ZONEINFODIR, strlen(ZONEINFODIR) + 2);
00217
00218 if (f = popen(buf, "r"))
00219 {
00220 while(fgets(buf, MAXPATHLEN - 1, f) != NULL)
00221 {
00222 buf[strlen(buf) - 1] = '\0';
00223 list.append(buf);
00224 }
00225 pclose(f);
00226 }
00227
00228 #else
00229 f = popen("grep -e ^[^#] /usr/share/zoneinfo/zone.tab | cut -f 3","r");
00230 if (!f) return;
00231 while(fgets(tempstring, 100, f) != NULL) {
00232 tempstring[strlen(tempstring)-1] = '\0';
00233 list.append(i18n(tempstring));
00234 tzonenames << tempstring;
00235 }
00236 pclose(f);
00237 #endif // !USE_SOLARIS
00238 list.sort();
00239
00240 mTimeZoneCombo->insertStringList(list);
00241
00242
00243 for ( int i = 0; i < mTimeZoneCombo->count(); ++i )
00244 {
00245 if (mTimeZoneCombo->text(i) == sCurrentlySet)
00246 {
00247 nCurrentlySet = i;
00248 break;
00249 }
00250 }
00251
00252 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
00253 QWhatsThis::add( mTimeZoneCombo, whatsThis );
00254
00255
00256 QHBox *holidayRegBox = new QHBox( topFrame );
00257 topLayout->addMultiCellWidget( holidayRegBox, 1, 1, 0, 1 );
00258
00259 QLabel *holidayLabel = new QLabel( i18n( "Use holiday region:" ), holidayRegBox );
00260 whatsThis = i18n( "Select from which region you want to use the "
00261 "holidays here. Defined holidays are shown as "
00262 "non-working days in the date navigator, the "
00263 "agenda view, etc." );
00264 QWhatsThis::add( holidayLabel, whatsThis );
00265
00266 mHolidayCombo = new QComboBox( holidayRegBox );
00267 connect( mHolidayCombo, SIGNAL( activated( int ) ),
00268 SLOT( slotWidChanged() ) );
00269
00270 QWhatsThis::add( mHolidayCombo, whatsThis );
00271
00272 QString currentHolidayName;
00273 QStringList holidayList;
00274 QStringList countryList = KHolidays::locations();
00275 QStringList::ConstIterator it;
00276
00277 for ( it = countryList.begin(); it != countryList.end(); ++it ) {
00278 QString countryFile = locate( "locale",
00279 "l10n/" + (*it) + "/entry.desktop" );
00280 QString regionName;
00281 if ( !countryFile.isEmpty() ) {
00282 KSimpleConfig cfg( countryFile );
00283 cfg.setGroup( "KCM Locale" );
00284 regionName = cfg.readEntry( "Name" );
00285 }
00286 if (regionName.isEmpty()) regionName = (*it);
00287
00288 holidayList << regionName;
00289 mRegionMap[regionName] = (*it);
00290
00291 if ( KOGlobals::self()->holidays()
00292 && ((*it) == KOGlobals::self()->holidays()->location()) )
00293 currentHolidayName = regionName;
00294 }
00295 holidayList.sort();
00296 holidayList.push_front( i18n("(None)") );
00297
00298 mHolidayCombo->insertStringList(holidayList);
00299
00300 for (int i=0; i < mHolidayCombo->count(); ++i) {
00301 if ( mHolidayCombo->text(i) == currentHolidayName ) {
00302 mHolidayCombo->setCurrentItem(i);
00303 break;
00304 }
00305 }
00306
00307 KPrefsWidTime *dayBegins =
00308 addWidTime( KOPrefs::instance()->dayBeginsItem(), topFrame );
00309 topLayout->addWidget( dayBegins->label(), 2, 0 );
00310 topLayout->addWidget( dayBegins->timeEdit(), 2, 1 );
00311
00312 KPrefsWidTime *defaultTime =
00313 addWidTime( KOPrefs::instance()->startTimeItem(), topFrame );
00314 topLayout->addWidget( defaultTime->label(), 3, 0);
00315 topLayout->addWidget( defaultTime->timeEdit(), 3, 1);
00316
00317 KPrefsWidDuration *defaultDuration =
00318 addWidDuration( KOPrefs::instance()->defaultDurationItem(), topFrame );
00319 topLayout->addWidget( defaultDuration->label(), 4, 0 );
00320 topLayout->addWidget( defaultDuration->timeEdit(), 4, 1 );
00321
00322 QGroupBox *remindersGroupBox = new QGroupBox( 1, Horizontal,
00323 i18n( "Reminders" ),
00324 topFrame );
00325 topLayout->addMultiCellWidget( remindersGroupBox, 5, 5, 0, 1 );
00326
00327 QHBox *remindersBox = new QHBox( remindersGroupBox );
00328 new QLabel( i18n( "Default reminder time:" ), remindersBox );
00329
00330 mReminderTimeSpin = new KIntSpinBox( remindersBox );
00331 connect( mReminderTimeSpin, SIGNAL(valueChanged(int)), SLOT(slotWidChanged()) );
00332
00333 mReminderUnitsCombo = new KComboBox( remindersBox );
00334 connect( mReminderUnitsCombo, SIGNAL(activated(int)), SLOT(slotWidChanged()) );
00335 mReminderUnitsCombo->insertItem( i18n( "minute(s)" ) );
00336 mReminderUnitsCombo->insertItem( i18n( "hour(s)" ) );
00337 mReminderUnitsCombo->insertItem( i18n( "day(s)" ) );
00338
00339 QHBox *audioFileRemindersBox = new QHBox( remindersGroupBox );
00340
00341 QCheckBox *cb = addWidBool( KOPrefs::instance()->defaultAudioFileRemindersItem(),
00342 audioFileRemindersBox )->checkBox();
00343 cb->setText( QString::null );
00344
00345 if ( KOPrefs::instance()->audioFilePathItem()->value().isEmpty() ) {
00346 QString defAudioFile = KGlobal::dirs()->findResourceDir( "sound", "KDE-Sys-Warning.ogg");
00347 KOPrefs::instance()->audioFilePathItem()->setValue( defAudioFile + "KDE-Sys-Warning.ogg" );
00348 }
00349 QString filter = i18n( "*.ogg *.wav *.mp3 *.wma *.flac *.aiff *.raw *.au *.ra|"
00350 "Audio Files (*.ogg *.wav *.mp3 *.wma *.flac *.aiff *.raw *.au *.ra)" );
00351 KURLRequester *rq = addWidPath( KOPrefs::instance()->audioFilePathItem(),
00352 audioFileRemindersBox, filter )->urlRequester();
00353 rq->setEnabled( cb->isChecked() );
00354 connect( cb, SIGNAL(toggled(bool)),
00355 rq, SLOT(setEnabled( bool)) );
00356
00357 QHBox *eventRemindersBox = new QHBox( remindersGroupBox );
00358 addWidBool( KOPrefs::instance()->defaultEventRemindersItem(), eventRemindersBox )->checkBox();
00359
00360 QHBox *todoRemindersBox = new QHBox( remindersGroupBox );
00361 addWidBool( KOPrefs::instance()->defaultTodoRemindersItem(), todoRemindersBox )->checkBox();
00362
00363 QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal,
00364 i18n("Working Hours"),
00365 topFrame);
00366 topLayout->addMultiCellWidget( workingHoursGroup, 6, 6, 0, 1 );
00367
00368 QHBox *workDaysBox = new QHBox( workingHoursGroup );
00369
00370 int weekStart=KGlobal::locale()->weekStartDay();
00371 for ( int i = 0; i < 7; ++i ) {
00372 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
00373 QString weekDayName = calSys->weekDayName( (i + weekStart + 6)%7 + 1, true );
00374 if ( KOPrefs::instance()->mCompactDialogs ) {
00375 weekDayName = weekDayName.left( 1 );
00376 }
00377 int index = ( i + weekStart + 6 ) % 7;
00378 mWorkDays[ index ] = new QCheckBox( weekDayName, workDaysBox );
00379 QWhatsThis::add( mWorkDays[ index ],
00380 i18n( "Check this box to make KOrganizer mark the "
00381 "working hours for this day of the week. "
00382 "If this is a work day for you, check "
00383 "this box, or the working hours will not be "
00384 "marked with color." ) );
00385
00386 connect( mWorkDays[ index ], SIGNAL( stateChanged( int ) ),
00387 SLOT( slotWidChanged() ) );
00388 }
00389
00390 QHBox *workStartBox = new QHBox(workingHoursGroup);
00391 addWidTime( KOPrefs::instance()->workingHoursStartItem(), workStartBox );
00392
00393 QHBox *workEndBox = new QHBox(workingHoursGroup);
00394 addWidTime( KOPrefs::instance()->workingHoursEndItem(), workEndBox );
00395
00396
00397 addWidBool( KOPrefs::instance()->excludeHolidaysItem(),
00398 workingHoursGroup );
00399
00400 topLayout->setRowStretch(7,1);
00401
00402 load();
00403 }
00404
00405 protected:
00406 void usrReadConfig()
00407 {
00408 setCombo( mTimeZoneCombo,
00409 i18n( KOPrefs::instance()->mTimeZoneId.utf8() ) );
00410
00411 mReminderTimeSpin->setValue( KOPrefs::instance()->mReminderTime );
00412 mReminderUnitsCombo->setCurrentItem( KOPrefs::instance()->mReminderTimeUnits );
00413
00414 for ( int i = 0; i < 7; ++i ) {
00415 mWorkDays[i]->setChecked( (1<<i) & (KOPrefs::instance()->mWorkWeekMask) );
00416 }
00417 }
00418
00419 void usrWriteConfig()
00420 {
00421
00422 QStringList::Iterator tz;
00423 for ( tz = tzonenames.begin(); tz != tzonenames.end(); ++tz )
00424 if (mTimeZoneCombo->currentText() == i18n((*tz).utf8()))
00425 break;
00426 if (tz != tzonenames.end())
00427 KOPrefs::instance()->mTimeZoneId = (*tz);
00428 else
00429 KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText();
00430
00431 KOPrefs::instance()->mHolidays = ( mHolidayCombo->currentItem() == 0 ) ?
00432 QString::null :
00433 mRegionMap[mHolidayCombo->currentText()];
00434
00435 KOPrefs::instance()->mReminderTime = mReminderTimeSpin->value();
00436 KOPrefs::instance()->mReminderTimeUnits = mReminderUnitsCombo->currentItem();
00437
00438 int mask = 0;
00439 for ( int i = 0; i < 7; ++i ) {
00440 if (mWorkDays[i]->isChecked()) mask = mask | (1<<i);
00441 }
00442 KOPrefs::instance()->mWorkWeekMask = mask;
00443 KOPrefs::instance()->writeConfig();
00444 }
00445
00446 void setCombo( QComboBox *combo, const QString &text,
00447 const QStringList *tags = 0 )
00448 {
00449 if (tags) {
00450 int i = tags->findIndex(text);
00451 if (i > 0) combo->setCurrentItem(i);
00452 } else {
00453 for(int i=0;i<combo->count();++i) {
00454 if (combo->text(i) == text) {
00455 combo->setCurrentItem(i);
00456 break;
00457 }
00458 }
00459 }
00460 }
00461
00462 private:
00463 QComboBox *mTimeZoneCombo;
00464 QStringList tzonenames;
00465 QComboBox *mHolidayCombo;
00466 QMap<QString,QString> mRegionMap;
00467 KIntSpinBox *mReminderTimeSpin;
00468 KComboBox *mReminderUnitsCombo;
00469 QCheckBox *mWorkDays[7];
00470 };
00471
00472 extern "C"
00473 {
00474 KCModule *create_korganizerconfigtime( QWidget *parent, const char * )
00475 {
00476 KGlobal::locale()->insertCatalogue( "timezones" );
00477 return new KOPrefsDialogTime( parent, "kcmkorganizertime" );
00478 }
00479 }
00480
00481
00482 class KOPrefsDialogViews : public KPrefsModule
00483 {
00484 public:
00485 KOPrefsDialogViews( QWidget *parent, const char *name )
00486 : KPrefsModule( KOPrefs::instance(), parent, name )
00487 {
00488 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00489
00490 QWidget *topFrame = new QWidget( this );
00491 topTopLayout->addWidget( topFrame );
00492
00493 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
00494 topLayout->setSpacing( KDialog::spacingHint() );
00495
00496 KPrefsWidBool *enableToolTips =
00497 addWidBool( KOPrefs::instance()->enableToolTipsItem(), topFrame );
00498 topLayout->addWidget( enableToolTips->checkBox() );
00499
00500 KPrefsWidBool *showTodosAgenda =
00501 addWidBool( KOPrefs::instance()->showAllDayTodoItem(), topFrame );
00502 topLayout->addWidget( showTodosAgenda->checkBox() );
00503
00504
00505 QGroupBox *dateNavGroup = new QGroupBox( 1, Horizontal,
00506 i18n("Date Navigator"),
00507 topFrame );
00508 addWidBool( KOPrefs::instance()->dailyRecurItem(), dateNavGroup );
00509 addWidBool( KOPrefs::instance()->weeklyRecurItem(), dateNavGroup );
00510 addWidBool( KOPrefs::instance()->weekNumbersShowWorkItem(), dateNavGroup );
00511 topLayout->addWidget( dateNavGroup );
00512
00513
00514
00515 QGroupBox *agendaGroup = new QGroupBox( 1, Horizontal,
00516 i18n("Agenda View"),
00517 topFrame );
00518
00519 QHBox *hourSizeBox = new QHBox( agendaGroup );
00520 KPrefsWidInt *hourSize =
00521 addWidInt( KOPrefs::instance()->hourSizeItem(), hourSizeBox );
00522 hourSize->spinBox()->setSuffix(i18n("suffix in the hour size spin box", " pixel"));
00523
00524 new QWidget( hourSizeBox );
00525
00526 QHBox *nextDaysBox = new QHBox( agendaGroup );
00527 KPrefsWidInt *nextDays =
00528 addWidInt( KOPrefs::instance()->nextXDaysItem(), nextDaysBox );
00529 nextDays->spinBox()->setSuffix(i18n("suffix in the N days spin box", " days"));
00530 new QWidget( nextDaysBox );
00531
00532 KPrefsWidBool *marcusBainsEnabled =
00533 addWidBool( KOPrefs::instance()->marcusBainsEnabledItem(), agendaGroup );
00534
00535 KPrefsWidBool *marcusBainsShowSeconds =
00536 addWidBool( KOPrefs::instance()->marcusBainsShowSecondsItem(), agendaGroup );
00537 connect( marcusBainsEnabled->checkBox(), SIGNAL( toggled( bool ) ),
00538 marcusBainsShowSeconds->checkBox(), SLOT( setEnabled( bool ) ) );
00539
00540 addWidBool( KOPrefs::instance()->selectionStartsEditorItem(), agendaGroup );
00541
00542 KPrefsWidBool *colorBusyDays =
00543 addWidBool( KOPrefs::instance()->colorBusyDaysEnabledItem(), agendaGroup );
00544
00545 addWidCombo( KOPrefs::instance()->agendaViewColorsItem(), agendaGroup );
00546
00547 addWidCombo( KOPrefs::instance()->agendaViewCalendarDisplayItem(), agendaGroup );
00548
00549 topLayout->addWidget( agendaGroup );
00550
00551
00552 QGroupBox *monthGroup = new QGroupBox( 1, Horizontal,
00553 i18n("Month View"),
00554 topFrame );
00555 addWidBool( KOPrefs::instance()->enableMonthScrollItem(), monthGroup );
00556 addWidBool( KOPrefs::instance()->fullViewMonthItem(), monthGroup );
00557 addWidCombo( KOPrefs::instance()->monthItemColorsItem(), monthGroup );
00558 topLayout->addWidget( monthGroup );
00559
00560
00561
00562 QGroupBox *todoGroup = new QGroupBox( 1, Horizontal,
00563 i18n("To-do View"),
00564 topFrame );
00565 addWidBool( KOPrefs::instance()->fullViewTodoItem(), todoGroup );
00566 addWidBool( KOPrefs::instance()->recordTodosInJournalsItem(), todoGroup );
00567 topLayout->addWidget( todoGroup );
00568
00569 topLayout->addStretch( 1 );
00570
00571 load();
00572 }
00573 };
00574
00575 extern "C"
00576 {
00577 KCModule *create_korganizerconfigviews( QWidget *parent, const char * )
00578 {
00579 return new KOPrefsDialogViews( parent, "kcmkorganizerviews" );
00580 }
00581 }
00582
00583
00584 class KOPrefsDialogFonts : public KPrefsModule
00585 {
00586 public:
00587 KOPrefsDialogFonts( QWidget *parent, const char *name )
00588 : KPrefsModule( KOPrefs::instance(), parent, name )
00589 {
00590 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00591
00592 QWidget *topFrame = new QWidget( this );
00593 topTopLayout->addWidget( topFrame );
00594
00595 QGridLayout *topLayout = new QGridLayout(topFrame,5,3);
00596 topLayout->setSpacing( KDialog::spacingHint() );
00597
00598 KPrefsWidFont *timeBarFont =
00599 addWidFont( KOPrefs::instance()->timeBarFontItem(), topFrame,
00600 KGlobal::locale()->formatTime( QTime( 12, 34 ) ) );
00601 topLayout->addWidget(timeBarFont->label(),0,0);
00602 topLayout->addWidget(timeBarFont->preview(),0,1);
00603 topLayout->addWidget(timeBarFont->button(),0,2);
00604
00605 KPrefsWidFont *monthViewFont =
00606 addWidFont( KOPrefs::instance()->monthViewFontItem(), topFrame,
00607 KGlobal::locale()->formatTime(QTime(12,34)) + " " +
00608 i18n("Event text") );
00609
00610 topLayout->addWidget(monthViewFont->label(),1,0);
00611 topLayout->addWidget(monthViewFont->preview(),1,1);
00612 topLayout->addWidget(monthViewFont->button(),1,2);
00613
00614 KPrefsWidFont *agendaViewFont =
00615 addWidFont( KOPrefs::instance()->agendaViewFontItem(),
00616 topFrame, i18n("Event text") );
00617 topLayout->addWidget(agendaViewFont->label(),2,0);
00618 topLayout->addWidget(agendaViewFont->preview(),2,1);
00619 topLayout->addWidget(agendaViewFont->button(),2,2);
00620
00621 KPrefsWidFont *marcusBainsFont =
00622 addWidFont( KOPrefs::instance()->marcusBainsFontItem(), topFrame,
00623 KGlobal::locale()->formatTime( QTime( 12, 34, 23 ) ) );
00624 topLayout->addWidget(marcusBainsFont->label(),3,0);
00625 topLayout->addWidget(marcusBainsFont->preview(),3,1);
00626 topLayout->addWidget(marcusBainsFont->button(),3,2);
00627
00628 topLayout->setColStretch(1,1);
00629 topLayout->setRowStretch(4,1);
00630
00631 load();
00632 }
00633 };
00634
00635 extern "C"
00636 {
00637 KCModule *create_korganizerconfigfonts( QWidget *parent, const char * )
00638 {
00639 return new KOPrefsDialogFonts( parent, "kcmkorganizerfonts" );
00640 }
00641 }
00642
00643
00644 KOPrefsDialogColors::KOPrefsDialogColors( QWidget *parent, const char *name )
00645 : KPrefsModule( KOPrefs::instance(), parent, name )
00646 {
00647 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00648
00649 QWidget *topFrame = new QWidget( this );
00650 topTopLayout->addWidget( topFrame );
00651
00652 QGridLayout *topLayout = new QGridLayout(topFrame,7,2);
00653 topLayout->setSpacing( KDialog::spacingHint() );
00654
00655
00656 KPrefsWidColor *holidayColor =
00657 addWidColor( KOPrefs::instance()->holidayColorItem(), topFrame );
00658 topLayout->addWidget(holidayColor->label(),0,0);
00659 topLayout->addWidget(holidayColor->button(),0,1);
00660
00661
00662 KPrefsWidColor *highlightColor =
00663 addWidColor( KOPrefs::instance()->highlightColorItem(), topFrame );
00664 topLayout->addWidget(highlightColor->label(),1,0);
00665 topLayout->addWidget(highlightColor->button(),1,1);
00666
00667
00668 KPrefsWidColor *agendaBgColor =
00669 addWidColor( KOPrefs::instance()->agendaBgColorItem(), topFrame );
00670 topLayout->addWidget(agendaBgColor->label(),2,0);
00671 topLayout->addWidget(agendaBgColor->button(),2,1);
00672
00673 KPrefsWidColor *agendaBgBusyColor =
00674 addWidColor( KOPrefs::instance()->agendaBgBusyColorItem(), topFrame );
00675 topLayout->addWidget(agendaBgBusyColor->label(),3,0);
00676 topLayout->addWidget(agendaBgBusyColor->button(),3,1);
00677
00678
00679 KPrefsWidColor *workingHoursColor =
00680 addWidColor( KOPrefs::instance()->workingHoursColorItem(), topFrame );
00681 topLayout->addWidget(workingHoursColor->label(),4,0);
00682 topLayout->addWidget(workingHoursColor->button(),4,1);
00683
00684
00685 KPrefsWidColor *todoDueTodayColor =
00686 addWidColor( KOPrefs::instance()->todoDueTodayColorItem(), topFrame );
00687 topLayout->addWidget(todoDueTodayColor->label(),5,0);
00688 topLayout->addWidget(todoDueTodayColor->button(),5,1);
00689
00690
00691 KPrefsWidColor *todoOverdueColor =
00692 addWidColor( KOPrefs::instance()->todoOverdueColorItem(), topFrame );
00693 topLayout->addWidget(todoOverdueColor->label(),6,0);
00694 topLayout->addWidget(todoOverdueColor->button(),6,1);
00695
00696
00697 KPrefsWidColor *unsetCategoryColor =
00698 addWidColor( KOPrefs::instance()->unsetCategoryColorItem(), topFrame );
00699 topLayout->addWidget( unsetCategoryColor->label(), 7, 0 );
00700 topLayout->addWidget( unsetCategoryColor->button(), 7, 1 );
00701
00702
00703 QGroupBox *categoryGroup = new QGroupBox(1,Horizontal,i18n("Categories"),
00704 topFrame);
00705 topLayout->addMultiCellWidget(categoryGroup,8,8,0,1);
00706
00707
00708 mCategoryCombo = new QComboBox(categoryGroup);
00709 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
00710 QWhatsThis::add( mCategoryCombo,
00711 i18n( "Select here the event category you want to modify. "
00712 "You can change the selected category color using "
00713 "the button below." ) );
00714 connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor()));
00715
00716 mCategoryButton = new KColorButton(categoryGroup);
00717 QWhatsThis::add( mCategoryButton,
00718 i18n( "Choose here the color of the event category selected "
00719 "using the combo box above." ) );
00720 connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor()));
00721 updateCategoryColor();
00722
00723
00724 QGroupBox *resourceGroup = new QGroupBox(1,Horizontal,i18n("Resources"),
00725 topFrame);
00726 topLayout->addMultiCellWidget(resourceGroup,9,9,0,1);
00727
00728 mResourceCombo = new QComboBox(resourceGroup);
00729 QWhatsThis::add( mResourceCombo,
00730 i18n( "Select here resource you want to modify. "
00731 "You can change the selected resource color using "
00732 "the button below." ) );
00733 connect(mResourceCombo,SIGNAL(activated(int)),SLOT(updateResourceColor()));
00734
00735 mResourceButton = new KColorButton(resourceGroup);
00736 QWhatsThis::add( mResourceButton,
00737 i18n( "Choose here the color of the resource selected "
00738 "using the combo box above." ) );
00739 connect(mResourceButton,SIGNAL(changed(const QColor &)),SLOT(setResourceColor()));
00740 updateResources();
00741
00742 topLayout->setRowStretch(9,1);
00743
00744 load();
00745 }
00746
00747 void KOPrefsDialogColors::usrWriteConfig()
00748 {
00749 QDictIterator<QColor> itCat(mCategoryDict);
00750 while (itCat.current()) {
00751 KOPrefs::instance()->setCategoryColor(itCat.currentKey(),*itCat.current());
00752 ++itCat;
00753 }
00754
00755 QDictIterator<QColor> itRes(mResourceDict);
00756 while (itRes.current()) {
00757 KOPrefs::instance()->setResourceColor(itRes.currentKey(),*itRes.current());
00758 ++itRes;
00759 }
00760 }
00761
00762 void KOPrefsDialogColors::usrReadConfig()
00763 {
00764 updateCategories();
00765 updateResources();
00766 }
00767
00768 void KOPrefsDialogColors::updateCategories()
00769 {
00770 mCategoryCombo->clear();
00771 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
00772 updateCategoryColor();
00773 }
00774
00775 void KOPrefsDialogColors::setCategoryColor()
00776 {
00777 mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color()));
00778 slotWidChanged();
00779 }
00780
00781 void KOPrefsDialogColors::updateCategoryColor()
00782 {
00783 QString cat = mCategoryCombo->currentText();
00784 QColor *color = mCategoryDict.find(cat);
00785 if (!color) {
00786 color = KOPrefs::instance()->categoryColor(cat);
00787 }
00788 if (color) {
00789 mCategoryButton->setColor(*color);
00790 }
00791 }
00792
00793 void KOPrefsDialogColors::updateResources()
00794 {
00795 mResourceCombo->clear();
00796 mResourceIdentifier.clear();
00797 kdDebug( 5850) << "KOPrefsDialogColors::updateResources()" << endl;
00798
00799 KCal::CalendarResourceManager *manager = KOrg::StdCalendar::self()->resourceManager();
00800
00801 kdDebug(5850) << "Loading Calendar resources...:" << endl;
00802 KCal::CalendarResourceManager::Iterator it;
00803 for( it = manager->begin(); it != manager->end(); ++it ) {
00804 if ( !(*it)->subresources().isEmpty() ) {
00805 QStringList subresources = (*it)->subresources();
00806 for ( uint i = 0; i < subresources.count(); ++i ) {
00807 QString resource = subresources[ i ];
00808 if ( (*it)->subresourceActive( resource ) ) {
00809 mResourceCombo->insertItem( (*it)->labelForSubresource( resource ) );
00810 mResourceIdentifier.append( resource );
00811 }
00812 }
00813 }
00814
00815 mResourceCombo->insertItem( (*it)->resourceName() );
00816 mResourceIdentifier.append( (*it)->identifier() );
00817 }
00818
00819 updateResourceColor();
00820 }
00821
00822 void KOPrefsDialogColors::setResourceColor()
00823 {
00824 kdDebug( 5850) << "KOPrefsDialogColors::setResorceColor()" << endl;
00825
00826 mResourceDict.replace( mResourceIdentifier[mResourceCombo->currentItem()],
00827 new QColor( mResourceButton->color() ) );
00828 slotWidChanged();
00829 }
00830
00831 void KOPrefsDialogColors::updateResourceColor()
00832 {
00833 kdDebug( 5850 ) << "KOPrefsDialogColors::updateResourceColor()" << endl;
00834 QString res= mResourceIdentifier[mResourceCombo->currentItem()];
00835 QColor *color = mCategoryDict.find(res);
00836 if( !color ) {
00837 color = KOPrefs::instance()->resourceColor( res );
00838 }
00839 if( color ) {
00840 mResourceButton->setColor(*color);
00841 }
00842 }
00843 extern "C"
00844 {
00845 KCModule *create_korganizerconfigcolors( QWidget *parent, const char * )
00846 {
00847 return new KOPrefsDialogColors( parent, "kcmkorganizercolors" );
00848 }
00849 }
00850
00851
00852 KOPrefsDialogGroupScheduling::KOPrefsDialogGroupScheduling( QWidget *parent, const char *name )
00853 : KPrefsModule( KOPrefs::instance(), parent, name )
00854 {
00855 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00856
00857 QWidget *topFrame = new QWidget( this );
00858 topTopLayout->addWidget( topFrame );
00859
00860 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
00861 topLayout->setSpacing( KDialog::spacingHint() );
00862
00863 KPrefsWidBool *useGroupwareBool =
00864 addWidBool( KOPrefs::instance()->useGroupwareCommunicationItem(),
00865 topFrame );
00866 topLayout->addMultiCellWidget(useGroupwareBool->checkBox(),0,0,0,1);
00867
00868
00869
00870
00871 KPrefsWidBool *bcc =
00872 addWidBool( KOPrefs::instance()->bccItem(), topFrame );
00873 topLayout->addMultiCellWidget(bcc->checkBox(),1,1,0,1);
00874
00875 KPrefsWidRadios *mailClientGroup =
00876 addWidRadios( KOPrefs::instance()->mailClientItem(), topFrame );
00877 topLayout->addMultiCellWidget(mailClientGroup->groupBox(),2,2,0,1);
00878
00879
00880 #if 0
00881 KPrefsWidRadios *schedulerGroup =
00882 addWidRadios(i18n("Scheduler Mail Client"),KOPrefs::instance()->mIMIPScheduler,
00883 topFrame);
00884 schedulerGroup->addRadio("Dummy");
00885 schedulerGroup->addRadio(i18n("Mail client"));
00886
00887 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1);
00888 #endif
00889
00890 QLabel *aMailsLabel = new QLabel(i18n("Additional email addresses:"),topFrame);
00891 QString whatsThis = i18n( "Add, edit or remove additional e-mails addresses "
00892 "here. These email addresses are the ones you "
00893 "have in addition to the one set in personal "
00894 "preferences. If you are an attendee of one event, "
00895 "but use another email address there, you need to "
00896 "list this address here so KOrganizer can "
00897 "recognize it as yours." );
00898 QWhatsThis::add( aMailsLabel, whatsThis );
00899 topLayout->addMultiCellWidget(aMailsLabel,3,3,0,1);
00900 mAMails = new QListView(topFrame);
00901 QWhatsThis::add( mAMails, whatsThis );
00902
00903 mAMails->addColumn(i18n("Email"),300);
00904 topLayout->addMultiCellWidget(mAMails,4,4,0,1);
00905
00906 QLabel *aEmailsEditLabel = new QLabel(i18n("Additional email address:"),topFrame);
00907 whatsThis = i18n( "Edit additional e-mails addresses here. To edit an "
00908 "address select it from the list above "
00909 "or press the \"New\" button below. These email "
00910 "addresses are the ones you have in addition to the "
00911 "one set in personal preferences." );
00912 QWhatsThis::add( aEmailsEditLabel, whatsThis );
00913 topLayout->addWidget(aEmailsEditLabel,5,0);
00914 aEmailsEdit = new QLineEdit(topFrame);
00915 QWhatsThis::add( aEmailsEdit, whatsThis );
00916 aEmailsEdit->setEnabled(false);
00917 topLayout->addWidget(aEmailsEdit,5,1);
00918
00919 QPushButton *add = new QPushButton(i18n("New"),topFrame,"new");
00920 whatsThis = i18n( "Press this button to add a new entry to the "
00921 "additional e-mail addresses list. Use the edit "
00922 "box above to edit the new entry." );
00923 QWhatsThis::add( add, whatsThis );
00924 topLayout->addWidget(add,6,0);
00925 QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove");
00926 QWhatsThis::add( del, whatsThis );
00927 topLayout->addWidget(del,6,1);
00928
00929
00930 connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) );
00931 connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) );
00932 connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem()));
00933 connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput()));
00934
00935 load();
00936 }
00937
00938 void KOPrefsDialogGroupScheduling::usrReadConfig()
00939 {
00940 mAMails->clear();
00941 for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin();
00942 it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) {
00943 QListViewItem *item = new QListViewItem(mAMails);
00944 item->setText(0,*it);
00945 mAMails->insertItem(item);
00946 }
00947 }
00948
00949 void KOPrefsDialogGroupScheduling::usrWriteConfig()
00950 {
00951 KOPrefs::instance()->mAdditionalMails.clear();
00952 QListViewItem *item;
00953 item = mAMails->firstChild();
00954 while (item)
00955 {
00956 KOPrefs::instance()->mAdditionalMails.append( item->text(0) );
00957 item = item->nextSibling();
00958 }
00959 }
00960
00961 void KOPrefsDialogGroupScheduling::addItem()
00962 {
00963 aEmailsEdit->setEnabled(true);
00964 QListViewItem *item = new QListViewItem(mAMails);
00965 mAMails->insertItem(item);
00966 mAMails->setSelected(item,true);
00967 aEmailsEdit->setText(i18n("(EmptyEmail)"));
00968 slotWidChanged();
00969 }
00970
00971 void KOPrefsDialogGroupScheduling::removeItem()
00972 {
00973 QListViewItem *item;
00974 item = mAMails->selectedItem();
00975 if (!item) return;
00976 mAMails->takeItem(item);
00977 item = mAMails->selectedItem();
00978 if (!item) {
00979 aEmailsEdit->setText("");
00980 aEmailsEdit->setEnabled(false);
00981 }
00982 if (mAMails->childCount() == 0) {
00983 aEmailsEdit->setEnabled(false);
00984 }
00985 slotWidChanged();
00986 }
00987
00988 void KOPrefsDialogGroupScheduling::updateItem()
00989 {
00990 QListViewItem *item;
00991 item = mAMails->selectedItem();
00992 if (!item) return;
00993 item->setText(0,aEmailsEdit->text());
00994 slotWidChanged();
00995 }
00996
00997 void KOPrefsDialogGroupScheduling::updateInput()
00998 {
00999 QListViewItem *item;
01000 item = mAMails->selectedItem();
01001 if (!item) return;
01002 aEmailsEdit->setEnabled(true);
01003 aEmailsEdit->setText(item->text(0));
01004 }
01005
01006 extern "C"
01007 {
01008 KCModule *create_korganizerconfiggroupscheduling( QWidget *parent,
01009 const char * )
01010 {
01011 return new KOPrefsDialogGroupScheduling( parent,
01012 "kcmkorganizergroupscheduling" );
01013 }
01014 }
01015
01016
01017 KOPrefsDialogGroupwareScheduling::KOPrefsDialogGroupwareScheduling( QWidget *parent, const char *name )
01018 : KPrefsModule( KOPrefs::instance(), parent, name )
01019 {
01020 mGroupwarePage = new KOGroupwarePrefsPage( this );
01021 connect( mGroupwarePage, SIGNAL( changed() ), SLOT( slotWidChanged() ) );
01022 ( new QVBoxLayout( this ) )->addWidget( mGroupwarePage );
01023
01024 load();
01025 }
01026
01027 void KOPrefsDialogGroupwareScheduling::usrReadConfig()
01028 {
01029 mGroupwarePage->publishEnable->setChecked( KOPrefs::instance()->mFreeBusyPublishAuto );
01030 mGroupwarePage->publishDelay->setValue( KOPrefs::instance()->mFreeBusyPublishDelay );
01031 mGroupwarePage->publishDays->setValue( KOPrefs::instance()->mFreeBusyPublishDays );
01032
01033 mGroupwarePage->publishUrl->setText( KOPrefs::instance()->mFreeBusyPublishUrl );
01034 mGroupwarePage->publishUser->setText( KOPrefs::instance()->mFreeBusyPublishUser );
01035 mGroupwarePage->publishPassword->setText( KOPrefs::instance()->mFreeBusyPublishPassword );
01036 mGroupwarePage->publishSavePassword->setChecked( KOPrefs::instance()->mFreeBusyPublishSavePassword );
01037
01038 mGroupwarePage->retrieveEnable->setChecked( KOPrefs::instance()->mFreeBusyRetrieveAuto );
01039 mGroupwarePage->fullDomainRetrieval->setChecked( KOPrefs::instance()->mFreeBusyFullDomainRetrieval );
01040 mGroupwarePage->retrieveUrl->setText( KOPrefs::instance()->mFreeBusyRetrieveUrl );
01041 mGroupwarePage->retrieveUser->setText( KOPrefs::instance()->mFreeBusyRetrieveUser );
01042 mGroupwarePage->retrievePassword->setText( KOPrefs::instance()->mFreeBusyRetrievePassword );
01043 mGroupwarePage->retrieveSavePassword->setChecked( KOPrefs::instance()->mFreeBusyRetrieveSavePassword );
01044 }
01045
01046 void KOPrefsDialogGroupwareScheduling::usrWriteConfig()
01047 {
01048 KOPrefs::instance()->mFreeBusyPublishAuto = mGroupwarePage->publishEnable->isChecked();
01049 KOPrefs::instance()->mFreeBusyPublishDelay = mGroupwarePage->publishDelay->value();
01050 KOPrefs::instance()->mFreeBusyPublishDays = mGroupwarePage->publishDays->value();
01051
01052 KOPrefs::instance()->mFreeBusyPublishUrl = mGroupwarePage->publishUrl->text();
01053 KOPrefs::instance()->mFreeBusyPublishUser = mGroupwarePage->publishUser->text();
01054 KOPrefs::instance()->mFreeBusyPublishPassword = mGroupwarePage->publishPassword->text();
01055 KOPrefs::instance()->mFreeBusyPublishSavePassword = mGroupwarePage->publishSavePassword->isChecked();
01056
01057 KOPrefs::instance()->mFreeBusyRetrieveAuto = mGroupwarePage->retrieveEnable->isChecked();
01058 KOPrefs::instance()->mFreeBusyFullDomainRetrieval = mGroupwarePage->fullDomainRetrieval->isChecked();
01059 KOPrefs::instance()->mFreeBusyRetrieveUrl = mGroupwarePage->retrieveUrl->text();
01060 KOPrefs::instance()->mFreeBusyRetrieveUser = mGroupwarePage->retrieveUser->text();
01061 KOPrefs::instance()->mFreeBusyRetrievePassword = mGroupwarePage->retrievePassword->text();
01062 KOPrefs::instance()->mFreeBusyRetrieveSavePassword = mGroupwarePage->retrieveSavePassword->isChecked();
01063
01064
01065 QString configFile = locateLocal( "data", "korganizer/freebusyurls" );
01066 KConfig cfg( configFile );
01067 cfg.deleteGroup( KOPrefs::instance()->email() );
01068 }
01069
01070 extern "C"
01071 {
01072 KCModule *create_korganizerconfigfreebusy( QWidget *parent, const char * )
01073 {
01074 return new KOPrefsDialogGroupwareScheduling( parent,
01075 "kcmkorganizerfreebusy" );
01076 }
01077 }
01078
01079
01080
01081 class PluginItem : public QCheckListItem {
01082 public:
01083 PluginItem( QListView *parent, KService::Ptr service ) :
01084 QCheckListItem( parent, service->name(), QCheckListItem::CheckBox ), mService( service )
01085 {}
01086 KService::Ptr service() { return mService; }
01087 private:
01088 KService::Ptr mService;
01089 };
01090
01091
01095 KOPrefsDialogPlugins::KOPrefsDialogPlugins( QWidget *parent, const char* name )
01096 : KPrefsModule( KOPrefs::instance(), parent, name )
01097 {
01098 QBoxLayout *topTopLayout = new QVBoxLayout( this );
01099
01100 QWidget *topFrame = new QWidget( this );
01101 topTopLayout->addWidget( topFrame );
01102 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
01103 topLayout->setSpacing( KDialog::spacingHint() );
01104
01105 mListView = new QListView( topFrame );
01106 mListView->addColumn( i18n("Name") );
01107 mListView->setResizeMode( QListView::LastColumn );
01108 topLayout->addWidget( mListView );
01109
01110 mDescription = new QLabel( topFrame );
01111 mDescription->setAlignment( QLabel::NoAccel | QLabel::WordBreak | QLabel::AlignVCenter );
01112 mDescription->setFrameShape( QLabel::Panel );
01113 mDescription->setFrameShadow( QLabel::Sunken );
01114 mDescription->setMinimumSize( QSize( 0, 55 ) );
01115 mDescription->setSizePolicy(
01116 QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0,
01117 0, 0, mDescription->sizePolicy().hasHeightForWidth() ) );
01118 topLayout->addWidget( mDescription );
01119
01120
01121 QWidget *buttonRow = new QWidget( topFrame );
01122 QBoxLayout *buttonRowLayout = new QHBoxLayout( buttonRow );
01123 mConfigureButton = new KPushButton( KGuiItem( i18n("Configure &Plugin..."),
01124 "configure", QString::null, i18n("This button allows you to configure"
01125 " the plugin that you have selected in the list above") ), buttonRow );
01126
01127 buttonRowLayout->addWidget( mConfigureButton );
01128 buttonRowLayout->addItem( new QSpacerItem(1, 1, QSizePolicy::Expanding) );
01129 topLayout->addWidget( buttonRow );
01130 connect( mConfigureButton, SIGNAL( clicked() ), SLOT( configure() ) );
01131
01132 connect( mListView, SIGNAL( selectionChanged( QListViewItem* ) ),
01133 SLOT( selectionChanged( QListViewItem* ) ) );
01134 connect( mListView, SIGNAL( clicked( QListViewItem* ) ),
01135 SLOT( slotWidChanged() ) );
01136
01137 load();
01138
01139 selectionChanged( 0 );
01140 }
01141
01142 void KOPrefsDialogPlugins::usrReadConfig()
01143 {
01144 mListView->clear();
01145 KTrader::OfferList plugins = KOCore::self()->availablePlugins();
01146 plugins += KOCore::self()->availableParts();
01147
01148 QStringList selectedPlugins = KOPrefs::instance()->mSelectedPlugins;
01149
01150 KTrader::OfferList::ConstIterator it;
01151 for( it = plugins.begin(); it != plugins.end(); ++it ) {
01152 QCheckListItem *item = new PluginItem( mListView, *it );
01153 if ( selectedPlugins.find( (*it)->desktopEntryName() ) !=
01154 selectedPlugins.end() ) {
01155 item->setOn( true );
01156 }
01157 }
01158 }
01159
01160 void KOPrefsDialogPlugins::usrWriteConfig()
01161 {
01162 QStringList selectedPlugins;
01163
01164 PluginItem *item = static_cast<PluginItem *>( mListView->firstChild() );
01165 while( item ) {
01166 if( item->isOn() ) {
01167 selectedPlugins.append( item->service()->desktopEntryName() );
01168 }
01169 item = static_cast<PluginItem *>( item->nextSibling() );
01170 }
01171 KOPrefs::instance()->mSelectedPlugins = selectedPlugins;
01172 }
01173
01174 void KOPrefsDialogPlugins::configure()
01175 {
01176 PluginItem *item = static_cast<PluginItem *>( mListView->selectedItem() );
01177 if ( !item ) return;
01178
01179 KOrg::Plugin *plugin = KOCore::self()->loadPlugin( item->service() );
01180
01181 if ( plugin ) {
01182 plugin->configure( this );
01183 delete plugin;
01184 } else {
01185 KMessageBox::sorry( this, i18n( "Unable to configure this plugin" ),
01186 "PluginConfigUnable" );
01187 }
01188 }
01189
01190 void KOPrefsDialogPlugins::selectionChanged( QListViewItem *i )
01191 {
01192 PluginItem *item = dynamic_cast<PluginItem*>( i );
01193 if ( !item ) {
01194 mConfigureButton->setEnabled( false );
01195 mDescription->setText( QString::null );
01196 return;
01197 }
01198
01199 QVariant variant = item->service()->property( "X-KDE-KOrganizer-HasSettings" );
01200
01201 bool hasSettings = true;
01202 if ( variant.isValid() )
01203 hasSettings = variant.toBool();
01204
01205 mDescription->setText( item->service()->comment() );
01206 mConfigureButton->setEnabled( hasSettings );
01207
01208 slotWidChanged();
01209 }
01210
01211 extern "C"
01212 {
01213 KCModule *create_korganizerconfigplugins( QWidget *parent, const char * )
01214 {
01215 return new KOPrefsDialogPlugins( parent,
01216 "kcmkorganizerplugins" );
01217 }
01218 }
01219
01220
01221 extern "C"
01222 {
01223 KCModule *create_korgdesignerfields( QWidget *parent, const char * ) {
01224 return new KOPrefsDesignerFields( parent, "kcmkorgdesignerfields" );
01225 }
01226 }
01227
01228 KOPrefsDesignerFields::KOPrefsDesignerFields( QWidget *parent, const char *name )
01229 : KCMDesignerFields( parent, name )
01230 {
01231 }
01232
01233 QString KOPrefsDesignerFields::localUiDir()
01234 {
01235 QString dir = locateLocal( "data", "korganizer/designer/event/");
01236 kdDebug() << "KOPrefsDesignerFields::localUiDir(): " << dir << endl;
01237 return dir;
01238 }
01239
01240 QString KOPrefsDesignerFields::uiPath()
01241 {
01242 return "korganizer/designer/event/";
01243 }
01244
01245 void KOPrefsDesignerFields::writeActivePages( const QStringList &activePages )
01246 {
01247 KOPrefs::instance()->setActiveDesignerFields( activePages );
01248 KOPrefs::instance()->writeConfig();
01249 }
01250
01251 QStringList KOPrefsDesignerFields::readActivePages()
01252 {
01253 return KOPrefs::instance()->activeDesignerFields();
01254 }
01255
01256 QString KOPrefsDesignerFields::applicationName()
01257 {
01258 return "KORGANIZER";
01259 }
01260
01261 #include "koprefsdialog.moc"