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 00050 #if defined(USE_SOLARIS) 00051 #include <sys/param.h> 00052 00053 #define ZONEINFODIR "/usr/share/lib/zoneinfo" 00054 #define INITFILE "/etc/default/init" 00055 #endif 00056 00057 #include "koprefs.h" 00058 00059 #include "koprefsdialog.h" 00060 #include "kogroupwareprefspage.h" 00061 00062 00063 KOPrefsDialogMain::KOPrefsDialogMain( QWidget *parent, const char *name ) 00064 : KPrefsModule( KOPrefs::instance(), parent, name ) 00065 { 00066 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00067 00068 QWidget *topFrame = new QWidget( this ); 00069 topTopLayout->addWidget( topFrame ); 00070 00071 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 00072 topLayout->setSpacing( KDialog::spacingHint() ); 00073 00074 KPrefsWidBool *emailControlCenter = 00075 addWidBool( KOPrefs::instance()->emailControlCenterItem(), topFrame ); 00076 topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1); 00077 connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), 00078 SLOT(toggleEmailSettings(bool))); 00079 00080 mNameEdit = new QLineEdit(topFrame); 00081 connect( mNameEdit, SIGNAL( textChanged( const QString & ) ), 00082 SLOT( slotWidChanged() ) ); 00083 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); 00084 topLayout->addWidget(mNameLabel,1,0); 00085 topLayout->addWidget(mNameEdit,1,1); 00086 00087 mEmailEdit = new QLineEdit(topFrame); 00088 connect( mEmailEdit, SIGNAL( textChanged( const QString & ) ), 00089 SLOT( slotWidChanged() ) ); 00090 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); 00091 topLayout->addWidget(mEmailLabel,2,0); 00092 topLayout->addWidget(mEmailEdit,2,1); 00093 00094 KPrefsWidBool *bcc = 00095 addWidBool( KOPrefs::instance()->bccItem(), topFrame ); 00096 topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); 00097 00098 00099 QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), 00100 topFrame); 00101 topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); 00102 00103 addWidBool( KOPrefs::instance()->autoSaveItem(), autoSaveGroup ); 00104 00105 QHBox *intervalBox = new QHBox(autoSaveGroup); 00106 intervalBox->setSpacing( KDialog::spacingHint() ); 00107 00108 QLabel *autoSaveIntervalLabel = new QLabel(i18n("Save &interval in minutes:"),intervalBox); 00109 mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); 00110 connect( mAutoSaveIntervalSpin, SIGNAL( valueChanged( int ) ), 00111 SLOT( slotWidChanged() ) ); 00112 autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin); 00113 00114 KPrefsWidBool *confirmCheck = 00115 addWidBool( KOPrefs::instance()->confirmItem(), topFrame ); 00116 topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); 00117 00118 KPrefsWidRadios *mailClientGroup = 00119 addWidRadios( KOPrefs::instance()->mailClientItem(), topFrame ); 00120 topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); 00121 00122 // TODO: Readd this switch 00123 // KPrefsWidBool *useGroupwareBool = 00124 // addWidBool( KOPrefs::instance()->useGroupwareCommunicationItem(), 00125 // topFrame ); 00126 // topLayout->addMultiCellWidget(useGroupwareBool->checkBox(),12,12,0,1); 00127 // TODO: This radio button should only be available when KMail is chosen 00128 // connect(thekmailradiobuttonupthere,SIGNAL(toggled(bool)), 00129 // useGroupwareBool->checkBox(), SLOT(enabled(bool))); 00130 00131 KPrefsWidBool *htmlsave = 00132 addWidBool( KOPrefs::instance()->htmlWithSaveItem(), 00133 topFrame ); 00134 topLayout->addMultiCellWidget(htmlsave->checkBox(),13,13,0,1); 00135 00136 KPrefsWidRadios *destinationGroup = 00137 addWidRadios( KOPrefs::instance()->destinationItem(), 00138 topFrame); 00139 topLayout->addMultiCellWidget(destinationGroup->groupBox(),14,14,0,1); 00140 00141 topLayout->setRowStretch(15,1); 00142 00143 load(); 00144 } 00145 00146 void KOPrefsDialogMain::usrReadConfig() 00147 { 00148 mNameEdit->setText(KOPrefs::instance()->fullName()); 00149 mEmailEdit->setText(KOPrefs::instance()->email()); 00150 00151 mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); 00152 } 00153 00154 void KOPrefsDialogMain::usrWriteConfig() 00155 { 00156 KOPrefs::instance()->setFullName(mNameEdit->text()); 00157 KOPrefs::instance()->setEmail(mEmailEdit->text()); 00158 00159 KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); 00160 } 00161 00162 void KOPrefsDialogMain::toggleEmailSettings( bool on ) 00163 { 00164 if (on) { 00165 mEmailEdit->setEnabled(false); 00166 mNameEdit->setEnabled(false); 00167 mEmailLabel->setEnabled(false); 00168 mNameLabel->setEnabled(false); 00169 00170 KEMailSettings settings; 00171 mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); 00172 mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); 00173 } else { 00174 mEmailEdit->setEnabled(true); 00175 mNameEdit->setEnabled(true); 00176 mEmailLabel->setEnabled(true); 00177 mNameLabel->setEnabled(true); 00178 } 00179 } 00180 00181 extern "C" 00182 { 00183 KCModule *create_korganizerconfigmain( QWidget *parent, const char * ) 00184 { 00185 return new KOPrefsDialogMain( parent, "kcmkorganizermain" ); 00186 } 00187 } 00188 00189 00190 class KOPrefsDialogTime : public KPrefsModule 00191 { 00192 public: 00193 KOPrefsDialogTime( QWidget *parent, const char *name ) 00194 : KPrefsModule( KOPrefs::instance(), parent, name ) 00195 { 00196 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00197 00198 QWidget *topFrame = new QWidget( this ); 00199 topTopLayout->addWidget( topFrame ); 00200 00201 QGridLayout *topLayout = new QGridLayout(topFrame,5,2); 00202 topLayout->setSpacing( KDialog::spacingHint() ); 00203 00204 QHBox *timeZoneBox = new QHBox( topFrame ); 00205 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); 00206 00207 new QLabel( i18n("Timezone:"), timeZoneBox ); 00208 mTimeZoneCombo = new QComboBox( timeZoneBox ); 00209 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), 00210 SLOT( slotWidChanged() ) ); 00211 00212 FILE *f; 00213 char tempstring[101] = "Unknown"; 00214 QString sCurrentlySet(i18n("Unknown")); 00215 int nCurrentlySet = 0; 00216 QStringList list; 00217 00218 // read the currently set time zone 00219 #if defined(USE_SOLARIS) // MARCO 00220 char buf[MAXPATHLEN]; 00221 00222 snprintf(buf, MAXPATHLEN, 00223 "/bin/fgrep 'TZ=' %s | /bin/head -n 1 | /bin/cut -b 4-", 00224 INITFILE); 00225 00226 if (f = popen(buf, "r")) 00227 { 00228 if (fgets(buf, MAXPATHLEN - 1, f) != NULL) 00229 { 00230 buf[strlen(buf) - 1] = '\0'; 00231 sCurrentlySet = QString(buf); 00232 } 00233 pclose(f); 00234 } 00235 #else 00236 if((f = fopen("/etc/timezone", "r")) != NULL) { 00237 // get the currently set timezone 00238 fgets(tempstring, 100, f); 00239 tempstring[strlen(tempstring) - 1] = '\0'; 00240 sCurrentlySet = QString(tempstring); 00241 fclose(f); 00242 } 00243 #endif // !USE_SOLARIS 00244 00245 mTimeZoneCombo->insertItem(i18n("[No selection]")); 00246 00247 // Read all system time zones 00248 #if defined(USE_SOLARIS) // MARCO 00249 snprintf(buf, MAXPATHLEN, 00250 "/bin/find %s \\( -name src -prune \\) -o -type f -print | /bin/cut -b %d-", 00251 ZONEINFODIR, strlen(ZONEINFODIR) + 2); 00252 00253 if (f = popen(buf, "r")) 00254 { 00255 while(fgets(buf, MAXPATHLEN - 1, f) != NULL) 00256 { 00257 buf[strlen(buf) - 1] = '\0'; 00258 list.append(buf); 00259 } 00260 pclose(f); 00261 } 00262 00263 #else 00264 f = popen("grep -e ^[^#] /usr/share/zoneinfo/zone.tab | cut -f 3","r"); 00265 if (!f) return; 00266 while(fgets(tempstring, 100, f) != NULL) { 00267 tempstring[strlen(tempstring)-1] = '\0'; 00268 list.append(i18n(tempstring)); 00269 tzonenames << tempstring; 00270 } 00271 pclose(f); 00272 #endif // !USE_SOLARIS 00273 list.sort(); 00274 00275 mTimeZoneCombo->insertStringList(list); 00276 00277 // find the currently set time zone and select it 00278 for (int i = 0; i < mTimeZoneCombo->count(); i++) 00279 { 00280 if (mTimeZoneCombo->text(i) == sCurrentlySet) 00281 { 00282 nCurrentlySet = i; 00283 break; 00284 } 00285 } 00286 00287 mTimeZoneCombo->setCurrentItem(nCurrentlySet); 00288 00289 topLayout->addWidget(new QLabel(i18n("Default appointment time:"), 00290 topFrame),1,0); 00291 mStartTimeSpin = new QSpinBox(0,23,1,topFrame); 00292 connect( mStartTimeSpin, SIGNAL( valueChanged( int ) ), 00293 SLOT( slotWidChanged() ) ); 00294 mStartTimeSpin->setSuffix(":00"); 00295 topLayout->addWidget(mStartTimeSpin,1,1); 00296 00297 topLayout->addWidget(new QLabel(i18n("Default duration of new appointment:"), 00298 topFrame),2,0); 00299 mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame); 00300 connect( mDefaultDurationSpin, SIGNAL( valueChanged( int ) ), 00301 SLOT( slotWidChanged() ) ); 00302 mDefaultDurationSpin->setSuffix(":00"); 00303 topLayout->addWidget(mDefaultDurationSpin,2,1); 00304 00305 QStringList alarmList; 00306 alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes") 00307 << i18n("15 minutes") << i18n("30 minutes"); 00308 topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame), 00309 3,0); 00310 mAlarmTimeCombo = new QComboBox(topFrame); 00311 connect( mAlarmTimeCombo, SIGNAL( activated( int ) ), 00312 SLOT( slotWidChanged() ) ); 00313 mAlarmTimeCombo->insertStringList(alarmList); 00314 topLayout->addWidget(mAlarmTimeCombo,3,1); 00315 00316 00317 QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal, 00318 i18n("Working Hours"), 00319 topFrame); 00320 topLayout->addMultiCellWidget(workingHoursGroup,4,4,0,1); 00321 00322 QHBox *workStartBox = new QHBox(workingHoursGroup); 00323 00324 addWidTime( KOPrefs::instance()->workingHoursStartItem(), workStartBox ); 00325 00326 QHBox *workEndBox = new QHBox(workingHoursGroup); 00327 00328 addWidTime( KOPrefs::instance()->workingHoursEndItem(), workEndBox ); 00329 00330 addWidBool( KOPrefs::instance()->excludeHolidaysItem(), 00331 workingHoursGroup ); 00332 00333 addWidBool( KOPrefs::instance()->excludeSaturdaysItem(), 00334 workingHoursGroup ); 00335 00336 topLayout->setRowStretch(6,1); 00337 00338 load(); 00339 } 00340 00341 protected: 00342 void usrReadConfig() 00343 { 00344 setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId.utf8())); 00345 00346 mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); 00347 mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); 00348 mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); 00349 } 00350 00351 void usrWriteConfig() 00352 { 00353 // Find untranslated selected zone 00354 QStringList::Iterator tz; 00355 for (tz = tzonenames.begin(); tz != tzonenames.end(); tz++) 00356 if (mTimeZoneCombo->currentText() == i18n((*tz).utf8())) 00357 break; 00358 if (tz != tzonenames.end()) 00359 KOPrefs::instance()->mTimeZoneId = (*tz); 00360 else 00361 KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText(); 00362 00363 KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); 00364 KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); 00365 KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); 00366 } 00367 00368 void setCombo( QComboBox *combo, const QString &text, 00369 const QStringList *tags = 0 ) 00370 { 00371 if (tags) { 00372 int i = tags->findIndex(text); 00373 if (i > 0) combo->setCurrentItem(i); 00374 } else { 00375 for(int i=0;i<combo->count();++i) { 00376 if (combo->text(i) == text) { 00377 combo->setCurrentItem(i); 00378 break; 00379 } 00380 } 00381 } 00382 } 00383 00384 private: 00385 QComboBox *mTimeZoneCombo; 00386 QStringList tzonenames; 00387 QSpinBox *mStartTimeSpin; 00388 QSpinBox *mDefaultDurationSpin; 00389 QComboBox *mAlarmTimeCombo; 00390 }; 00391 00392 extern "C" 00393 { 00394 KCModule *create_korganizerconfigtime( QWidget *parent, const char * ) 00395 { 00396 KGlobal::locale()->insertCatalogue( "timezones" ); 00397 return new KOPrefsDialogTime( parent, "kcmkorganizertime" ); 00398 } 00399 } 00400 00401 00402 class KOPrefsDialogViews : public KPrefsModule 00403 { 00404 public: 00405 KOPrefsDialogViews( QWidget *parent, const char *name ) 00406 : KPrefsModule( KOPrefs::instance(), parent, name ) 00407 { 00408 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00409 00410 QWidget *topFrame = new QWidget( this ); 00411 topTopLayout->addWidget( topFrame ); 00412 00413 QGridLayout *topLayout = new QGridLayout(topFrame,13,2); 00414 topLayout->setSpacing( KDialog::spacingHint() ); 00415 00416 QBoxLayout *dayBeginsLayout = new QHBoxLayout; 00417 topLayout->addLayout(dayBeginsLayout,0,0); 00418 00419 KPrefsWidTime *dayBegins = 00420 addWidTime( KOPrefs::instance()->dayBeginsItem(), 00421 topFrame ); 00422 dayBeginsLayout->addWidget(dayBegins->label()); 00423 dayBeginsLayout->addStretch(1); 00424 dayBeginsLayout->addWidget(dayBegins->spinBox()); 00425 00426 QBoxLayout *nextDaysLayout = new QHBoxLayout; 00427 topLayout->addLayout(nextDaysLayout,1,0); 00428 nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame)); 00429 mNextXDaysSpin = new QSpinBox(2,14,1,topFrame); 00430 connect( mNextXDaysSpin, SIGNAL( valueChanged( int ) ), 00431 SLOT( slotWidChanged() ) ); 00432 nextDaysLayout->addStretch(1); 00433 nextDaysLayout->addWidget(mNextXDaysSpin); 00434 00435 QGroupBox *hourSizeGroup = new QGroupBox(1,Horizontal, 00436 i18n("Hour Size in Schedule View"), 00437 topFrame); 00438 mHourSizeSlider = new QSlider(4,30,1,10,Horizontal,hourSizeGroup); 00439 connect( mHourSizeSlider, SIGNAL ( valueChanged( int ) ), 00440 SLOT( slotWidChanged() ) ); 00441 topLayout->addMultiCellWidget(hourSizeGroup,2,2,0,1); 00442 00443 KPrefsWidBool *dailyRecur = 00444 addWidBool( KOPrefs::instance()->dailyRecurItem(), topFrame ); 00445 topLayout->addWidget(dailyRecur->checkBox(),3,0); 00446 00447 KPrefsWidBool *weeklyRecur = 00448 addWidBool( KOPrefs::instance()->weeklyRecurItem(), topFrame ); 00449 topLayout->addWidget(weeklyRecur->checkBox(),4,0); 00450 00451 KPrefsWidBool *enableToolTips = 00452 addWidBool( KOPrefs::instance()->enableToolTipsItem(), topFrame ); 00453 topLayout->addWidget(enableToolTips->checkBox(),5,0); 00454 00455 KPrefsWidBool *enableMonthScroll = 00456 addWidBool( KOPrefs::instance()->enableMonthScrollItem(), topFrame ); 00457 topLayout->addWidget(enableMonthScroll->checkBox(),6,0); 00458 00459 KPrefsWidBool *fullViewMonth = 00460 addWidBool( KOPrefs::instance()->fullViewMonthItem(), topFrame ); 00461 topLayout->addWidget(fullViewMonth->checkBox(),7,0); 00462 00463 KPrefsWidBool *coloredCategoriesInMonthView = 00464 addWidBool( KOPrefs::instance()->monthViewUsesCategoryColorItem(), 00465 topFrame ); 00466 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),8,0); 00467 00468 KPrefsWidBool *fullViewTodo = 00469 addWidBool( KOPrefs::instance()->fullViewTodoItem(), topFrame ); 00470 topLayout->addWidget(fullViewTodo->checkBox(),9,0); 00471 00472 KPrefsWidBool *marcusBainsEnabled = 00473 addWidBool( KOPrefs::instance()->marcusBainsEnabledItem(), topFrame ); 00474 topLayout->addWidget(marcusBainsEnabled->checkBox(),10,0); 00475 00476 KPrefsWidBool *marcusBainsShowSeconds = 00477 addWidBool( KOPrefs::instance()->marcusBainsShowSecondsItem(), topFrame ); 00478 topLayout->addWidget(marcusBainsShowSeconds->checkBox(),11,0); 00479 connect( marcusBainsEnabled->checkBox(), SIGNAL( toggled( bool ) ), 00480 marcusBainsShowSeconds->checkBox(), SLOT( setEnabled( bool ) ) ); 00481 00482 KPrefsWidBool *selectionStartsEditor = 00483 addWidBool( KOPrefs::instance()->selectionStartsEditorItem(), 00484 topFrame ); 00485 topLayout->addWidget(selectionStartsEditor->checkBox(),12,0); 00486 00487 topLayout->setRowStretch(11,1); 00488 00489 load(); 00490 } 00491 00492 protected: 00493 void usrReadConfig() 00494 { 00495 mHourSizeSlider->setValue(KOPrefs::instance()->mHourSize); 00496 mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays); 00497 } 00498 00499 void usrWriteConfig() 00500 { 00501 KOPrefs::instance()->mHourSize = mHourSizeSlider->value(); 00502 KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value(); 00503 } 00504 00505 private: 00506 QSlider *mHourSizeSlider; 00507 QSpinBox *mNextXDaysSpin; 00508 }; 00509 00510 extern "C" 00511 { 00512 KCModule *create_korganizerconfigviews( QWidget *parent, const char * ) 00513 { 00514 return new KOPrefsDialogViews( parent, "kcmkorganizerviews" ); 00515 } 00516 } 00517 00518 00519 class KOPrefsDialogFonts : public KPrefsModule 00520 { 00521 public: 00522 KOPrefsDialogFonts( QWidget *parent, const char *name ) 00523 : KPrefsModule( KOPrefs::instance(), parent, name ) 00524 { 00525 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00526 00527 QWidget *topFrame = new QWidget( this ); 00528 topTopLayout->addWidget( topFrame ); 00529 00530 QGridLayout *topLayout = new QGridLayout(topFrame,5,3); 00531 topLayout->setSpacing( KDialog::spacingHint() ); 00532 00533 KPrefsWidFont *timeBarFont = 00534 addWidFont( KOPrefs::instance()->timeBarFontItem(), topFrame, 00535 KGlobal::locale()->formatTime( QTime( 12, 34 ) ) ); 00536 topLayout->addWidget(timeBarFont->label(),0,0); 00537 topLayout->addWidget(timeBarFont->preview(),0,1); 00538 topLayout->addWidget(timeBarFont->button(),0,2); 00539 00540 KPrefsWidFont *monthViewFont = 00541 addWidFont( KOPrefs::instance()->monthViewFontItem(), topFrame, 00542 KGlobal::locale()->formatTime(QTime(12,34)) + " " + 00543 i18n("Event text") ); 00544 00545 topLayout->addWidget(monthViewFont->label(),1,0); 00546 topLayout->addWidget(monthViewFont->preview(),1,1); 00547 topLayout->addWidget(monthViewFont->button(),1,2); 00548 00549 KPrefsWidFont *agendaViewFont = 00550 addWidFont( KOPrefs::instance()->agendaViewFontItem(), 00551 topFrame, i18n("Event text") ); 00552 topLayout->addWidget(agendaViewFont->label(),2,0); 00553 topLayout->addWidget(agendaViewFont->preview(),2,1); 00554 topLayout->addWidget(agendaViewFont->button(),2,2); 00555 00556 KPrefsWidFont *marcusBainsFont = 00557 addWidFont( KOPrefs::instance()->marcusBainsFontItem(), topFrame, 00558 KGlobal::locale()->formatTime( QTime( 12, 34, 23 ) ) ); 00559 topLayout->addWidget(marcusBainsFont->label(),3,0); 00560 topLayout->addWidget(marcusBainsFont->preview(),3,1); 00561 topLayout->addWidget(marcusBainsFont->button(),3,2); 00562 00563 topLayout->setColStretch(1,1); 00564 topLayout->setRowStretch(4,1); 00565 00566 load(); 00567 } 00568 }; 00569 00570 extern "C" 00571 { 00572 KCModule *create_korganizerconfigfonts( QWidget *parent, const char * ) 00573 { 00574 return new KOPrefsDialogFonts( parent, "kcmkorganizerfonts" ); 00575 } 00576 } 00577 00578 00579 KOPrefsDialogColors::KOPrefsDialogColors( QWidget *parent, const char *name ) 00580 : KPrefsModule( KOPrefs::instance(), parent, name ) 00581 { 00582 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00583 00584 QWidget *topFrame = new QWidget( this ); 00585 topTopLayout->addWidget( topFrame ); 00586 00587 QGridLayout *topLayout = new QGridLayout(topFrame,7,2); 00588 topLayout->setSpacing( KDialog::spacingHint() ); 00589 00590 // Holiday Color 00591 KPrefsWidColor *holidayColor = 00592 addWidColor( KOPrefs::instance()->holidayColorItem(), topFrame ); 00593 topLayout->addWidget(holidayColor->label(),0,0); 00594 topLayout->addWidget(holidayColor->button(),0,1); 00595 00596 // Highlight Color 00597 KPrefsWidColor *highlightColor = 00598 addWidColor( KOPrefs::instance()->highlightColorItem(), topFrame ); 00599 topLayout->addWidget(highlightColor->label(),1,0); 00600 topLayout->addWidget(highlightColor->button(),1,1); 00601 00602 KPrefsWidColor *eventColor = 00603 addWidColor( KOPrefs::instance()->eventColorItem(), topFrame ); 00604 topLayout->addWidget(eventColor->label(),2,0); 00605 topLayout->addWidget(eventColor->button(),2,1); 00606 00607 // agenda view background color 00608 KPrefsWidColor *agendaBgColor = 00609 addWidColor( KOPrefs::instance()->agendaBgColorItem(), topFrame ); 00610 topLayout->addWidget(agendaBgColor->label(),3,0); 00611 topLayout->addWidget(agendaBgColor->button(),3,1); 00612 00613 // working hours color 00614 KPrefsWidColor *workingHoursColor = 00615 addWidColor( KOPrefs::instance()->workingHoursColorItem(), topFrame ); 00616 topLayout->addWidget(workingHoursColor->label(),4,0); 00617 topLayout->addWidget(workingHoursColor->button(),4,1); 00618 00619 // Todo due today color 00620 KPrefsWidColor *todoDueTodayColor = 00621 addWidColor( KOPrefs::instance()->todoDueTodayColorItem(), topFrame ); 00622 topLayout->addWidget(todoDueTodayColor->label(),5,0); 00623 topLayout->addWidget(todoDueTodayColor->button(),5,1); 00624 00625 // Todo overdue color 00626 KPrefsWidColor *todoOverdueColor = 00627 addWidColor( KOPrefs::instance()->todoOverdueColorItem(), topFrame ); 00628 topLayout->addWidget(todoOverdueColor->label(),6,0); 00629 topLayout->addWidget(todoOverdueColor->button(),6,1); 00630 00631 // categories colors 00632 QGroupBox *categoryGroup = new QGroupBox(1,Horizontal,i18n("Categories"), 00633 topFrame); 00634 topLayout->addMultiCellWidget(categoryGroup,7,7,0,1); 00635 00636 mCategoryCombo = new QComboBox(categoryGroup); 00637 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); 00638 connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); 00639 00640 mCategoryButton = new KColorButton(categoryGroup); 00641 connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); 00642 updateCategoryColor(); 00643 00644 topLayout->setRowStretch(8,1); 00645 00646 load(); 00647 } 00648 00649 void KOPrefsDialogColors::usrWriteConfig() 00650 { 00651 QDictIterator<QColor> it(mCategoryDict); 00652 while (it.current()) { 00653 KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); 00654 ++it; 00655 } 00656 } 00657 00658 void KOPrefsDialogColors::usrReadConfig() 00659 { 00660 updateCategories(); 00661 } 00662 00663 void KOPrefsDialogColors::updateCategories() 00664 { 00665 mCategoryCombo->clear(); 00666 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); 00667 updateCategoryColor(); 00668 } 00669 00670 void KOPrefsDialogColors::setCategoryColor() 00671 { 00672 mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); 00673 } 00674 00675 void KOPrefsDialogColors::updateCategoryColor() 00676 { 00677 QString cat = mCategoryCombo->currentText(); 00678 QColor *color = mCategoryDict.find(cat); 00679 if (!color) { 00680 color = KOPrefs::instance()->categoryColor(cat); 00681 } 00682 if (color) { 00683 mCategoryButton->setColor(*color); 00684 slotWidChanged(); 00685 } 00686 } 00687 00688 extern "C" 00689 { 00690 KCModule *create_korganizerconfigcolors( QWidget *parent, const char * ) 00691 { 00692 return new KOPrefsDialogColors( parent, "kcmkorganizercolors" ); 00693 } 00694 } 00695 00696 00697 class KOPrefsDialogPrinting : public KPrefsModule 00698 { 00699 public: 00700 KOPrefsDialogPrinting( QWidget *parent, const char *name ) 00701 : KPrefsModule( KOPrefs::instance(), parent, name ) 00702 { 00703 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00704 00705 QWidget *topFrame = new QWidget( this ); 00706 topTopLayout->addWidget( topFrame ); 00707 00708 QGridLayout *topLayout = new QGridLayout( topFrame, 5, 2 ); 00709 topLayout->setSpacing( KDialog::spacingHint() ); 00710 00711 topLayout->setRowStretch( 4, 1 ); 00712 00713 load(); 00714 } 00715 }; 00716 00717 extern "C" 00718 { 00719 KCModule *create_korganizerconfigprinting( QWidget *parent, const char * ) 00720 { 00721 return new KOPrefsDialogPrinting( parent, "kcmkorganizerprinting" ); 00722 } 00723 } 00724 00725 00726 KOPrefsDialogGroupScheduling::KOPrefsDialogGroupScheduling( QWidget *parent, const char *name ) 00727 : KPrefsModule( KOPrefs::instance(), parent, name ) 00728 { 00729 QBoxLayout *topTopLayout = new QVBoxLayout( this ); 00730 00731 QWidget *topFrame = new QWidget( this ); 00732 topTopLayout->addWidget( topFrame ); 00733 00734 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 00735 topLayout->setSpacing( KDialog::spacingHint() ); 00736 00737 #if 0 00738 KPrefsWidRadios *schedulerGroup = 00739 addWidRadios(i18n("Scheduler Mail Client"),KOPrefs::instance()->mIMIPScheduler, 00740 topFrame); 00741 schedulerGroup->addRadio("Dummy"); // Only for debugging 00742 schedulerGroup->addRadio(i18n("Mail client")); 00743 00744 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); 00745 #endif 00746 00747 KPrefsWidRadios *sendGroup = 00748 addWidRadios( KOPrefs::instance()->iMIPSendItem(), 00749 topFrame ); 00750 00751 topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); 00752 00753 topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); 00754 mAMails = new QListView(topFrame); 00755 mAMails->addColumn(i18n("Email"),300); 00756 topLayout->addMultiCellWidget(mAMails,3,3,0,1); 00757 00758 topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); 00759 aEmailsEdit = new QLineEdit(topFrame); 00760 aEmailsEdit->setEnabled(false); 00761 topLayout->addWidget(aEmailsEdit,4,1); 00762 00763 QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); 00764 topLayout->addWidget(add,5,0); 00765 QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); 00766 topLayout->addWidget(del,5,1); 00767 00768 //topLayout->setRowStretch(2,1); 00769 connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); 00770 connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); 00771 connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); 00772 connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); 00773 00774 load(); 00775 } 00776 00777 void KOPrefsDialogGroupScheduling::usrReadConfig() 00778 { 00779 mAMails->clear(); 00780 for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); 00781 it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { 00782 QListViewItem *item = new QListViewItem(mAMails); 00783 item->setText(0,*it); 00784 mAMails->insertItem(item); 00785 } 00786 } 00787 00788 void KOPrefsDialogGroupScheduling::usrWriteConfig() 00789 { 00790 KOPrefs::instance()->mAdditionalMails.clear(); 00791 QListViewItem *item; 00792 item = mAMails->firstChild(); 00793 while (item) 00794 { 00795 KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); 00796 item = item->nextSibling(); 00797 } 00798 } 00799 00800 void KOPrefsDialogGroupScheduling::addItem() 00801 { 00802 aEmailsEdit->setEnabled(true); 00803 QListViewItem *item = new QListViewItem(mAMails); 00804 mAMails->insertItem(item); 00805 mAMails->setSelected(item,true); 00806 aEmailsEdit->setText(i18n("(EmptyEmail)")); 00807 } 00808 00809 void KOPrefsDialogGroupScheduling::removeItem() 00810 { 00811 QListViewItem *item; 00812 item = mAMails->selectedItem(); 00813 if (!item) return; 00814 mAMails->takeItem(item); 00815 item = mAMails->selectedItem(); 00816 if (!item) { 00817 aEmailsEdit->setText(""); 00818 aEmailsEdit->setEnabled(false); 00819 } 00820 if (mAMails->childCount() == 0) { 00821 aEmailsEdit->setEnabled(false); 00822 } 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 } 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 //autoInsertGroup->addRadio(i18n("selected emails")); 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 //autoInsertGroup->addRadio(i18n("selected emails")); 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 //autoFreeBusyGroup->addRadio(i18n("selected emails")); 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 //autoFreeBusyGroup->addRadio(i18n("selected emails")); 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 // TODO: find replacement for showing printer tab 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->publishManualRB->setChecked( !KOPrefs::instance()->mAutoPublish ); 00940 mGroupwarePage->publishAutoRB->setChecked( KOPrefs::instance()->mAutoPublish ); 00941 mGroupwarePage->publishDelaySB->setValue( KOPrefs::instance()->mPublishDelay ); 00942 mGroupwarePage->publishDaysSB->setValue( KOPrefs::instance()->mPublishFreeBusyDays ); 00943 mGroupwarePage->publishKolabRB->setChecked( KOPrefs::instance()->mPublishKolab ); 00944 mGroupwarePage->kolabServerNameED->setText( KOPrefs::instance()->mPublishKolabServer ); 00945 mGroupwarePage->publishUserNameED->setText( KOPrefs::instance()->mPublishUserName ); 00946 mGroupwarePage->publishAnyServerRB->setChecked( !KOPrefs::instance()->mPublishKolab ); 00947 mGroupwarePage->publishPasswordED->setText( KOPrefs::instance()->mPublishPassword ); 00948 mGroupwarePage->publishPasswordCB->setChecked( KOPrefs::instance()->mRememberPublishPw ); 00949 mGroupwarePage->anyServerURLED->setText( KOPrefs::instance()->mPublishAnyURL ); 00950 mGroupwarePage->retrieveCB->setChecked( KOPrefs::instance()->mRetrieveFreeBusy ); 00951 mGroupwarePage->retrieveKolabRB->setChecked( KOPrefs::instance()->mRetrieveKolab ); 00952 mGroupwarePage->retrieveKolabServerNameED->setText( KOPrefs::instance()->mRetrieveKolabServer ); 00953 mGroupwarePage->retrieveAnyServerRB->setChecked( !KOPrefs::instance()->mRetrieveKolab ); 00954 mGroupwarePage->retrieveAnyServerURLED->setText( KOPrefs::instance()->mRetrieveAnyURL ); 00955 mGroupwarePage->retrieveUserNameED->setText( KOPrefs::instance()->mRetrieveUserName ); 00956 mGroupwarePage->retrievePasswordED->setText( KOPrefs::instance()->mRetrievePassword ); 00957 mGroupwarePage->retrievePasswordCB->setChecked( KOPrefs::instance()->mRememberRetrievePw ); 00958 } 00959 00960 void KOPrefsDialogGroupwareScheduling::usrWriteConfig() 00961 { 00962 KOPrefs::instance()->mAutoPublish = mGroupwarePage->publishAutoRB->isChecked(); 00963 KOPrefs::instance()->mPublishDelay = mGroupwarePage->publishDelaySB->value(); 00964 KOPrefs::instance()->mPublishFreeBusyDays = mGroupwarePage->publishDaysSB->value(); 00965 KOPrefs::instance()->mPublishKolab = mGroupwarePage->publishKolabRB->isChecked(); 00966 KOPrefs::instance()->mPublishKolabServer = mGroupwarePage->kolabServerNameED->text(); 00967 KOPrefs::instance()->mPublishUserName = mGroupwarePage->publishUserNameED->text(); 00968 KOPrefs::instance()->mPublishAnyURL = mGroupwarePage->anyServerURLED->text(); 00969 KOPrefs::instance()->mPublishPassword = mGroupwarePage->publishPasswordED->text(); 00970 KOPrefs::instance()->mRememberPublishPw = mGroupwarePage->publishPasswordCB->isChecked(); 00971 KOPrefs::instance()->mRetrieveFreeBusy = mGroupwarePage->retrieveCB->isChecked(); 00972 KOPrefs::instance()->mRetrieveKolab = mGroupwarePage->retrieveKolabRB->isChecked(); 00973 KOPrefs::instance()->mRetrieveKolabServer = mGroupwarePage->retrieveKolabServerNameED->text(); 00974 KOPrefs::instance()->mRetrieveAnyURL = mGroupwarePage->retrieveAnyServerURLED->text(); 00975 KOPrefs::instance()->mRetrieveUserName = mGroupwarePage->retrieveUserNameED->text(); 00976 KOPrefs::instance()->mRetrievePassword = mGroupwarePage->retrievePasswordED->text(); 00977 KOPrefs::instance()->mRememberRetrievePw = mGroupwarePage->retrievePasswordCB->isChecked(); 00978 } 00979 00980 extern "C" 00981 { 00982 KCModule *create_korganizerconfigfreebusy( QWidget *parent, const char * ) 00983 { 00984 return new KOPrefsDialogGroupwareScheduling( parent, 00985 "kcmkorganizerfreebusy" ); 00986 } 00987 } 00988 00989 00990 #include "koprefsdialog.moc"
KDE Logo
This file is part of the documentation for korganizer Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:13 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003