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