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 #include <qlayout.h>
00026 #include <qlabel.h>
00027 #include <qgroupbox.h>
00028 #include <qbuttongroup.h>
00029 #include <qlineedit.h>
00030 #include <qslider.h>
00031 #include <qfile.h>
00032 #include <qcombobox.h>
00033 #include <qhbox.h>
00034 #include <qspinbox.h>
00035 #include <qcheckbox.h>
00036 #include <qradiobutton.h>
00037 #include <qpushbutton.h>
00038 #include <qstrlist.h>
00039 #include <qlistview.h>
00040 #include <qtabwidget.h>
00041
00042 #include <kcolorbutton.h>
00043 #include <kdebug.h>
00044 #include <klocale.h>
00045 #include <kglobal.h>
00046 #include <kmessagebox.h>
00047 #include <kiconloader.h>
00048 #include <kemailsettings.h>
00049 #include <kcalendarsystem.h>
00050
00051 #if defined(USE_SOLARIS)
00052 #include <sys/param.h>
00053
00054 #define ZONEINFODIR "/usr/share/lib/zoneinfo"
00055 #define INITFILE "/etc/default/init"
00056 #endif
00057
00058 #include "koprefs.h"
00059
00060 #include "koprefsdialog.h"
00061 #include "kogroupwareprefspage.h"
00062 #include "ktimeedit.h"
00063 #include "koglobals.h"
00064
00065
00066 KOPrefsDialogMain::KOPrefsDialogMain( QWidget *parent, const char *name )
00067 : KPrefsModule( KOPrefs::instance(), parent, name )
00068 {
00069 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00070
00071 QWidget *topFrame = new QWidget( this );
00072 topTopLayout->addWidget( topFrame );
00073
00074 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
00075 topLayout->setSpacing( KDialog::spacingHint() );
00076
00077 KPrefsWidBool *emailControlCenter =
00078 addWidBool( KOPrefs::instance()->emailControlCenterItem(), topFrame );
00079 topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1);
00080 connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)),
00081 SLOT(toggleEmailSettings(bool)));
00082
00083 mNameEdit = new QLineEdit(topFrame);
00084 connect( mNameEdit, SIGNAL( textChanged( const QString & ) ),
00085 SLOT( slotWidChanged() ) );
00086 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame);
00087 topLayout->addWidget(mNameLabel,1,0);
00088 topLayout->addWidget(mNameEdit,1,1);
00089
00090 mEmailEdit = new QLineEdit(topFrame);
00091 connect( mEmailEdit, SIGNAL( textChanged( const QString & ) ),
00092 SLOT( slotWidChanged() ) );
00093 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame);
00094 topLayout->addWidget(mEmailLabel,2,0);
00095 topLayout->addWidget(mEmailEdit,2,1);
00096
00097 KPrefsWidBool *bcc =
00098 addWidBool( KOPrefs::instance()->bccItem(), topFrame );
00099 topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1);
00100
00101
00102 QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"),
00103 topFrame);
00104 topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1);
00105
00106 addWidBool( KOPrefs::instance()->autoSaveItem(), autoSaveGroup );
00107
00108 QHBox *intervalBox = new QHBox(autoSaveGroup);
00109 intervalBox->setSpacing( KDialog::spacingHint() );
00110
00111 QLabel *autoSaveIntervalLabel = new QLabel(i18n("Save &interval in minutes:"),intervalBox);
00112 mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox);
00113 connect( mAutoSaveIntervalSpin, SIGNAL( valueChanged( int ) ),
00114 SLOT( slotWidChanged() ) );
00115 autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin);
00116
00117 KPrefsWidBool *confirmCheck =
00118 addWidBool( KOPrefs::instance()->confirmItem(), topFrame );
00119 topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1);
00120
00121 KPrefsWidRadios *mailClientGroup =
00122 addWidRadios( KOPrefs::instance()->mailClientItem(), topFrame );
00123 topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1);
00124
00125 KPrefsWidBool *useGroupwareBool =
00126 addWidBool( KOPrefs::instance()->useGroupwareCommunicationItem(),
00127 topFrame );
00128 topLayout->addMultiCellWidget(useGroupwareBool->checkBox(),12,12,0,1);
00129
00130
00131
00132
00133 KPrefsWidBool *htmlsave =
00134 addWidBool( KOPrefs::instance()->htmlWithSaveItem(),
00135 topFrame );
00136 topLayout->addMultiCellWidget(htmlsave->checkBox(),13,13,0,1);
00137
00138 KPrefsWidRadios *destinationGroup =
00139 addWidRadios( KOPrefs::instance()->destinationItem(),
00140 topFrame);
00141 topLayout->addMultiCellWidget(destinationGroup->groupBox(),14,14,0,1);
00142
00143 topLayout->setRowStretch(15,1);
00144
00145 load();
00146 }
00147
00148 void KOPrefsDialogMain::usrReadConfig()
00149 {
00150 mNameEdit->setText(KOPrefs::instance()->fullName());
00151 mEmailEdit->setText(KOPrefs::instance()->email());
00152
00153 mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval);
00154 }
00155
00156 void KOPrefsDialogMain::usrWriteConfig()
00157 {
00158 KOPrefs::instance()->setFullName(mNameEdit->text());
00159 KOPrefs::instance()->setEmail(mEmailEdit->text());
00160
00161 KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value();
00162 }
00163
00164 void KOPrefsDialogMain::toggleEmailSettings( bool on )
00165 {
00166 if (on) {
00167 mEmailEdit->setEnabled(false);
00168 mNameEdit->setEnabled(false);
00169 mEmailLabel->setEnabled(false);
00170 mNameLabel->setEnabled(false);
00171
00172 KEMailSettings settings;
00173 mNameEdit->setText(settings.getSetting(KEMailSettings::RealName));
00174 mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress));
00175 } else {
00176 mEmailEdit->setEnabled(true);
00177 mNameEdit->setEnabled(true);
00178 mEmailLabel->setEnabled(true);
00179 mNameLabel->setEnabled(true);
00180
00181 mNameEdit->setText( KOPrefs::instance()->mName );
00182 mEmailEdit->setText( KOPrefs::instance()->mEmail );
00183 }
00184 }
00185
00186 extern "C"
00187 {
00188 KCModule *create_korganizerconfigmain( QWidget *parent, const char * )
00189 {
00190 return new KOPrefsDialogMain( parent, "kcmkorganizermain" );
00191 }
00192 }
00193
00194
00195 class KOPrefsDialogTime : public KPrefsModule
00196 {
00197 public:
00198 KOPrefsDialogTime( QWidget *parent, const char *name )
00199 : KPrefsModule( KOPrefs::instance(), parent, name )
00200 {
00201 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00202
00203 QWidget *topFrame = new QWidget( this );
00204 topTopLayout->addWidget( topFrame );
00205
00206 QGridLayout *topLayout = new QGridLayout(topFrame,5,2);
00207 topLayout->setSpacing( KDialog::spacingHint() );
00208
00209 QHBox *timeZoneBox = new QHBox( topFrame );
00210 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
00211
00212 new QLabel( i18n("Timezone:"), timeZoneBox );
00213 mTimeZoneCombo = new QComboBox( timeZoneBox );
00214 connect( mTimeZoneCombo, SIGNAL( activated( int ) ),
00215 SLOT( slotWidChanged() ) );
00216
00217 FILE *f;
00218 char tempstring[101] = "Unknown";
00219 QString sCurrentlySet(i18n("Unknown"));
00220 int nCurrentlySet = 0;
00221 QStringList list;
00222
00223
00224 #if defined(USE_SOLARIS) // MARCO
00225 char buf[MAXPATHLEN];
00226
00227 snprintf(buf, MAXPATHLEN,
00228 "/bin/fgrep 'TZ=' %s | /bin/head -n 1 | /bin/cut -b 4-",
00229 INITFILE);
00230
00231 if (f = popen(buf, "r"))
00232 {
00233 if (fgets(buf, MAXPATHLEN - 1, f) != NULL)
00234 {
00235 buf[strlen(buf) - 1] = '\0';
00236 sCurrentlySet = QString(buf);
00237 }
00238 pclose(f);
00239 }
00240 #else
00241 if((f = fopen("/etc/timezone", "r")) != NULL) {
00242
00243 fgets(tempstring, 100, f);
00244 tempstring[strlen(tempstring) - 1] = '\0';
00245 sCurrentlySet = QString(tempstring);
00246 fclose(f);
00247 }
00248 #endif // !USE_SOLARIS
00249
00250 mTimeZoneCombo->insertItem(i18n("[No selection]"));
00251
00252
00253 #if defined(USE_SOLARIS) // MARCO
00254 snprintf(buf, MAXPATHLEN,
00255 "/bin/find %s \\( -name src -prune \\) -o -type f -print | /bin/cut -b %d-",
00256 ZONEINFODIR, strlen(ZONEINFODIR) + 2);
00257
00258 if (f = popen(buf, "r"))
00259 {
00260 while(fgets(buf, MAXPATHLEN - 1, f) != NULL)
00261 {
00262 buf[strlen(buf) - 1] = '\0';
00263 list.append(buf);
00264 }
00265 pclose(f);
00266 }
00267
00268 #else
00269 f = popen("grep -e ^[^#] /usr/share/zoneinfo/zone.tab | cut -f 3","r");
00270 if (!f) return;
00271 while(fgets(tempstring, 100, f) != NULL) {
00272 tempstring[strlen(tempstring)-1] = '\0';
00273 list.append(i18n(tempstring));
00274 tzonenames << tempstring;
00275 }
00276 pclose(f);
00277 #endif // !USE_SOLARIS
00278 list.sort();
00279
00280 mTimeZoneCombo->insertStringList(list);
00281
00282
00283 for (int i = 0; i < mTimeZoneCombo->count(); i++)
00284 {
00285 if (mTimeZoneCombo->text(i) == sCurrentlySet)
00286 {
00287 nCurrentlySet = i;
00288 break;
00289 }
00290 }
00291
00292 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
00293
00294 KPrefsWidTime *dayBegins =
00295 addWidTime( KOPrefs::instance()->dayBeginsItem(), topFrame );
00296 topLayout->addWidget( dayBegins->label(), 1, 0 );
00297 topLayout->addWidget(dayBegins->timeEdit(), 1, 1 );
00298
00299 KPrefsWidTime *defaultTime =
00300 addWidTime( KOPrefs::instance()->startTimeItem(), topFrame );
00301 topLayout->addWidget( defaultTime->label(), 2, 0);
00302 topLayout->addWidget( defaultTime->timeEdit(), 2, 1);
00303
00304 KPrefsWidTime *defaultDuration =
00305 addWidTime( KOPrefs::instance()->defaultDurationItem(), topFrame );
00306 topLayout->addWidget( defaultDuration->label(), 3, 0);
00307 topLayout->addWidget( defaultDuration->timeEdit(), 3, 1);
00308
00309 QStringList alarmList;
00310 alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes")
00311 << i18n("15 minutes") << i18n("30 minutes");
00312 topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame),
00313 4,0);
00314 mAlarmTimeCombo = new QComboBox(topFrame);
00315 connect( mAlarmTimeCombo, SIGNAL( activated( int ) ),
00316 SLOT( slotWidChanged() ) );
00317 mAlarmTimeCombo->insertStringList(alarmList);
00318 topLayout->addWidget(mAlarmTimeCombo,4,1);
00319
00320
00321 QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal,
00322 i18n("Working Hours"),
00323 topFrame);
00324 topLayout->addMultiCellWidget(workingHoursGroup,5,5,0,1);
00325
00326 QHBox *workDaysBox = new QHBox( workingHoursGroup );
00327
00328 int weekStart=KGlobal::locale()->weekStartDay();
00329 for ( int i = 0; i < 7; ++i ) {
00330 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
00331 QString weekDayName = calSys->weekDayName( (i + weekStart + 6)%7 + 1, true );
00332 if ( KOPrefs::instance()->mCompactDialogs ) {
00333 weekDayName = weekDayName.left( 1 );
00334 }
00335 mWorkDays[ (i + weekStart + 6)%7 ] = new QCheckBox( weekDayName, workDaysBox );
00336 }
00337 for ( int i = 0; i < 7; ++i ) {
00338 connect( mWorkDays[i], SIGNAL( stateChanged( int ) ),
00339 SLOT( slotWidChanged() ) );
00340 }
00341
00342 QHBox *workStartBox = new QHBox(workingHoursGroup);
00343 addWidTime( KOPrefs::instance()->workingHoursStartItem(), workStartBox );
00344
00345 QHBox *workEndBox = new QHBox(workingHoursGroup);
00346 addWidTime( KOPrefs::instance()->workingHoursEndItem(), workEndBox );
00347
00348
00349 addWidBool( KOPrefs::instance()->excludeHolidaysItem(),
00350 workingHoursGroup );
00351
00352 topLayout->setRowStretch(7,1);
00353
00354 load();
00355 }
00356
00357 protected:
00358 void usrReadConfig()
00359 {
00360 setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId.utf8()));
00361
00362 mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime);
00363 for ( int i = 0; i < 7; ++i ) {
00364 mWorkDays[i]->setChecked( (1<<i) & (KOPrefs::instance()->mWorkWeekMask) );
00365 }
00366 }
00367
00368 void usrWriteConfig()
00369 {
00370
00371 QStringList::Iterator tz;
00372 for (tz = tzonenames.begin(); tz != tzonenames.end(); tz++)
00373 if (mTimeZoneCombo->currentText() == i18n((*tz).utf8()))
00374 break;
00375 if (tz != tzonenames.end())
00376 KOPrefs::instance()->mTimeZoneId = (*tz);
00377 else
00378 KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText();
00379
00380 KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem();
00381 int mask = 0;
00382 for ( int i = 0; i < 7; ++i ) {
00383 if (mWorkDays[i]->isChecked()) mask = mask | (1<<i);
00384 }
00385 KOPrefs::instance()->mWorkWeekMask = mask;
00386 KOPrefs::instance()->writeConfig();
00387 }
00388
00389 void setCombo( QComboBox *combo, const QString &text,
00390 const QStringList *tags = 0 )
00391 {
00392 if (tags) {
00393 int i = tags->findIndex(text);
00394 if (i > 0) combo->setCurrentItem(i);
00395 } else {
00396 for(int i=0;i<combo->count();++i) {
00397 if (combo->text(i) == text) {
00398 combo->setCurrentItem(i);
00399 break;
00400 }
00401 }
00402 }
00403 }
00404
00405 private:
00406 QComboBox *mTimeZoneCombo;
00407 QStringList tzonenames;
00408 QComboBox *mAlarmTimeCombo;
00409 QCheckBox *mWorkDays[7];
00410 };
00411
00412 extern "C"
00413 {
00414 KCModule *create_korganizerconfigtime( QWidget *parent, const char * )
00415 {
00416 KGlobal::locale()->insertCatalogue( "timezones" );
00417 return new KOPrefsDialogTime( parent, "kcmkorganizertime" );
00418 }
00419 }
00420
00421
00422 class KOPrefsDialogViews : public KPrefsModule
00423 {
00424 public:
00425 KOPrefsDialogViews( QWidget *parent, const char *name )
00426 : KPrefsModule( KOPrefs::instance(), parent, name )
00427 {
00428 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00429
00430 QWidget *topFrame = new QWidget( this );
00431 topTopLayout->addWidget( topFrame );
00432
00433 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
00434 topLayout->setSpacing( KDialog::spacingHint() );
00435
00436 KPrefsWidBool *enableToolTips =
00437 addWidBool( KOPrefs::instance()->enableToolTipsItem(), topFrame );
00438 topLayout->addWidget( enableToolTips->checkBox() );
00439
00440 KPrefsWidBool *showTodosAgenda =
00441 addWidBool( KOPrefs::instance()->showAllDayTodoItem(), topFrame );
00442 topLayout->addWidget( showTodosAgenda->checkBox() );
00443
00444
00445 QGroupBox *dateNavGroup = new QGroupBox( 1, Horizontal,
00446 i18n("Date Navigator"),
00447 topFrame );
00448 addWidBool( KOPrefs::instance()->dailyRecurItem(), dateNavGroup );
00449 addWidBool( KOPrefs::instance()->weeklyRecurItem(), dateNavGroup );
00450 topLayout->addWidget( dateNavGroup );
00451
00452
00453
00454 QGroupBox *agendaGroup = new QGroupBox( 1, Horizontal,
00455 i18n("Agenda View"),
00456 topFrame );
00457
00458 QHBox *hourSizeBox = new QHBox( agendaGroup );
00459 KPrefsWidInt *hourSize =
00460 addWidInt( KOPrefs::instance()->hourSizeItem(), hourSizeBox );
00461 hourSize->spinBox()->setSuffix(i18n("suffix in the hour size spin box", " pixel"));
00462 new QWidget( hourSizeBox );
00463
00464 QHBox *nextDaysBox = new QHBox( agendaGroup );
00465 KPrefsWidInt *nextDays =
00466 addWidInt( KOPrefs::instance()->nextXDaysItem(), nextDaysBox );
00467 nextDays->spinBox()->setSuffix(i18n("suffix in the N days spin box", " days"));
00468 new QWidget( nextDaysBox );
00469
00470 KPrefsWidBool *marcusBainsEnabled =
00471 addWidBool( KOPrefs::instance()->marcusBainsEnabledItem(), agendaGroup );
00472
00473 KPrefsWidBool *marcusBainsShowSeconds =
00474 addWidBool( KOPrefs::instance()->marcusBainsShowSecondsItem(), agendaGroup );
00475 connect( marcusBainsEnabled->checkBox(), SIGNAL( toggled( bool ) ),
00476 marcusBainsShowSeconds->checkBox(), SLOT( setEnabled( bool ) ) );
00477
00478 addWidBool( KOPrefs::instance()->selectionStartsEditorItem(), agendaGroup );
00479
00480 topLayout->addWidget( agendaGroup );
00481
00482
00483
00484 QGroupBox *monthGroup = new QGroupBox( 1, Horizontal,
00485 i18n("Month View"),
00486 topFrame );
00487 addWidBool( KOPrefs::instance()->enableMonthScrollItem(), monthGroup );
00488 addWidBool( KOPrefs::instance()->fullViewMonthItem(), monthGroup );
00489 addWidBool( KOPrefs::instance()->monthViewUsesCategoryColorItem(),
00490 monthGroup );
00491 topLayout->addWidget( monthGroup );
00492
00493
00494
00495 QGroupBox *todoGroup = new QGroupBox( 1, Horizontal,
00496 i18n("Todo View"),
00497 topFrame );
00498 addWidBool( KOPrefs::instance()->fullViewTodoItem(), todoGroup );
00499 topLayout->addWidget( todoGroup );
00500
00501 topLayout->addStretch( 1 );
00502
00503 load();
00504 }
00505 };
00506
00507 extern "C"
00508 {
00509 KCModule *create_korganizerconfigviews( QWidget *parent, const char * )
00510 {
00511 return new KOPrefsDialogViews( parent, "kcmkorganizerviews" );
00512 }
00513 }
00514
00515
00516 class KOPrefsDialogFonts : public KPrefsModule
00517 {
00518 public:
00519 KOPrefsDialogFonts( QWidget *parent, const char *name )
00520 : KPrefsModule( KOPrefs::instance(), parent, name )
00521 {
00522 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00523
00524 QWidget *topFrame = new QWidget( this );
00525 topTopLayout->addWidget( topFrame );
00526
00527 QGridLayout *topLayout = new QGridLayout(topFrame,5,3);
00528 topLayout->setSpacing( KDialog::spacingHint() );
00529
00530 KPrefsWidFont *timeBarFont =
00531 addWidFont( KOPrefs::instance()->timeBarFontItem(), topFrame,
00532 KGlobal::locale()->formatTime( QTime( 12, 34 ) ) );
00533 topLayout->addWidget(timeBarFont->label(),0,0);
00534 topLayout->addWidget(timeBarFont->preview(),0,1);
00535 topLayout->addWidget(timeBarFont->button(),0,2);
00536
00537 KPrefsWidFont *monthViewFont =
00538 addWidFont( KOPrefs::instance()->monthViewFontItem(), topFrame,
00539 KGlobal::locale()->formatTime(QTime(12,34)) + " " +
00540 i18n("Event text") );
00541
00542 topLayout->addWidget(monthViewFont->label(),1,0);
00543 topLayout->addWidget(monthViewFont->preview(),1,1);
00544 topLayout->addWidget(monthViewFont->button(),1,2);
00545
00546 KPrefsWidFont *agendaViewFont =
00547 addWidFont( KOPrefs::instance()->agendaViewFontItem(),
00548 topFrame, i18n("Event text") );
00549 topLayout->addWidget(agendaViewFont->label(),2,0);
00550 topLayout->addWidget(agendaViewFont->preview(),2,1);
00551 topLayout->addWidget(agendaViewFont->button(),2,2);
00552
00553 KPrefsWidFont *marcusBainsFont =
00554 addWidFont( KOPrefs::instance()->marcusBainsFontItem(), topFrame,
00555 KGlobal::locale()->formatTime( QTime( 12, 34, 23 ) ) );
00556 topLayout->addWidget(marcusBainsFont->label(),3,0);
00557 topLayout->addWidget(marcusBainsFont->preview(),3,1);
00558 topLayout->addWidget(marcusBainsFont->button(),3,2);
00559
00560 topLayout->setColStretch(1,1);
00561 topLayout->setRowStretch(4,1);
00562
00563 load();
00564 }
00565 };
00566
00567 extern "C"
00568 {
00569 KCModule *create_korganizerconfigfonts( QWidget *parent, const char * )
00570 {
00571 return new KOPrefsDialogFonts( parent, "kcmkorganizerfonts" );
00572 }
00573 }
00574
00575
00576 KOPrefsDialogColors::KOPrefsDialogColors( QWidget *parent, const char *name )
00577 : KPrefsModule( KOPrefs::instance(), parent, name )
00578 {
00579 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00580
00581 QWidget *topFrame = new QWidget( this );
00582 topTopLayout->addWidget( topFrame );
00583
00584 QGridLayout *topLayout = new QGridLayout(topFrame,7,2);
00585 topLayout->setSpacing( KDialog::spacingHint() );
00586
00587
00588 KPrefsWidColor *holidayColor =
00589 addWidColor( KOPrefs::instance()->holidayColorItem(), topFrame );
00590 topLayout->addWidget(holidayColor->label(),0,0);
00591 topLayout->addWidget(holidayColor->button(),0,1);
00592
00593
00594 KPrefsWidColor *highlightColor =
00595 addWidColor( KOPrefs::instance()->highlightColorItem(), topFrame );
00596 topLayout->addWidget(highlightColor->label(),1,0);
00597 topLayout->addWidget(highlightColor->button(),1,1);
00598
00599 KPrefsWidColor *eventColor =
00600 addWidColor( KOPrefs::instance()->eventColorItem(), topFrame );
00601 topLayout->addWidget(eventColor->label(),2,0);
00602 topLayout->addWidget(eventColor->button(),2,1);
00603
00604
00605 KPrefsWidColor *agendaBgColor =
00606 addWidColor( KOPrefs::instance()->agendaBgColorItem(), topFrame );
00607 topLayout->addWidget(agendaBgColor->label(),3,0);
00608 topLayout->addWidget(agendaBgColor->button(),3,1);
00609
00610
00611 KPrefsWidColor *workingHoursColor =
00612 addWidColor( KOPrefs::instance()->workingHoursColorItem(), topFrame );
00613 topLayout->addWidget(workingHoursColor->label(),4,0);
00614 topLayout->addWidget(workingHoursColor->button(),4,1);
00615
00616
00617 KPrefsWidColor *todoDueTodayColor =
00618 addWidColor( KOPrefs::instance()->todoDueTodayColorItem(), topFrame );
00619 topLayout->addWidget(todoDueTodayColor->label(),5,0);
00620 topLayout->addWidget(todoDueTodayColor->button(),5,1);
00621
00622
00623 KPrefsWidColor *todoOverdueColor =
00624 addWidColor( KOPrefs::instance()->todoOverdueColorItem(), topFrame );
00625 topLayout->addWidget(todoOverdueColor->label(),6,0);
00626 topLayout->addWidget(todoOverdueColor->button(),6,1);
00627
00628
00629 QGroupBox *categoryGroup = new QGroupBox(1,Horizontal,i18n("Categories"),
00630 topFrame);
00631 topLayout->addMultiCellWidget(categoryGroup,7,7,0,1);
00632
00633 mCategoryCombo = new QComboBox(categoryGroup);
00634 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
00635 connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor()));
00636
00637 mCategoryButton = new KColorButton(categoryGroup);
00638 connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor()));
00639 updateCategoryColor();
00640
00641 topLayout->setRowStretch(8,1);
00642
00643 load();
00644 }
00645
00646 void KOPrefsDialogColors::usrWriteConfig()
00647 {
00648 QDictIterator<QColor> it(mCategoryDict);
00649 while (it.current()) {
00650 KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current());
00651 ++it;
00652 }
00653 }
00654
00655 void KOPrefsDialogColors::usrReadConfig()
00656 {
00657 updateCategories();
00658 }
00659
00660 void KOPrefsDialogColors::updateCategories()
00661 {
00662 mCategoryCombo->clear();
00663 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
00664 updateCategoryColor();
00665 }
00666
00667 void KOPrefsDialogColors::setCategoryColor()
00668 {
00669 mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color()));
00670 }
00671
00672 void KOPrefsDialogColors::updateCategoryColor()
00673 {
00674 QString cat = mCategoryCombo->currentText();
00675 QColor *color = mCategoryDict.find(cat);
00676 if (!color) {
00677 color = KOPrefs::instance()->categoryColor(cat);
00678 }
00679 if (color) {
00680 mCategoryButton->setColor(*color);
00681 slotWidChanged();
00682 }
00683 }
00684
00685 extern "C"
00686 {
00687 KCModule *create_korganizerconfigcolors( QWidget *parent, const char * )
00688 {
00689 return new KOPrefsDialogColors( parent, "kcmkorganizercolors" );
00690 }
00691 }
00692
00693
00694 class KOPrefsDialogPrinting : public KPrefsModule
00695 {
00696 public:
00697 KOPrefsDialogPrinting( QWidget *parent, const char *name )
00698 : KPrefsModule( KOPrefs::instance(), parent, name )
00699 {
00700 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00701
00702 QWidget *topFrame = new QWidget( this );
00703 topTopLayout->addWidget( topFrame );
00704
00705 QGridLayout *topLayout = new QGridLayout( topFrame, 5, 2 );
00706 topLayout->setSpacing( KDialog::spacingHint() );
00707
00708 topLayout->setRowStretch( 4, 1 );
00709
00710 load();
00711 }
00712 };
00713
00714 extern "C"
00715 {
00716 KCModule *create_korganizerconfigprinting( QWidget *parent, const char * )
00717 {
00718 return new KOPrefsDialogPrinting( parent, "kcmkorganizerprinting" );
00719 }
00720 }
00721
00722
00723 KOPrefsDialogGroupScheduling::KOPrefsDialogGroupScheduling( QWidget *parent, const char *name )
00724 : KPrefsModule( KOPrefs::instance(), parent, name )
00725 {
00726 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00727
00728 QWidget *topFrame = new QWidget( this );
00729 topTopLayout->addWidget( topFrame );
00730
00731 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
00732 topLayout->setSpacing( KDialog::spacingHint() );
00733
00734 #if 0
00735 KPrefsWidRadios *schedulerGroup =
00736 addWidRadios(i18n("Scheduler Mail Client"),KOPrefs::instance()->mIMIPScheduler,
00737 topFrame);
00738 schedulerGroup->addRadio("Dummy");
00739 schedulerGroup->addRadio(i18n("Mail client"));
00740
00741 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1);
00742 #endif
00743
00744 KPrefsWidRadios *sendGroup =
00745 addWidRadios( KOPrefs::instance()->iMIPSendItem(),
00746 topFrame );
00747
00748 topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1);
00749
00750 topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1);
00751 mAMails = new QListView(topFrame);
00752 mAMails->addColumn(i18n("Email"),300);
00753 topLayout->addMultiCellWidget(mAMails,3,3,0,1);
00754
00755 topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0);
00756 aEmailsEdit = new QLineEdit(topFrame);
00757 aEmailsEdit->setEnabled(false);
00758 topLayout->addWidget(aEmailsEdit,4,1);
00759
00760 QPushButton *add = new QPushButton(i18n("New"),topFrame,"new");
00761 topLayout->addWidget(add,5,0);
00762 QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove");
00763 topLayout->addWidget(del,5,1);
00764
00765
00766 connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) );
00767 connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) );
00768 connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem()));
00769 connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput()));
00770
00771 load();
00772 }
00773
00774 void KOPrefsDialogGroupScheduling::usrReadConfig()
00775 {
00776 mAMails->clear();
00777 for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin();
00778 it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) {
00779 QListViewItem *item = new QListViewItem(mAMails);
00780 item->setText(0,*it);
00781 mAMails->insertItem(item);
00782 }
00783 }
00784
00785 void KOPrefsDialogGroupScheduling::usrWriteConfig()
00786 {
00787 KOPrefs::instance()->mAdditionalMails.clear();
00788 QListViewItem *item;
00789 item = mAMails->firstChild();
00790 while (item)
00791 {
00792 KOPrefs::instance()->mAdditionalMails.append( item->text(0) );
00793 item = item->nextSibling();
00794 }
00795 }
00796
00797 void KOPrefsDialogGroupScheduling::addItem()
00798 {
00799 aEmailsEdit->setEnabled(true);
00800 QListViewItem *item = new QListViewItem(mAMails);
00801 mAMails->insertItem(item);
00802 mAMails->setSelected(item,true);
00803 aEmailsEdit->setText(i18n("(EmptyEmail)"));
00804 slotWidChanged();
00805 }
00806
00807 void KOPrefsDialogGroupScheduling::removeItem()
00808 {
00809 QListViewItem *item;
00810 item = mAMails->selectedItem();
00811 if (!item) return;
00812 mAMails->takeItem(item);
00813 item = mAMails->selectedItem();
00814 if (!item) {
00815 aEmailsEdit->setText("");
00816 aEmailsEdit->setEnabled(false);
00817 }
00818 if (mAMails->childCount() == 0) {
00819 aEmailsEdit->setEnabled(false);
00820 }
00821 slotWidChanged();
00822 }
00823
00824 void KOPrefsDialogGroupScheduling::updateItem()
00825 {
00826 QListViewItem *item;
00827 item = mAMails->selectedItem();
00828 if (!item) return;
00829 item->setText(0,aEmailsEdit->text());
00830 slotWidChanged();
00831 }
00832
00833 void KOPrefsDialogGroupScheduling::updateInput()
00834 {
00835 QListViewItem *item;
00836 item = mAMails->selectedItem();
00837 if (!item) return;
00838 aEmailsEdit->setEnabled(true);
00839 aEmailsEdit->setText(item->text(0));
00840 }
00841
00842 extern "C"
00843 {
00844 KCModule *create_korganizerconfiggroupscheduling( QWidget *parent,
00845 const char * )
00846 {
00847 return new KOPrefsDialogGroupScheduling( parent,
00848 "kcmkorganizergroupscheduling" );
00849 }
00850 }
00851
00852
00853 class KOPrefsDialogGroupAutomation : public KPrefsModule
00854 {
00855 public:
00856 KOPrefsDialogGroupAutomation( QWidget *parent, const char *name )
00857 : KPrefsModule( KOPrefs::instance(), parent, name )
00858 {
00859 QBoxLayout *topTopLayout = new QVBoxLayout( this );
00860
00861 QWidget *topFrame = new QWidget( this );
00862 topTopLayout->addWidget( topFrame );
00863
00864 QGridLayout *topLayout = new QGridLayout(topFrame,6,1);
00865 topLayout->setSpacing( KDialog::spacingHint() );
00866
00867 KPrefsWidRadios *autoRefreshGroup =
00868 addWidRadios( KOPrefs::instance()->iMIPAutoRefreshItem(), topFrame );
00869 topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0);
00870
00871 KPrefsWidRadios *autoInsertGroup =
00872 addWidRadios( KOPrefs::instance()->iMIPAutoInsertReplyItem(),
00873 topFrame );
00874 autoInsertGroup->addRadio(i18n("Never"));
00875 autoInsertGroup->addRadio(i18n("If attendee is in addressbook"));
00876
00877 topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0);
00878
00879 KPrefsWidRadios *autoRequestGroup =
00880 addWidRadios( KOPrefs::instance()->iMIPAutoInsertRequestItem(),
00881 topFrame );
00882 autoRequestGroup->addRadio(i18n("Never"));
00883 autoRequestGroup->addRadio(i18n("If organizer is in addressbook"));
00884
00885 topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0);
00886
00887 KPrefsWidRadios *autoFreeBusyGroup =
00888 addWidRadios( KOPrefs::instance()->iMIPAutoFreeBusyItem(), topFrame );
00889 autoFreeBusyGroup->addRadio(i18n("Never"));
00890 autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook"));
00891
00892 topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0);
00893
00894 KPrefsWidRadios *autoFreeBusyReplyGroup =
00895 addWidRadios( KOPrefs::instance()->iMIPAutoFreeBusyReplyItem(),
00896 topFrame );
00897 autoFreeBusyReplyGroup->addRadio(i18n("Never"));
00898 autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook"));
00899
00900 topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0);
00901
00902 topLayout->setRowStretch( 5, 1 );
00903
00904 load();
00905 }
00906 };
00907
00908 extern "C"
00909 {
00910 KCModule *create_korganizerconfiggroupautomation( QWidget *parent,
00911 const char * )
00912 {
00913 return new KOPrefsDialogGroupAutomation( parent,
00914 "kcmkorganizergroupautomation" );
00915 }
00916 }
00917
00918
00919 #if 0
00920 void KOPrefsDialog::showPrinterTab()
00921 {
00922 showPage(pageIndex(mPrinterTab));
00923 }
00924 #endif
00925
00926
00927 KOPrefsDialogGroupwareScheduling::KOPrefsDialogGroupwareScheduling( QWidget *parent, const char *name )
00928 : KPrefsModule( KOPrefs::instance(), parent, name )
00929 {
00930 mGroupwarePage = new KOGroupwarePrefsPage( this );
00931 connect( mGroupwarePage, SIGNAL( changed() ), SLOT( slotWidChanged() ) );
00932 ( new QVBoxLayout( this ) )->addWidget( mGroupwarePage );
00933
00934 load();
00935 }
00936
00937 void KOPrefsDialogGroupwareScheduling::usrReadConfig()
00938 {
00939 mGroupwarePage->publishEnable->setChecked( KOPrefs::instance()->mFreeBusyPublishAuto );
00940 mGroupwarePage->publishDelay->setValue( KOPrefs::instance()->mFreeBusyPublishDelay );
00941 mGroupwarePage->publishDays->setValue( KOPrefs::instance()->mFreeBusyPublishDays );
00942
00943 mGroupwarePage->publishUrl->setText( KOPrefs::instance()->mFreeBusyPublishUrl );
00944 mGroupwarePage->publishUser->setText( KOPrefs::instance()->mFreeBusyPublishUser );
00945 mGroupwarePage->publishPassword->setText( KOPrefs::instance()->mFreeBusyPublishPassword );
00946 mGroupwarePage->publishSavePassword->setChecked( KOPrefs::instance()->mFreeBusyPublishSavePassword );
00947
00948 mGroupwarePage->retrieveEnable->setChecked( KOPrefs::instance()->mFreeBusyRetrieveAuto );
00949 mGroupwarePage->fullDomainRetrieval->setChecked( KOPrefs::instance()->mFreeBusyFullDomainRetrieval );
00950 mGroupwarePage->retrieveUrl->setText( KOPrefs::instance()->mFreeBusyRetrieveUrl );
00951 mGroupwarePage->retrieveUser->setText( KOPrefs::instance()->mFreeBusyRetrieveUser );
00952 mGroupwarePage->retrievePassword->setText( KOPrefs::instance()->mFreeBusyRetrievePassword );
00953 mGroupwarePage->retrieveSavePassword->setChecked( KOPrefs::instance()->mFreeBusyRetrieveSavePassword );
00954 }
00955
00956 void KOPrefsDialogGroupwareScheduling::usrWriteConfig()
00957 {
00958 KOPrefs::instance()->mFreeBusyPublishAuto = mGroupwarePage->publishEnable->isChecked();
00959 KOPrefs::instance()->mFreeBusyPublishDelay = mGroupwarePage->publishDelay->value();
00960 KOPrefs::instance()->mFreeBusyPublishDays = mGroupwarePage->publishDays->value();
00961
00962 KOPrefs::instance()->mFreeBusyPublishUrl = mGroupwarePage->publishUrl->text();
00963 KOPrefs::instance()->mFreeBusyPublishUser = mGroupwarePage->publishUser->text();
00964 KOPrefs::instance()->mFreeBusyPublishPassword = mGroupwarePage->publishPassword->text();
00965 KOPrefs::instance()->mFreeBusyPublishSavePassword = mGroupwarePage->publishSavePassword->isChecked();
00966
00967 KOPrefs::instance()->mFreeBusyRetrieveAuto = mGroupwarePage->retrieveEnable->isChecked();
00968 KOPrefs::instance()->mFreeBusyFullDomainRetrieval = mGroupwarePage->fullDomainRetrieval->isChecked();
00969 KOPrefs::instance()->mFreeBusyRetrieveUrl = mGroupwarePage->retrieveUrl->text();
00970 KOPrefs::instance()->mFreeBusyRetrieveUser = mGroupwarePage->retrieveUser->text();
00971 KOPrefs::instance()->mFreeBusyRetrievePassword = mGroupwarePage->retrievePassword->text();
00972 KOPrefs::instance()->mFreeBusyRetrieveSavePassword = mGroupwarePage->retrieveSavePassword->isChecked();
00973 }
00974
00975 extern "C"
00976 {
00977 KCModule *create_korganizerconfigfreebusy( QWidget *parent, const char * )
00978 {
00979 return new KOPrefsDialogGroupwareScheduling( parent,
00980 "kcmkorganizerfreebusy" );
00981 }
00982 }
00983
00984
00985 #include "koprefsdialog.moc"