korganizer Library API Documentation

koprefsdialog.cpp

00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 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 // TODO: This radio button should only be available when KMail is chosen 00130 // connect(thekmailradiobuttonupthere,SIGNAL(toggled(bool)), 00131 // useGroupwareBool->checkBox(), SLOT(enabled(bool))); 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 // read the currently set time zone 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 // get the currently set timezone 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 // Read all system time zones 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 // find the currently set time zone and select it 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 // Respect start of week setting 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 topLayout->addMultiCellWidget( workDaysBox, 6, 6, 0, 1 ); 00352 00353 topLayout->setRowStretch(7,1); 00354 00355 load(); 00356 } 00357 00358 protected: 00359 void usrReadConfig() 00360 { 00361 setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId.utf8())); 00362 00363 mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); 00364 for ( int i = 0; i < 7; ++i ) { 00365 mWorkDays[i]->setChecked( (1<<i) & (KOPrefs::instance()->mWorkWeekMask) ); 00366 } 00367 } 00368 00369 void usrWriteConfig() 00370 { 00371 // Find untranslated selected zone 00372 QStringList::Iterator tz; 00373 for (tz = tzonenames.begin(); tz != tzonenames.end(); tz++) 00374 if (mTimeZoneCombo->currentText() == i18n((*tz).utf8())) 00375 break; 00376 if (tz != tzonenames.end()) 00377 KOPrefs::instance()->mTimeZoneId = (*tz); 00378 else 00379 KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText(); 00380 00381 KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); 00382 int mask = 0; 00383 for ( int i = 0; i < 7; ++i ) { 00384 if (mWorkDays[i]->isChecked()) mask = mask | (1<<i); 00385 } 00386 KOPrefs::instance()->mWorkWeekMask = mask; 00387 KOPrefs::instance()->writeConfig(); 00388 } 00389 00390 void setCombo( QComboBox *combo, const QString &text, 00391 const QStringList *tags = 0 ) 00392 { 00393 if (tags) { 00394 int i = tags->findIndex(text); 00395 if (i > 0) combo->setCurrentItem(i); 00396 } else { 00397 for(int i=0;i<combo->count();++i) { 00398 if (combo->text(i) == text) { 00399 combo->setCurrentItem(i); 00400 break; 00401 } 00402 } 00403 } 00404 } 00405 00406 private: 00407 QComboBox *mTimeZoneCombo; 00408 QStringList tzonenames; 00409 QComboBox *mAlarmTimeCombo; 00410 QCheckBox *mWorkDays[7]; 00411 }; 00412 00413 extern "C" 00414 { 00415 KCModule *create_korganizerconfigtime( QWidget *parent, const char * ) 00416 { 00417 KGlobal::locale()->insertCatalogue( "timezones" ); 00418 return new KOPrefsDialogTime( parent, "kcmkorganizertime" ); 00419 } 00420 } 00421 00422 00423 class KOPrefsDialogViews : public KPrefsModule 00424 { 00425 public: 00426 KOPrefsDialogViews( QWidget *parent, const char *name ) 00427 : KPrefsModule( KOPrefs::instance(), parent, name ) 00428 { 00429 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00430 00431 QWidget *topFrame = new QWidget( this ); 00432 topTopLayout->addWidget( topFrame ); 00433 00434 QBoxLayout *topLayout = new QVBoxLayout( topFrame ); 00435 topLayout->setSpacing( KDialog::spacingHint() ); 00436 00437 KPrefsWidBool *enableToolTips = 00438 addWidBool( KOPrefs::instance()->enableToolTipsItem(), topFrame ); 00439 topLayout->addWidget( enableToolTips->checkBox() ); 00440 00441 KPrefsWidBool *showTodosAgenda = 00442 addWidBool( KOPrefs::instance()->showAllDayTodoItem(), topFrame ); 00443 topLayout->addWidget( showTodosAgenda->checkBox() ); 00444 00445 /*** Date Navigator Group ***/ 00446 QGroupBox *dateNavGroup = new QGroupBox( 1, Horizontal, 00447 i18n("Date Navigator"), 00448 topFrame ); 00449 addWidBool( KOPrefs::instance()->dailyRecurItem(), dateNavGroup ); 00450 addWidBool( KOPrefs::instance()->weeklyRecurItem(), dateNavGroup ); 00451 topLayout->addWidget( dateNavGroup ); 00452 00453 00454 /*** Agenda View Group ***/ 00455 QGroupBox *agendaGroup = new QGroupBox( 1, Horizontal, 00456 i18n("Agenda View"), 00457 topFrame ); 00458 00459 QHBox *hourSizeBox = new QHBox( agendaGroup ); 00460 KPrefsWidInt *hourSize = 00461 addWidInt( KOPrefs::instance()->hourSizeItem(), hourSizeBox ); 00462 hourSize->spinBox()->setSuffix(i18n("suffix in the hour size spin box", " pixel")); 00463 new QWidget( hourSizeBox ); 00464 00465 QHBox *nextDaysBox = new QHBox( agendaGroup ); 00466 KPrefsWidInt *nextDays = 00467 addWidInt( KOPrefs::instance()->nextXDaysItem(), nextDaysBox ); 00468 nextDays->spinBox()->setSuffix(i18n("suffix in the N days spin box", " days")); 00469 new QWidget( nextDaysBox ); 00470 00471 KPrefsWidBool *marcusBainsEnabled = 00472 addWidBool( KOPrefs::instance()->marcusBainsEnabledItem(), agendaGroup ); 00473 00474 KPrefsWidBool *marcusBainsShowSeconds = 00475 addWidBool( KOPrefs::instance()->marcusBainsShowSecondsItem(), agendaGroup ); 00476 connect( marcusBainsEnabled->checkBox(), SIGNAL( toggled( bool ) ), 00477 marcusBainsShowSeconds->checkBox(), SLOT( setEnabled( bool ) ) ); 00478 00479 addWidBool( KOPrefs::instance()->selectionStartsEditorItem(), agendaGroup ); 00480 00481 topLayout->addWidget( agendaGroup ); 00482 00483 00484 /*** Month View Group ***/ 00485 QGroupBox *monthGroup = new QGroupBox( 1, Horizontal, 00486 i18n("Month View"), 00487 topFrame ); 00488 addWidBool( KOPrefs::instance()->enableMonthScrollItem(), monthGroup ); 00489 addWidBool( KOPrefs::instance()->fullViewMonthItem(), monthGroup ); 00490 addWidBool( KOPrefs::instance()->monthViewUsesCategoryColorItem(), 00491 monthGroup ); 00492 topLayout->addWidget( monthGroup ); 00493 00494 00495 /*** Todo View Group ***/ 00496 QGroupBox *todoGroup = new QGroupBox( 1, Horizontal, 00497 i18n("Todo View"), 00498 topFrame ); 00499 addWidBool( KOPrefs::instance()->fullViewTodoItem(), todoGroup ); 00500 topLayout->addWidget( todoGroup ); 00501 00502 topLayout->addStretch( 1 ); 00503 00504 load(); 00505 } 00506 }; 00507 00508 extern "C" 00509 { 00510 KCModule *create_korganizerconfigviews( QWidget *parent, const char * ) 00511 { 00512 return new KOPrefsDialogViews( parent, "kcmkorganizerviews" ); 00513 } 00514 } 00515 00516 00517 class KOPrefsDialogFonts : public KPrefsModule 00518 { 00519 public: 00520 KOPrefsDialogFonts( QWidget *parent, const char *name ) 00521 : KPrefsModule( KOPrefs::instance(), parent, name ) 00522 { 00523 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00524 00525 QWidget *topFrame = new QWidget( this ); 00526 topTopLayout->addWidget( topFrame ); 00527 00528 QGridLayout *topLayout = new QGridLayout(topFrame,5,3); 00529 topLayout->setSpacing( KDialog::spacingHint() ); 00530 00531 KPrefsWidFont *timeBarFont = 00532 addWidFont( KOPrefs::instance()->timeBarFontItem(), topFrame, 00533 KGlobal::locale()->formatTime( QTime( 12, 34 ) ) ); 00534 topLayout->addWidget(timeBarFont->label(),0,0); 00535 topLayout->addWidget(timeBarFont->preview(),0,1); 00536 topLayout->addWidget(timeBarFont->button(),0,2); 00537 00538 KPrefsWidFont *monthViewFont = 00539 addWidFont( KOPrefs::instance()->monthViewFontItem(), topFrame, 00540 KGlobal::locale()->formatTime(QTime(12,34)) + " " + 00541 i18n("Event text") ); 00542 00543 topLayout->addWidget(monthViewFont->label(),1,0); 00544 topLayout->addWidget(monthViewFont->preview(),1,1); 00545 topLayout->addWidget(monthViewFont->button(),1,2); 00546 00547 KPrefsWidFont *agendaViewFont = 00548 addWidFont( KOPrefs::instance()->agendaViewFontItem(), 00549 topFrame, i18n("Event text") ); 00550 topLayout->addWidget(agendaViewFont->label(),2,0); 00551 topLayout->addWidget(agendaViewFont->preview(),2,1); 00552 topLayout->addWidget(agendaViewFont->button(),2,2); 00553 00554 KPrefsWidFont *marcusBainsFont = 00555 addWidFont( KOPrefs::instance()->marcusBainsFontItem(), topFrame, 00556 KGlobal::locale()->formatTime( QTime( 12, 34, 23 ) ) ); 00557 topLayout->addWidget(marcusBainsFont->label(),3,0); 00558 topLayout->addWidget(marcusBainsFont->preview(),3,1); 00559 topLayout->addWidget(marcusBainsFont->button(),3,2); 00560 00561 topLayout->setColStretch(1,1); 00562 topLayout->setRowStretch(4,1); 00563 00564 load(); 00565 } 00566 }; 00567 00568 extern "C" 00569 { 00570 KCModule *create_korganizerconfigfonts( QWidget *parent, const char * ) 00571 { 00572 return new KOPrefsDialogFonts( parent, "kcmkorganizerfonts" ); 00573 } 00574 } 00575 00576 00577 KOPrefsDialogColors::KOPrefsDialogColors( QWidget *parent, const char *name ) 00578 : KPrefsModule( KOPrefs::instance(), parent, name ) 00579 { 00580 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00581 00582 QWidget *topFrame = new QWidget( this ); 00583 topTopLayout->addWidget( topFrame ); 00584 00585 QGridLayout *topLayout = new QGridLayout(topFrame,7,2); 00586 topLayout->setSpacing( KDialog::spacingHint() ); 00587 00588 // Holiday Color 00589 KPrefsWidColor *holidayColor = 00590 addWidColor( KOPrefs::instance()->holidayColorItem(), topFrame ); 00591 topLayout->addWidget(holidayColor->label(),0,0); 00592 topLayout->addWidget(holidayColor->button(),0,1); 00593 00594 // Highlight Color 00595 KPrefsWidColor *highlightColor = 00596 addWidColor( KOPrefs::instance()->highlightColorItem(), topFrame ); 00597 topLayout->addWidget(highlightColor->label(),1,0); 00598 topLayout->addWidget(highlightColor->button(),1,1); 00599 00600 KPrefsWidColor *eventColor = 00601 addWidColor( KOPrefs::instance()->eventColorItem(), topFrame ); 00602 topLayout->addWidget(eventColor->label(),2,0); 00603 topLayout->addWidget(eventColor->button(),2,1); 00604 00605 // agenda view background color 00606 KPrefsWidColor *agendaBgColor = 00607 addWidColor( KOPrefs::instance()->agendaBgColorItem(), topFrame ); 00608 topLayout->addWidget(agendaBgColor->label(),3,0); 00609 topLayout->addWidget(agendaBgColor->button(),3,1); 00610 00611 // working hours color 00612 KPrefsWidColor *workingHoursColor = 00613 addWidColor( KOPrefs::instance()->workingHoursColorItem(), topFrame ); 00614 topLayout->addWidget(workingHoursColor->label(),4,0); 00615 topLayout->addWidget(workingHoursColor->button(),4,1); 00616 00617 // Todo due today color 00618 KPrefsWidColor *todoDueTodayColor = 00619 addWidColor( KOPrefs::instance()->todoDueTodayColorItem(), topFrame ); 00620 topLayout->addWidget(todoDueTodayColor->label(),5,0); 00621 topLayout->addWidget(todoDueTodayColor->button(),5,1); 00622 00623 // Todo overdue color 00624 KPrefsWidColor *todoOverdueColor = 00625 addWidColor( KOPrefs::instance()->todoOverdueColorItem(), topFrame ); 00626 topLayout->addWidget(todoOverdueColor->label(),6,0); 00627 topLayout->addWidget(todoOverdueColor->button(),6,1); 00628 00629 // categories colors 00630 QGroupBox *categoryGroup = new QGroupBox(1,Horizontal,i18n("Categories"), 00631 topFrame); 00632 topLayout->addMultiCellWidget(categoryGroup,7,7,0,1); 00633 00634 mCategoryCombo = new QComboBox(categoryGroup); 00635 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); 00636 connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); 00637 00638 mCategoryButton = new KColorButton(categoryGroup); 00639 connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); 00640 updateCategoryColor(); 00641 00642 topLayout->setRowStretch(8,1); 00643 00644 load(); 00645 } 00646 00647 void KOPrefsDialogColors::usrWriteConfig() 00648 { 00649 QDictIterator<QColor> it(mCategoryDict); 00650 while (it.current()) { 00651 KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); 00652 ++it; 00653 } 00654 } 00655 00656 void KOPrefsDialogColors::usrReadConfig() 00657 { 00658 updateCategories(); 00659 } 00660 00661 void KOPrefsDialogColors::updateCategories() 00662 { 00663 mCategoryCombo->clear(); 00664 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); 00665 updateCategoryColor(); 00666 } 00667 00668 void KOPrefsDialogColors::setCategoryColor() 00669 { 00670 mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); 00671 } 00672 00673 void KOPrefsDialogColors::updateCategoryColor() 00674 { 00675 QString cat = mCategoryCombo->currentText(); 00676 QColor *color = mCategoryDict.find(cat); 00677 if (!color) { 00678 color = KOPrefs::instance()->categoryColor(cat); 00679 } 00680 if (color) { 00681 mCategoryButton->setColor(*color); 00682 slotWidChanged(); 00683 } 00684 } 00685 00686 extern "C" 00687 { 00688 KCModule *create_korganizerconfigcolors( QWidget *parent, const char * ) 00689 { 00690 return new KOPrefsDialogColors( parent, "kcmkorganizercolors" ); 00691 } 00692 } 00693 00694 00695 class KOPrefsDialogPrinting : public KPrefsModule 00696 { 00697 public: 00698 KOPrefsDialogPrinting( QWidget *parent, const char *name ) 00699 : KPrefsModule( KOPrefs::instance(), parent, name ) 00700 { 00701 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00702 00703 QWidget *topFrame = new QWidget( this ); 00704 topTopLayout->addWidget( topFrame ); 00705 00706 QGridLayout *topLayout = new QGridLayout( topFrame, 5, 2 ); 00707 topLayout->setSpacing( KDialog::spacingHint() ); 00708 00709 topLayout->setRowStretch( 4, 1 ); 00710 00711 load(); 00712 } 00713 }; 00714 00715 extern "C" 00716 { 00717 KCModule *create_korganizerconfigprinting( QWidget *parent, const char * ) 00718 { 00719 return new KOPrefsDialogPrinting( parent, "kcmkorganizerprinting" ); 00720 } 00721 } 00722 00723 00724 KOPrefsDialogGroupScheduling::KOPrefsDialogGroupScheduling( QWidget *parent, const char *name ) 00725 : KPrefsModule( KOPrefs::instance(), parent, name ) 00726 { 00727 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00728 00729 QWidget *topFrame = new QWidget( this ); 00730 topTopLayout->addWidget( topFrame ); 00731 00732 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 00733 topLayout->setSpacing( KDialog::spacingHint() ); 00734 00735 #if 0 00736 KPrefsWidRadios *schedulerGroup = 00737 addWidRadios(i18n("Scheduler Mail Client"),KOPrefs::instance()->mIMIPScheduler, 00738 topFrame); 00739 schedulerGroup->addRadio("Dummy"); // Only for debugging 00740 schedulerGroup->addRadio(i18n("Mail client")); 00741 00742 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); 00743 #endif 00744 00745 KPrefsWidRadios *sendGroup = 00746 addWidRadios( KOPrefs::instance()->iMIPSendItem(), 00747 topFrame ); 00748 00749 topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); 00750 00751 topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); 00752 mAMails = new QListView(topFrame); 00753 mAMails->addColumn(i18n("Email"),300); 00754 topLayout->addMultiCellWidget(mAMails,3,3,0,1); 00755 00756 topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); 00757 aEmailsEdit = new QLineEdit(topFrame); 00758 aEmailsEdit->setEnabled(false); 00759 topLayout->addWidget(aEmailsEdit,4,1); 00760 00761 QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); 00762 topLayout->addWidget(add,5,0); 00763 QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); 00764 topLayout->addWidget(del,5,1); 00765 00766 //topLayout->setRowStretch(2,1); 00767 connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); 00768 connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); 00769 connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); 00770 connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); 00771 00772 load(); 00773 } 00774 00775 void KOPrefsDialogGroupScheduling::usrReadConfig() 00776 { 00777 mAMails->clear(); 00778 for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); 00779 it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { 00780 QListViewItem *item = new QListViewItem(mAMails); 00781 item->setText(0,*it); 00782 mAMails->insertItem(item); 00783 } 00784 } 00785 00786 void KOPrefsDialogGroupScheduling::usrWriteConfig() 00787 { 00788 KOPrefs::instance()->mAdditionalMails.clear(); 00789 QListViewItem *item; 00790 item = mAMails->firstChild(); 00791 while (item) 00792 { 00793 KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); 00794 item = item->nextSibling(); 00795 } 00796 } 00797 00798 void KOPrefsDialogGroupScheduling::addItem() 00799 { 00800 aEmailsEdit->setEnabled(true); 00801 QListViewItem *item = new QListViewItem(mAMails); 00802 mAMails->insertItem(item); 00803 mAMails->setSelected(item,true); 00804 aEmailsEdit->setText(i18n("(EmptyEmail)")); 00805 slotWidChanged(); 00806 } 00807 00808 void KOPrefsDialogGroupScheduling::removeItem() 00809 { 00810 QListViewItem *item; 00811 item = mAMails->selectedItem(); 00812 if (!item) return; 00813 mAMails->takeItem(item); 00814 item = mAMails->selectedItem(); 00815 if (!item) { 00816 aEmailsEdit->setText(""); 00817 aEmailsEdit->setEnabled(false); 00818 } 00819 if (mAMails->childCount() == 0) { 00820 aEmailsEdit->setEnabled(false); 00821 } 00822 slotWidChanged(); 00823 } 00824 00825 void KOPrefsDialogGroupScheduling::updateItem() 00826 { 00827 QListViewItem *item; 00828 item = mAMails->selectedItem(); 00829 if (!item) return; 00830 item->setText(0,aEmailsEdit->text()); 00831 slotWidChanged(); 00832 } 00833 00834 void KOPrefsDialogGroupScheduling::updateInput() 00835 { 00836 QListViewItem *item; 00837 item = mAMails->selectedItem(); 00838 if (!item) return; 00839 aEmailsEdit->setEnabled(true); 00840 aEmailsEdit->setText(item->text(0)); 00841 } 00842 00843 extern "C" 00844 { 00845 KCModule *create_korganizerconfiggroupscheduling( QWidget *parent, 00846 const char * ) 00847 { 00848 return new KOPrefsDialogGroupScheduling( parent, 00849 "kcmkorganizergroupscheduling" ); 00850 } 00851 } 00852 00853 00854 class KOPrefsDialogGroupAutomation : public KPrefsModule 00855 { 00856 public: 00857 KOPrefsDialogGroupAutomation( QWidget *parent, const char *name ) 00858 : KPrefsModule( KOPrefs::instance(), parent, name ) 00859 { 00860 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00861 00862 QWidget *topFrame = new QWidget( this ); 00863 topTopLayout->addWidget( topFrame ); 00864 00865 QGridLayout *topLayout = new QGridLayout(topFrame,6,1); 00866 topLayout->setSpacing( KDialog::spacingHint() ); 00867 00868 KPrefsWidRadios *autoRefreshGroup = 00869 addWidRadios( KOPrefs::instance()->iMIPAutoRefreshItem(), topFrame ); 00870 topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0); 00871 00872 KPrefsWidRadios *autoInsertGroup = 00873 addWidRadios( KOPrefs::instance()->iMIPAutoInsertReplyItem(), 00874 topFrame ); 00875 autoInsertGroup->addRadio(i18n("Never")); 00876 autoInsertGroup->addRadio(i18n("If attendee is in addressbook")); 00877 //autoInsertGroup->addRadio(i18n("selected emails")); 00878 topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0); 00879 00880 KPrefsWidRadios *autoRequestGroup = 00881 addWidRadios( KOPrefs::instance()->iMIPAutoInsertRequestItem(), 00882 topFrame ); 00883 autoRequestGroup->addRadio(i18n("Never")); 00884 autoRequestGroup->addRadio(i18n("If organizer is in addressbook")); 00885 //autoInsertGroup->addRadio(i18n("selected emails")); 00886 topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0); 00887 00888 KPrefsWidRadios *autoFreeBusyGroup = 00889 addWidRadios( KOPrefs::instance()->iMIPAutoFreeBusyItem(), topFrame ); 00890 autoFreeBusyGroup->addRadio(i18n("Never")); 00891 autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook")); 00892 //autoFreeBusyGroup->addRadio(i18n("selected emails")); 00893 topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0); 00894 00895 KPrefsWidRadios *autoFreeBusyReplyGroup = 00896 addWidRadios( KOPrefs::instance()->iMIPAutoFreeBusyReplyItem(), 00897 topFrame ); 00898 autoFreeBusyReplyGroup->addRadio(i18n("Never")); 00899 autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook")); 00900 //autoFreeBusyGroup->addRadio(i18n("selected emails")); 00901 topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0); 00902 00903 topLayout->setRowStretch( 5, 1 ); 00904 00905 load(); 00906 } 00907 }; 00908 00909 extern "C" 00910 { 00911 KCModule *create_korganizerconfiggroupautomation( QWidget *parent, 00912 const char * ) 00913 { 00914 return new KOPrefsDialogGroupAutomation( parent, 00915 "kcmkorganizergroupautomation" ); 00916 } 00917 } 00918 00919 // TODO: find replacement for showing printer tab 00920 #if 0 00921 void KOPrefsDialog::showPrinterTab() 00922 { 00923 showPage(pageIndex(mPrinterTab)); 00924 } 00925 #endif 00926 00927 00928 KOPrefsDialogGroupwareScheduling::KOPrefsDialogGroupwareScheduling( QWidget *parent, const char *name ) 00929 : KPrefsModule( KOPrefs::instance(), parent, name ) 00930 { 00931 mGroupwarePage = new KOGroupwarePrefsPage( this ); 00932 connect( mGroupwarePage, SIGNAL( changed() ), SLOT( slotWidChanged() ) ); 00933 ( new QVBoxLayout( this ) )->addWidget( mGroupwarePage ); 00934 00935 load(); 00936 } 00937 00938 void KOPrefsDialogGroupwareScheduling::usrReadConfig() 00939 { 00940 mGroupwarePage->publishEnable->setChecked( KOPrefs::instance()->mFreeBusyPublishAuto ); 00941 mGroupwarePage->publishDelay->setValue( KOPrefs::instance()->mFreeBusyPublishDelay ); 00942 mGroupwarePage->publishDays->setValue( KOPrefs::instance()->mFreeBusyPublishDays ); 00943 00944 mGroupwarePage->publishUrl->setText( KOPrefs::instance()->mFreeBusyPublishUrl ); 00945 mGroupwarePage->publishUser->setText( KOPrefs::instance()->mFreeBusyPublishUser ); 00946 mGroupwarePage->publishPassword->setText( KOPrefs::instance()->mFreeBusyPublishPassword ); 00947 mGroupwarePage->publishSavePassword->setChecked( KOPrefs::instance()->mFreeBusyPublishSavePassword ); 00948 00949 mGroupwarePage->retrieveEnable->setChecked( KOPrefs::instance()->mFreeBusyRetrieveAuto ); 00950 mGroupwarePage->fullDomainRetrieval->setChecked( KOPrefs::instance()->mFreeBusyFullDomainRetrieval ); 00951 mGroupwarePage->retrieveUrl->setText( KOPrefs::instance()->mFreeBusyRetrieveUrl ); 00952 mGroupwarePage->retrieveUser->setText( KOPrefs::instance()->mFreeBusyRetrieveUser ); 00953 mGroupwarePage->retrievePassword->setText( KOPrefs::instance()->mFreeBusyRetrievePassword ); 00954 mGroupwarePage->retrieveSavePassword->setChecked( KOPrefs::instance()->mFreeBusyRetrieveSavePassword ); 00955 } 00956 00957 void KOPrefsDialogGroupwareScheduling::usrWriteConfig() 00958 { 00959 KOPrefs::instance()->mFreeBusyPublishAuto = mGroupwarePage->publishEnable->isChecked(); 00960 KOPrefs::instance()->mFreeBusyPublishDelay = mGroupwarePage->publishDelay->value(); 00961 KOPrefs::instance()->mFreeBusyPublishDays = mGroupwarePage->publishDays->value(); 00962 00963 KOPrefs::instance()->mFreeBusyPublishUrl = mGroupwarePage->publishUrl->text(); 00964 KOPrefs::instance()->mFreeBusyPublishUser = mGroupwarePage->publishUser->text(); 00965 KOPrefs::instance()->mFreeBusyPublishPassword = mGroupwarePage->publishPassword->text(); 00966 KOPrefs::instance()->mFreeBusyPublishSavePassword = mGroupwarePage->publishSavePassword->isChecked(); 00967 00968 KOPrefs::instance()->mFreeBusyRetrieveAuto = mGroupwarePage->retrieveEnable->isChecked(); 00969 KOPrefs::instance()->mFreeBusyFullDomainRetrieval = mGroupwarePage->fullDomainRetrieval->isChecked(); 00970 KOPrefs::instance()->mFreeBusyRetrieveUrl = mGroupwarePage->retrieveUrl->text(); 00971 KOPrefs::instance()->mFreeBusyRetrieveUser = mGroupwarePage->retrieveUser->text(); 00972 KOPrefs::instance()->mFreeBusyRetrievePassword = mGroupwarePage->retrievePassword->text(); 00973 KOPrefs::instance()->mFreeBusyRetrieveSavePassword = mGroupwarePage->retrieveSavePassword->isChecked(); 00974 } 00975 00976 extern "C" 00977 { 00978 KCModule *create_korganizerconfigfreebusy( QWidget *parent, const char * ) 00979 { 00980 return new KOPrefsDialogGroupwareScheduling( parent, 00981 "kcmkorganizerfreebusy" ); 00982 } 00983 } 00984 00985 00986 #include "koprefsdialog.moc"
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:53:26 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003